android系统的源代码是通过git和repo来进行组织和管理的,官方提供通过从官网上获取源码的repo工具。
由于国内网路环境的原因,从国内获取android源码库变得较为困难。为了方便后续使用和开发,需要在本地建立一个官网的版本镜像,本文主要是介绍在本地建立android的版本库镜像和从本地版本库获取源代码的方法。
apt-get install git-core
apt-get install git-daemon-run
mkdir -p /pub/gittree
$sudo gedit /etc/sv/git-daemon/run
将该文件中的
/usr/lib/git-core/git-daemon –verbose –base-path=/var/cache /var/cache/git
改为
/usr/lib/git-core/git-daemon –verbose –export-all –base-path=/pub/gittree /pub/gittree
sv stop git-daemon
sv stop git-daemon
ps -ef | grep git
输出
root | 3378 3333 0 10:29 ? | 00:00:00 runsv git-daemon |
gitlog | 3379 3378 0 10:29 ? | 00:00:00 svlogd -tt /var/log/git-daemon |
107 | 3391 3378 0 10:36 ? | 00:00:00 /usr/lib/git-core/git-daemon –verbose –reuseaddr –export-all –base-path=/pub/gittree /pub/gittree |
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
注:
由于防火墙的作用, 国内无法直接访问这个地址, 这里必须要通过国外的代理服务器来完成\\。
我们是在国外购买了一个云主机,然后自行安装代理服务器完成的。
cd /pub/gittree
~/bin/repo init -u https://android.googlesource.com/platform/manifest -mirror
~/bin/repo sync
一共近30G的内容, 时间较长,请耐心等待。
在/pub/gittree.repo/manifest.xml中添加如下内容:
<project path=“prebuilts/gcc/darwin-x86/arm/arm-eabi-4.6” name=“platform/prebuilts/gcc/darwin-x86/arm/arm-eabi-4.6” groups=“pdk,darwin,arm” />
<project path=“prebuilts/gcc/darwin-x86/arm/arm-eabi-4.7” name=“platform/prebuilts/gcc/darwin-x86/arm/arm-eabi-4.7” groups=“pdk,darwin,arm” />
<project path=“prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6” name=“platform/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6” groups=“pdk,darwin,arm” />
<project path=“prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.7” name=“platform/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.7” groups=“pdk,darwin,arm” />
<project path=“prebuilts/gcc/darwin-x86/mips/mipsel-linux-android-4.6” name=“platform/prebuilts/gcc/darwin-x86/mips/mipsel-linux-android-4.6” groups=“pdk,darwin,mips” />
<project path=“prebuilts/gcc/darwin-x86/mips/mipsel-linux-android-4.7” name=“platform/prebuilts/gcc/darwin-x86/mips/mipsel-linux-android-4.7” groups=“pdk,darwin,mips” />
<project path=“prebuilts/gcc/darwin-x86/x86/i686-linux-android-4.6” name=“platform/prebuilts/gcc/darwin-x86/x86/i686-linux-android-4.6” groups=“pdk,darwin,x86” />
<project path=“prebuilts/gcc/darwin-x86/x86/i686-linux-android-4.7” name=“platform/prebuilts/gcc/darwin-x86/x86/i686-linux-android-4.7” groups=“pdk,darwin,x86” />
<project path=“prebuilts/gcc/darwin-x86/x86/x86_64-linux-android-4.7” name=“platform/prebuilts/gcc/darwin-x86/x86/x86_64-linux-android-4.7” groups=“pdk,darwin,x86” />
<project path=“prebuilts/gcc/linux-x86/arm/arm-eabi-4.6” name=“platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6” groups=“pdk,linux,arm” />
<project path=“prebuilts/gcc/linux-x86/arm/arm-eabi-4.7” name=“platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7” groups=“pdk,linux,arm” />
<project path=“prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6” name=“platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6” groups=“pdk,linux,arm” />
<project path=“prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7” name=“platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7” groups=“pdk,linux,arm” />
<project path=“prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.4.3” name=“platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.4.3” groups=“pdk,linux” />
<project path=“prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6” name=“platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6” groups=“pdk,linux” />
<project path=“prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6” name=“platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6” groups=“pdk,linux” />
<project path=“prebuilts/gcc/linux-x86/mips/mipsel-linux-android-4.6” name=“platform/prebuilts/gcc/linux-x86/mips/mipsel-linux-android-4.6” groups=“pdk,linux,mips” />
<project path=“prebuilts/gcc/linux-x86/mips/mipsel-linux-android-4.7” name=“platform/prebuilts/gcc/linux-x86/mips/mipsel-linux-android-4.7” groups=“pdk,linux,mips” />
<project path=“prebuilts/gcc/linux-x86/x86/i686-linux-android-4.6” name=“platform/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.6” groups=“pdk,linux,x86” />
<project path=“prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7” name=“platform/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7” groups=“pdk,linux,x86” />
<project path=“prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.7” name=“platform/prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.7” groups=“pdk,linux,x86” />
<project path=“prebuilts/clang/linux-x86/host/3.3” name=“platform/prebuilts/clang/linux-x86/host/3.3” groups=“linux” />
<project path=“prebuilts/clang/darwin-x86/host/3.3” name=“platform/prebuilts/clang/darwin-x86/host/3.3” groups=“darwin” />
<project path=“hardware/ti/wlan” name=“platform/hardware/ti/wlan” />
<project path=“hardware/ti/wpan” name=“platform/hardware/ti/wpan” />
<project path=“frameworks/uiautomator” name=“platform/frameworks/uiautomator” />
<project path=“external/v8” name=“platform/external/v8” />
<project path=“external/libppp” name=“platform/external/libppp” />
<project path=“external/icu4c” name=“platform/external/icu4c” groups=“pdk” />
<project path=“external/dropbear” name=“platform/external/dropbear” />
<project path=“external/droiddriver” name=“platform/external/droiddriver” />
<project path=“external/chromium_org/third_party/skia/gyp” name=“platform/external/chromium_org/third_party/skia/gyp” />
<project path=“external/chromium_org/third_party/skia/include” name=“platform/external/chromium_org/third_party/skia/include” />
<project path=“external/chromium_org/third_party/skia/src” name=“platform/external/chromium_org/third_party/skia/src” />
<project path=“external/chromium_org/third_party/angle_dx11” name=“platform/external/chromium_org/third_party/angle_dx11” />
再次执行:
~/bin/repo sync
$mkdir ~/android_branck
git clone git://192.168.1.125/git-repo.git
注:
192.168.1.125 为本地源码镜像库的ip地址
vi git-repo/repo
将
REPO_URL = https://gerrit.googlesource.com/git-repo
修改为
REPO_URL = git://192.168.1.125/git-repo
git config –global user.email “zhanhl@idste.cn”
git config –global user.name “zhanhl”
./git-repo/repo init -u git:192.168.1.125/platform/manifest -b android-4.4.2_r1
./git-repo/repo sync