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 即可保持同步。

參考

清華大學開源軟件鏡像站

發佈了24 篇原創文章 · 獲贊 14 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章