0%

基于aosp-lastest.tar同步AOSP源码

概述

使用TUNA AOSP初始包(aosp-lastest.tar)同步AOSP最新源码。

步骤

Repo

1
2
3
4
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
chmod +x repo
sudo mv repo /usr/local/bin/
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'

下载、校验、解压

下载aosp-latest.tar后,md5sum aosp-latest.tar计算并对比校验和,无误则执行tar xf aosp-latest.tar解压

设置分支(可选)

1
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-12.0.0_r2

不设置则默认下载主分支源码

同步源码

1
repo sync -j4

此后,每次只需运行repo sync即可保持同步。 我们强烈建议您保持每天同步,并尽量选择凌晨等低峰时间

使用Local Manifests克隆设备代码

打开.repo/manifests/default.xml,增加以下内容(已有则不需要添加):

1
2
<remote  name="github"
fetch="https://github.com/" />

创建.repo/local_manifests/hammerhead.xml(使用revision指定版本):

1
2
3
4
5
6
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project name="z3DD3r/android_device_lge_hammerhead" revision="lineage-18.1" path="device/lge/hammerhead" remote="github" />
<project name="z3DD3r/android_kernel_lge_hammerhead" revision="lineage-18.1" path="kernel/lge/hammerhead" remote="github" />
<project name="z3DD3r/android_vendor_lge" revision="lineage-18.1" path="vendor/lge" remote="github" />
</manifest>

之后repo sync -c -j4 --force-sync即可

遇到的问题

error: RPC failed; curl 56 GnuTLS recv error (-9)

1
2
3
apt-get install gnutls-bin
git config --global http.sslVerify false
git config --global http.postBuffer 1048576000

关闭SSL校验,并设置缓冲区大小

curl 56 GnuTLS recv error (-110): The TLS connection was non-properly terminated.

gnutls_handshake错误,建议取消代理后再同步代码

也可以使用openssl代替gnutls,重新编译git(未测试)
详见error RPC failed; curl 56 GnuTLS recv error (-110) The TLS connection was non-properly terminated

如果编译时提示依赖未安装,sudo apt install安装依赖即可

fatal: Could not reset index file to revision

1
2
3
warning: repo is not tracking a remote branch, so it will not receive updates
repo reset: error: Entry 'git_superproject.py' not uptodate. Cannot merge.
fatal: Could not reset index file to revision 'vx.x.x^0'

解决:

cd 到.repo/repo
git reset –hard 倒数第二个commit
git pull
最后再repo sync

参考

Android 8.1.0 AOSP源码下载及编译
解决git clone 完成后提示’error: RPC failed; curl 56 GnuTLS recv error (-9)’