最近写文章,反复多次折腾AOSP代码,因通过网络repo sync aosp代码,能一次顺利下载的概率很低,以前就经常遇到,但从未总结,导致自己也要回头检索方法,所以觉得可以总结一下,涉及下载最新、各分支AOSP代码的方法,以及如何处理所遇到的同步错误及其解决方法,现分享给大家~
(1)下载初始化包,约 60GB 数据,建议复制地址,直接使用迅雷下载
szhou@bc-R01:~/works$curl -OC - https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar
(2)解压
szhou@bc-R01:~/works$ mkdir aosp
szhou@bc-R01:~/works$ tar -xvf aosp-latest.tar -C aosp/
(3)下载repo
szhou@bc-R01:~/works/aosp$ mkdir bin
szhou@bc-R01:~/works/aosp$ curl https://storage.googleapis.com/git-repo-downloads/repo > bin/repo
szhou@bc-R01:~/works/aosp$ curl https://storage.googleapis.com/git-repo-downloads/repo > bin/repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 48143 100 48143 0 0 48336 0 --:--:-- --:--:-- --:--:-- 48287
(4)部署repo
szhou@bc-R01:~/works/aosp$ chmod a+x bin/repo
szhou@bc-R01:~/works/aosp$ sudo cp bin/repo /usr/bin/
[sudo] password for szhou:
szhou@bc-R01:~/works/aosp$
szhou@bc-R01:~/works/aosp/aosp$ ls -al
total 12
drwxr-xr-x 3 szhou szhou 4096 10月 1 00:00 .
drwxrwxr-x 4 szhou szhou 4096 12月 24 00:39 ..
drwxr-xr-x 7 szhou szhou 4096 10月 1 00:45 .repo
szhou@bc-R01:~/works/aosp/aosp$
szhou@bc-R01:~/works/aosp/aosp$ ls -al
total 12
drwxr-xr-x 3 szhou szhou 4096 10月 1 00:00 .
drwxrwxr-x 4 szhou szhou 4096 12月 24 00:39 ..
drwxr-xr-x 7 szhou szhou 4096 10月 1 00:45 .repo
szhou@bc-R01:~/works/aosp/aosp$ cd .repo/repo/
szhou@bc-R01:~/works/aosp/aosp/.repo/repo$ git pull
remote: Enumerating objects: 263, done.
remote: Counting objects: 100% (191/191), done.
remote: Compressing objects: 100% (138/138), done.
remote: Total 263 (delta 152), reused 55 (delta 53), pack-reused 72
Receiving objects: 100% (263/263), 264.03 KiB | 11.00 MiB/s, done.
Resolving deltas: 100% (158/158), completed with 12 local objects.
From https://mirrors.tuna.tsinghua.edu.cn/git/git-repo
1e9f7b9..4c80921 stable -> origin/stable
83c66ec..b1d1ece main -> origin/main
* [new tag] v2.40 -> v2.40
* [new tag] v2.38 -> v2.38
* [new tag] v2.39 -> v2.39
Updating 1e9f7b9..4c80921
Fast-forward
.github/workflows/close-pull-request.yml | 22 +++
.github/workflows/test-ci.yml | 5 +-
color.py | 4 +-
…… 略……
tests/test_wrapper.py | 2 +-
tox.ini | 7 +-
60 files changed, 3043 insertions(+), 2389 deletions(-)
create mode 100644 .github/workflows/close-pull-request.yml
create mode 100644 git_trace2_event_log_base.py
szhou@bc-R01:~/works/aosp/aosp/.repo/repo$
szhou@bc-R01:~/works/aosp/aosp/.repo/manifests.git$ git branch -av | grep android-13
remotes/origin/android-13.0.0_r1 0f42cde46 Manifest for Android 13.0.0 Release 1 (TP1A.220624.014)
remotes/origin/android-13.0.0_r10 e64b26003 Manifest for Android 13.0.0 Release 10
…… 略 ……
remotes/origin/android-13.0.0_r80 4ca496b8e Manifest for Android 13.0.0 Release 80
remotes/origin/android-13.0.0_r81 259db423b Manifest for Android 13.0.0 Release 81
remotes/origin/android-13.0.0_r82 ed487956f Manifest for Android 13.0.0 Release 82
remotes/origin/android-13.0.0_r9 0bac787fd Manifest for Android 13.0.0 Release 9
szhou@bc-R01:~/works/aosp/aosp/.repo/manifests.git$
操作如下图所示
szhou@bc-R01:~/works/aosp/aosp/.repo/manifests.git$ cd ../..
szhou@bc-R01:~/works/aosp/aosp$ repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-13.0.0_r82
File "/usr/bin/repo", line 51
def print(self, *args, **kwargs):
^
SyntaxError: invalid syntax
szhou@bc-R01:~/works/aosp/aosp$ python --version
Python 2.7.18
szhou@bc-R01:~/works/aosp/aosp$
sudo apt-get install python2.7
(1)查看已安装的Python有哪些版本
szhou@bc-R01:~/works/aosp/aosp$ ls -l /usr/bin/python*
lrwxrwxrwx 1 root root 24 12月 10 20:34 /usr/bin/python -> /etc/alternatives/python
lrwxrwxrwx 1 root root 9 3月 13 2020 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3662032 7月 1 2022 /usr/bin/python2.7
lrwxrwxrwx 1 root root 33 7月 1 2022 /usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root 16 3月 13 2020 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root 9 12月 10 08:57 /usr/bin/python3 -> python3.8
-rwxr-xr-x 1 root root 5465880 11月 22 18:22 /usr/bin/python3.8
lrwxrwxrwx 1 root root 33 11月 22 18:22 /usr/bin/python3.8-config -> x86_64-linux-gnu-python3.8-config
lrwxrwxrwx 1 root root 16 3月 13 2020 /usr/bin/python3-config -> python3.8-config
-rwxr-xr-x 1 root root 384 1月 25 2023 /usr/bin/python3-futurize
-rwxr-xr-x 1 root root 388 1月 25 2023 /usr/bin/python3-pasteurize
lrwxrwxrwx 1 root root 14 4月 15 2020 /usr/bin/python-config -> python2-config
szhou@bc-R01:~/works/aosp/aosp$
(1)配置多版本支持
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 2
(2)执行 --config python后,选择Python3.8, 编号为2
szhou@bc-R01:~/works/aosp/aosp$ sudo update-alternatives --config python
[sudo] password for szhou:
There are 2 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python3.8 2 auto mode
* 1 /usr/bin/python2.7 1 manual mode
2 /usr/bin/python3.8 2 manual mode
Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/python3.8 to provide /usr/bin/python (python) in manual mode
szhou@bc-R01:~/works/aosp/aosp$
(3)查看版本设置情况
szhou@bc-R01:~/works/aosp/aosp$ python --version
Python 3.8.10
szhou@bc-R01:~/works/aosp/aosp$
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-13.0.0_r82
szhou@bc-R01:~/works/aosp/aosp$ repo sync -c
szhou@bc-R01:~/works/aosp/aosp/.repo/manifests.git$ cd ../..
szhou@bc-R01:~/works/aosp/aosp$ repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-13.0.0_r82
File "/usr/bin/repo", line 51
def print(self, *args, **kwargs):
^
SyntaxError: invalid syntax
szhou@bc-R01:~/works/aosp/aosp$ python --version
Python 2.7.18
szhou@bc-R01:~/works/aosp/aosp$
szhou@oa-R630:~/works/aosp$ /home/szhou/Downloads/aosp/bin/repo sync -c
Fetching: 100% (1146/1146), done in 11m43.689s
info: A new version of repo is available
repo: Updating release signing keys to keyset ver 2.3
warning: repo is not tracking a remote branch, so it will not receive updates
================================================================================
Repo command failed: RepoUnhandledExceptionError
szhou@oa-R630:~/works/aosp$
szhou@oa-R630:~/works/aosp/.repo/repo$ git pull
sync -lc
: revision refs xxxszhou@oa-R630:~/works/aosp$ /home/szhou/Downloads/aosp/bin/repo sync -c
error: Cannot checkout device/google/raviole-kernel: ManifestInvalidRevisionError: revision refs/tags/android-13.0.0_r82 in device/google/raviole-kernel not found
error: in `sync -c`: revision refs/tags/android-13.0.0_r82 in device/google/raviole-kernel not found
szhou@oa-R630:~/works/aosp$ ls -al
total 24
drwxr-xr-x 6 szhou szhou 4096 12月 20 11:11 .
drwxrwxr-x 5 szhou szhou 4096 12月 20 10:53 ..
drwxrwxr-x 36 szhou szhou 4096 12月 20 11:11 art
drwxrwxr-x 4 szhou szhou 4096 12月 20 11:11 device
drwxrwxr-x 3 szhou szhou 4096 12月 20 11:11 external
drwxr-xr-x 7 szhou szhou 4096 12月 20 11:10 .repo
szhou@oa-R630:~/works/aosp$ cd .repo/
manifests/ manifests.git/ project-objects/ projects/ repo/
szhou@oa-R630:~/works/aosp$ cd .repo/manifests.git/
branches/ hooks/ info/ logs/ objects/ refs/
szhou@oa-R630:~/works/aosp$ cd .repo/
manifests/ manifests.git/ project-objects/ projects/ repo/
szhou@oa-R630:~/works/aosp$ cd .repo/manifests
manifests/ manifests.git/
szhou@oa-R630:~/works/aosp$ cd .repo/
manifests/ manifests.git/ project-objects/ projects/ repo/
szhou@oa-R630:~/works/aosp$ cd .repo/projects/
art.git/ build/ developers/ external/ kernel/ packages/ prebuilts/ test/
bionic.git/ cts.git/ development.git/ frameworks/ libcore.git/ pdk.git/ sdk.git/ toolchain/
bootable/ dalvik.git/ device/ hardware/ libnativehelper.git/ platform_testing.git/ system/ tools/
szhou@oa-R630:~/works/aosp$ cd .repo/projects/device
szhou@oa-R630:~/works/aosp/.repo/projects/device$ cd -
/home/szhou/works/aosp
szhou@oa-R630:~/works/aosp$ rm -rf .repo/projects/device
szhou@oa-R630:~/works/aosp$ /home/szhou/Downloads/aosp/bin/repo sync -c
Checking out: 100% (1145/1145), done in 10m12.341s
error: Unable to fully sync the tree
error: Checking out local projects failed.
Failing repos:
device/generic/trusty
device/generic/uml
device/generic/vulkan-cereal
art
device/google/pantah-sepolicy
device/google/raviole
Try re-running with "-j1 --fail-fast" to exit at the first error.
================================================================================
Repo command failed due to the following `SyncError` errors:
device/generic/trusty checkout 05e24c85c2a542498ccf2983d898fcf0e6f9edd2
device/generic/uml checkout 60bc18c3a72bbed9640edaba4422fec18f36d6e9
device/generic/vulkan-cereal checkout 4b79dc90f067220adcc37bc24dae8f211ebe2d17
platform/art checkout b4ac1db327a419fb87e83c8b6f9825bc5fc126c3
device/google/pantah-sepolicy checkout 28219f7c6376cd1a810517d770029439dde653d5
+1 additional errors...
szhou@oa-R630:~/works/aosp$