如何解决国内镜像aosp进行repo sync太慢问题?

国内镜像下载代码的痛点“慢”

repo速度太慢

需要排队:

repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest  -b android-16.0.0_r4
Downloading Repo source from https://mirrors.tuna.tsinghua.edu.cn/git/git-repo



remote: Waiting in queue... (Position: 6)

经常repo init半天不动,大家以为repo卡死了,要等待好几个小时才可以完成。

好不容易repo init好了后,发现repo sync又是很慢。

repo sync
Syncing:  0% (4/1011) 49:00 | 4 jobs | 13:03 platform/boSyncing:

有学员反应花了几天才repo成功,这个情况也确实可能有的,但是最后时间虽然长,也是可以repo sync下来的。

文章参考:

清华镜像(确实比较慢)

https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/

中科大镜像 (稍微好一点)

https://mirrors.ustc.edu.cn/help/aosp.html

慢原因是啥?

1、repo的人越来越多,说明大家对aosp源码修改学习需求变大

2、清华大学镜像等开源节流,服务器肯定进行了降级

有没有快一些的方式呢?

解决办法

使用代理方式

这个有的有条件可以访问google外网,可以直接访问google官方库
下载repo

mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

再进行初始化仓库

repo init --partial-clone -b main -u https://android.googlesource.com/platform/manifest

进行repo

$ repo sync -c -j8

参考网站:https://source.android.com/docs/setup/download?hl=zh-cn

国内镜像直接使用压缩包方式

参考:https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/

压缩包的下载

wget -c https://mirrors.ustc.edu.cn/aosp-monthly/aosp-latest.tar

速度在40m以上
在这里插入图片描述
注意下载完成记得确认一下md5是否正确

https://mirrors.ustc.edu.cn/aosp-monthly/

在这里插入图片描述主要目的以防网络下载偶尔有错误,要保证压缩包数据完全正常.
使用如下命令md5sum进行计算压缩包md5码

test@test:~/disk_2T/ustc-aosp16$ md5sum aosp-latest.tar 
229f0c7d457d777417a5e768ce339892  aosp-latest.tar

发先和官网匹配,说明压缩包没有问题

在这里插入图片描述

解压压缩包
tar xf aosp-latest.tar
cd AOSP
git -C ./.repo/manifests.git/ remote set-url origin https://mirrors.ustc.edu.cn/aosp/platform/manifest.git

注意可能等待时间较长,这个也需要耐心和硬盘速度有关系,大概20分钟。

切换成目标branch然后进行repo sync

需要到解压的aosp目录中去,然后

cd .repo/manifests

然后进行checkout到自己目标的branch既可以,我这里是android-16.0.0_r4


test@test:~/disk_2T/ustc-aosp16/aosp/.repo/manifests$ git checkout -b android-16.0.0_r4 remotes/origin/android-16.0.0_r4
Branch 'android-16.0.0_r4' set up to track remote branch 'android-16.0.0_r4' from 'origin'.
Switched to a new branch 'android-16.0.0_r4'

核心命令就是:

git checkout -b android-16.0.0_r4 remotes/origin/android-16.0.0_r4

注意这类的remotes/origin/android-16.0.0_r4可以通过git branch -a进行获取。

最后进行repo sync命令执行

 repo sync -j 4
Syncing: 100% (1011/1011), done in 56m38.096s
Finalizing sync state...
Checking for bloat: 100% (98/98), done in 13.327s
warning: Project "platform/prebuilts/clang/host/linux-x86" is accumulating unoptimized data. Please run "repo sync --auto-gc" or "repo gc --repack" to clean up.
repo sync has finished successfully.

注意这个时间也可能较长,我这也花了5个小时,大家不要着急,可以晚上repo第二天早上看。

其他方案尝试:
有同学反应建议可以使用其他学校镜像进行下载,比如南京大学,但是尝试后发现repo sync都有比较多的错误,最后没有成功。学员朋友提供了其他学校的我这边也没有挨个尝试了,大家感兴趣的可以去试试。

在这里插入图片描述
原文地址及framework手把手指导:
https://mp.weixin.qq.com/s/oLlJMDEKYqcjoPThzzdaqA

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

千里马学框架

帮助你了,就请我喝杯咖啡

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值