Android源码下载教程二(成功率极高)

传统下载方法:Android源码下载流程

使用传统方法下载,首次同步需要下载约 60GB 数据,过程中任何网络故障都可能造成同步失败,需要频繁输入repo sync,一点都不省心。

清华镜像站提供了另外一种下载方法,每月更新的初始化包,直接下载一个tar包,直接解压放出代码即可。之后还可以使用repo sync同步最新代码,和传统方法并无差别。

一、下载aosp-latest.tar

下载初始化包

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

下载trace显示,从下午4点到晚上12点,下了8个钟,才下完。不过还是很顺利,没有出现下载失败的情况。

--2019-11-28 16:24:33--  https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-20191101.tar
Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1
Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 65436395520 (61G) [application/octet-stream]
Saving to: ‘aosp-20191101.tar’

aosp-20191101.tar                                      0%[                                                                                                                       ] 353.45M  49.4KB/s    in 7m 52s  

2019-11-28 16:32:25 (767 KB/s) - Connection closed at byte 370622121. Retrying.

--2019-11-28 16:32:26--  (try: 2)  https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-20191101.tar
Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 65436395520 (61G), 65065773399 (61G) remaining [application/octet-stream]
Saving to: ‘aosp-20191101.tar’

aosp-20191101.tar                                      2%[==>                                                                                                                    ]   1.65G  3.95MB/s    in 11m 47s 

2019-11-28 16:59:13 (1.89 MB/s) - Read error at byte 1773649187/65436395520 (Success). Retrying.

--2019-11-28 16:59:15--  (try: 3)  https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-20191101.tar
Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 65436395520 (61G), 63662746333 (59G) remaining [application/octet-stream]
Saving to: ‘aosp-20191101.tar’

aosp-20191101.tar                                     39%[+++===========================================>                                                                        ]  24.20G  2.05MB/s    in 2h 30m  

2019-11-28 19:29:45 (2.56 MB/s) - Connection closed at byte 25983204252. Retrying.

--2019-11-28 19:29:48--  (try: 4)  https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-20191101.tar
Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 65436395520 (61G), 39453191268 (37G) remaining [application/octet-stream]
Saving to: ‘aosp-20191101.tar’

aosp-20191101.tar                                     42%[+++++++++++++++++++++++++++++++++++++++++++++++==>                                                                     ]  26.11G   871KB/s    in 23m 5s  

2019-11-28 19:52:53 (1.41 MB/s) - Connection closed at byte 28031564308. Retrying.

--2019-11-28 19:52:57--  (try: 5)  https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-20191101.tar
Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 65436395520 (61G), 37404831212 (35G) remaining [application/octet-stream]
Saving to: ‘aosp-20191101.tar’

aosp-20191101.tar                                     49%[++++++++++++++++++++++++++++++++++++++++++++++++++=======>                                                             ]  30.14G  1008KB/s    in 40m 49s 

2019-11-28 20:33:48 (1.69 MB/s) - Connection closed at byte 32366786700. Retrying.

--2019-11-28 20:33:53--  (try: 6)  https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-20191101.tar
Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 65436395520 (61G), 33069608820 (31G) remaining [application/octet-stream]
Saving to: ‘aosp-20191101.tar’

aosp-20191101.tar                                    100%[++++++++++++++++++++++++++++++++++++++++++++++++++++++++++============================================================>]  60.94G  3.95MB/s    in 3h 40m  

2019-11-29 00:13:58 (2.39 MB/s) - ‘aosp-20191101.tar’ saved [65436395520/65436395520]

二、解压并同步代码

解压,解压到aosp工程目录,解压时间根据系统性能决定。

tar xf aosp-latest.tar

解压完成后进入aosp目录,这时 ls 的话什么也看不到,因为只有一个隐藏的 .repo 目录

cd aosp

同步代码,正常同步一遍即可得到完整目录

repo sync

repo sync -l 仅checkout代码,也就是不需要联网,直接本地同步出代码

三、更新代码

每次只需运行 repo sync 即可保持同步。

参考

清华大学开源软件镜像站

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值