Ubuntu 虚拟机是我新建的,下载的源码特别大,我给虚拟机分配了 600GB 的硬盘。
mkdir ~/bin

后面会将 repo 下载到 bin 目录,将 bin 目录放到环境变量里面的目的是为了后面在任何地方敲击 repo 命令,它都能识别出 repo 命令。
PATH=~/bin:$PATH

目的是后面使用 curl 来下载 repo
sudo apt install curl

curl -sSL -k 'https://gerrit-googlesource.proxy.ustclug.org/git-repo/+/master/repo?format=TEXT' |base64 -d > ~/bin/repo

为 repo 增加可执行权限
chmod a+x repo

export REPO_URL='https://gerrit-googlesource.proxy.ustclug.org/git-repo'

cd ~
mkdir android-12.1.0_r4

cd android-12.1.0_r4/
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-12.1.0_r4

注意这里会有一个报错
/usr/bin/env: ‘python’: No such file or directory
原因是我们没有安装 python
sudo apt-get install python

安装完 python 后,继续执行 repo init
报错没有安装 git

安装 git
sudo apt-get install git

然后,继续执行 repo init

报了证书的错误
解决办法:
export GIT_SSL_NO_VERIFY=1

继续执行 repo init
发现提示要升级 repo

按照提示升级 repo
cp /home/hg/android-12.1.0_r4/.repo/repo/repo /home/hg/bin/repo

执行 repo init
提示要设置 git 的 邮箱和用户名

下面根据提示 设置 git 邮箱和用户名

执行 repo init

我大概用了两个小时
如果下载被中断了,可以继续用 repo sync 下载
repo sync


git branch -av | grep -iE "858c828"
git checkout -b remotes/aosp/android12L-s1-release
