下载基础包
wget -c https://mirrors.ustc.edu.cn/aosp-monthly/aosp-latest.tar
解压到自己的工作目录,比如 ~/aosp/
tar xvf aosp-latest.tar -C ~/aosp/
更新repo
一定要更新,因为如果不更新,执行repo sync中途会报错,让你更新repo后继续
进入工作目录( ~/aosp/),更新本地repo:
# 进入到代码根目录
cd ~/aosp/
#进入到 .repo/ 目录更新repo
cd .repo/repo/ && git pull
# 查找repo路径
which repo
# 会输出一个位置,比如 /bin/repo 或者/usr/local/bin
# 覆盖更新repo 此处需要根据自己的本机路径做调整
# sudo cp {AOSP代码根路径}/.repo/repo/repo {本机环境变量中repo路径}
sudo cp ~/aosp/.repo/repo/repo /usr/local/bin/
更新仓库URL
进入工作目录( ~/aosp/),更新镜像地址:
cd ~/aosp/
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest
# 检查更新url是否成功
cat ~/aosp/.repo/manifests.git/config | grep url
# 如果输出跟上面的地址相同,就表示设置成功了
# url = git://mirrors.ustc.edu.cn/aosp/platform/manifest
# url = git://mirrors.ustc.edu.cn/aosp/platform/manifest
查找分支
如果没有找到,那么只有1种情况,就是基础包中没更新到,先执行一遍repo sync,同步所有分支后再查找
cd ~/aosp/.repo/manifests/
git branch -al | cut -d / -f 3
同步代码
切换分支,并开始同步:
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android12-gsi
repo sync -c --no-tags -j4 # 最大4个线程,多了会被中科大服务器拒绝
AOSP - USTC Mirror HelpUSTC Mirror Helphttps://mirrors.ustc.edu.cn/help/aosp.html