在使用repo sync下载代码的时候,经常由于网络不稳定等因素导致下载失败,采用循环不断下载的方法,脚步如下:
vim ~/bin/repo_sync
#!/bin/bash
trap 'echo "ctrl+c force exit"; exit' SIGINT
ALL_PKG=`grep project .repo/manifest.xml | awk '{print $3}' | cut -d'"' -f2`
ERR_PKG=""
T_PKG=$ALL_PKG
echo "repo package list:\n $T_PKG"
rm -rf ./success.pkg
while [ 1 ]
do
for i in $T_PKG
do
echo "check package:$i"
grep "$i" ./success.pkg >/dev/null 2>&1
if [ $? -eq 0 ]; then
continue
fi
repo sync $i
if [ $? -ne 0 ]; then
echo "SYNC Error package:$i"
ERR_PKG="$ERR_PKG $i"
continue
else
grep "$i" ./success.pkg >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "$i" >> ./success.pkg
fi
echo "SYNC Success package:$i"
fi
done
if [ "$ERR_PKG" = "" ]; then
echo "SYNC ALL"
rm -rf ./success.pkg
exit 0
else
T_PKG=$ERR_PKG
ERR_PKG=""
fi
echo "repo resync loop package list:\n $T_PKG"
done
chmod +x ~/bin/repo_sync;
在repo 工程下执行 ~/bin/repo_sync;
如果想在异常的时候退出,按Ctrl+c 退出即可。