## 源码下载
(一)配置下载环境
$sudo apt-get install git-core
配置git
$ git config --global user.name "用户名"
$ git config --global user.email "邮箱"
安装curl
$sudo apt-get install git-core curl
创建bin目录
$ mkdir ~/bin
$ PATH=~/bin:$PATH
下载repo
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
(二)初始化数据仓库
创建源码目录
$mkdir ANDROID_SOURCES
$cd ANDROID_SOURCES
初始化
buttps://android.googlesource.com/platform/manifest
再初始化指定版本库
$repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.2_r6
同步源码仓
$ repo sync
整个源码大小根据版本而不同,越往后的版本源码越大整个就有60G左右,而且在不断更新,因此需要使用脚本去同步,防止断线
#!/bin/bash
echo ¨================start repo sync===============¨
repo sync -f -j4
while [ $? == 1 ]; do
echo ¨================sync failed, re-sync again=============¨
sleep 3
repo sync -f -j4
done