1、获取远程供应商的repo镜像
repo init --mirror -u ssh://$username@$host_name:29418/manifests -b xx_branch --repo-url=ssh://$username@$host_name:29418/xx_repo -m $project_manifest.xml
repo sync -j4
2、将获取的repo镜像推送到远程gerrit服务器并批量创建仓库
ssh -p 29418 $username@$local_host_name gerrit ls-projects (测试命令,查询相关仓库的权限)
ssh -p 29418 $username@$local_host_name gerrit create-project $project_name/mirror-project-permission-base (创建权限控制base)
repo forall -c 'ssh -p 29418 $username@$local_host_name gerrit create-project $project_name/$REPO_PROJECT' (在服务器上批量创建$REPO_PROJECT各仓库)
repo forall -c 'ssh -p 29418 $username@$local_host_name gerrit set-project-parent --parent $project_name/mirror-project-permission-base $project_name/$REPO_PROJECT'(权限设置)
repo forall -c 'git push ssh://$username@$local_host_name:29418/$project_name/$REPO_PROJECT "refs/heads/*:refs/heads/$project_name/*"'(将本地仓库推送到gerrit服务器)
3、代码树下载
repo init -u ssh://$username@$local_host_name:29418/$project/manifests --repo--url ssh://$username@$local_host_name:29418/public/repo -m $project_manifest.xml (或者-b $android_branch)
repo sync
4、脚本无限下载,直到成功
while true; do
repo sync
if [ $?=0 ]; then
echo "Download success!"
exit 0
else
echo "Download failed!"
fi
done