源码同步脚本
这是用来同步源码的一份脚本,使用的清华aosp镜像。由于同步过程中耗时久,所以不可避免的会出现网络中断等问题,所以写了脚本方便同步。如果失败会自动重试
#!/usr/bin/env bash
export LOG_ACCOUNT=tmp
export LOG_FILENAME=repo-sync
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
aosp_branch=android-11.0.0_r1
if [ ! -d ".repo" ]; then
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b $aosp_branch
repo_stat=$?
if [ $repo_stat -ne 0 ]; then
log -o -- "init repo faild, please try again"
exit 0
fi
else
log -o -- "local .repo dir exists"
fi
try_count=0
log -o -- "from remote sync aosp"
repo sync
repo_stat=$?
while [ $repo_stat -ne 0 ]; do
log -o -- "sync faild, status: $repo_stat, try again in 5s ..."
sleep 5
repo sync
repo_stat=$?
((try_count++))
done
log -o -- "sync repo over, try_count: $try_count"
log -o -unotify "sync over, success"