# 从 .repo/manifest.xml 中提取 include 文件名 includes=$(grep "<include " .repo/manifest.xml | sed -n 's/.*name="\([^"]*\)".*/\1/p')
# 遍历所有 include 的文件 for inc in $includes; do incfile=".repo/manifests/$inc" if [ -f "$incfile" ]; then # 提取 incfile 中的 <project> 标签并生成 remove-project grep "<project " "$incfile" | while read line; do name=$(echo "$line" | sed -n 's/.*name="\([^"]*\)".*/\1/p') if [ -n "$name" ]; then echo " <remove-project name=\"$name\" />" >> "$OUTFILE" fi done else echo "警告:未找到被 include 的文件 $incfile" fi done