安装
以下步骤来自于官网
方法1:使用包管理工具进行安装
但是 在 Ubuntu 21 上测试,没有相应包。因此这里采用第二种方法。
# Debian/Ubuntu.
$ sudo apt install repo
# Gentoo.
$ sudo emerge dev-vcs/repo
方法2:手动安装
repo 命令仅仅是一个可执行脚本,因此可以被放在任何位置,只要路径设置正确即可。
$ mkdir -p ~/.bin
$ PATH="${HOME}/.bin:${PATH}"
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
$ chmod a+rx ~/.bin/repo
安装python环境
运行时,如果遇到以下错误:
ubuntu /usr/bin/env: python: No such file or directory
则需要安装python环境
sudo apt install python-is-python3
更换源
Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle
因为墙的问题,需要更换源,这里更换为清华源
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
加速 repo sync
原命令:
repo init -u https://android.googlesource.com/platform/manifest -b android-8.1.0_r52
repo sync
加速后:
repo init --depth 1 -u https://android.googlesource.com/platform/manifest -b android-8.1.0_r52
repo sync -c --no-tags -j4
这里:
- –depth 只执行深度为 1 的浅拷贝
- -c 只拷贝当前分支
- –no-tags 不拷贝标签
- -j<num_jobs> 多线程运行
参考: