方法一、使用已打包的源码包
下载已经打包的源码包,24G吧,然后基于源码包更新即可:
#!/bin/sh # 下载初始化包 wget https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar #解压 tar -xf aosp-latest.tar # 解压得到的 AOSP 工程目录 cd AOSP # 这时 ls 的话什么也看不到,因为只有一个隐藏的 .repo 目录 repo sync # 正常同步一遍即可得到完整目录
方法二、直接从获取源码树
从清华镜像站下载源码
https://mirrors.tuna.tsinghua.edu.cn/help/AOSP
下载 repo 工具
所有的源码的获取、更新,都是基于该命令工具的;
https://storage.googleapis.com/git-repo-downloads/repo
保存为 repo 文件
创建保存源码的目录
#!/bin/sh mkdir WORKING_DIRECTORY cd WORKING_DIRECTORY
初始化仓库
#!/bin/sh repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest # 如果需要某个特定的 Android 版本(列表): # repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-4.0.1_r1 # 如果提示无法连接到 gerrit.googlesource.com,可以编辑 repo,把 REPO_URL 一行替换成下面的: # REPO_URL = 'https://gerrit-google.tuna.tsinghua.edu.cn/git-repo' # 查看所有的分支:https://stackoverflow.com/questions/26127319/git-repo-how-to-list-all-branches-in-one-google-repo # git --git-dir .repo/manifests.git/ branch -a
同步源码树(以后只需执行这条命令来同步):
#!/bin/sh repo syncwo25826
修改镜像站的地址
比如之前是从 android.googlesource.com 获取的,想换别的,需要修改两个地方:
(1)、.repo/manifest.xml ,把 name=”aosp” 的 remote节点 的 fetch值
从 https://android.googlesource.com
改为
https://aosp.tuna.tsinghua.edu.cn/
(2)、.repo/manifests.git/config,将
url = https://android.googlesource.com/platform/manifest
更改为
url = https://aosp.tuna.tsinghua.edu.cn/platform/manifest
参考文献
Downloading the Source:https://source.android.com/source/downloading