用户工具

站点工具


创建android本地版本库

iDste:创建android本地版本库

android系统的源代码是通过git和repo来进行组织和管理的,官方提供通过从官网上获取源码的repo工具。

由于国内网路环境的原因,从国内获取android源码库变得较为困难。为了方便后续使用和开发,需要在本地建立一个官网的版本镜像,本文主要是介绍在本地建立android的版本库镜像和从本地版本库获取源代码的方法。

建立本地版本镜像

1. 在ubuntu系统上安装git-core

apt-get install git-core
apt-get install git-daemon-run

2. 创建本地源码库的存放路径

mkdir -p /pub/gittree

3. 修改配置:

$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

4. 重启git服务

sv stop git-daemon
sv stop git-daemon

5. 确认服务已经正确运行

ps -ef | grep git
输出

root3378 3333 0 10:29 ?00:00:00 runsv git-daemon
gitlog3379 3378 0 10:29 ?00:00:00 svlogd -tt /var/log/git-daemon
1073391 3378 0 10:36 ?00:00:00 /usr/lib/git-core/git-daemon –verbose –reuseaddr –export-all –base-path=/pub/gittree /pub/gittree

6. 将源码库从官网上同步到本地

注:
由于防火墙的作用, 国内无法直接访问这个地址, 这里必须要通过国外的代理服务器来完成\\。 我们是在国外购买了一个云主机,然后自行安装代理服务器完成的。

7. 初始化和同步源码库

cd /pub/gittree
~/bin/repo init -u https://android.googlesource.com/platform/manifest -mirror
~/bin/repo sync

一共近30G的内容, 时间较长,请耐心等待。

8. 添加4.4.1的分支的工程同步完成后, 默认是将最新版本库同步到了本地。在做imx上的android系统开发时, 系统源码需要 android-4.4.2_r1分支。 在这个分支上,有一些老版本的工程, 默认在做镜像时不会被同步到本地, 因此需要手动添加:

在/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

从本地库中checkout源码

1. 创建本地的开发目录

$mkdir ~/android_branck

2. 获取repo工具

git clone git://192.168.1.125/git-repo.git
注:
192.168.1.125 为本地源码镜像库的ip地址

3. 修改repo的源地址

vi git-repo/repo
将 REPO_URL = https://gerrit.googlesource.com/git-repo
修改为 REPO_URL = git://192.168.1.125/git-repo

4. 配置git的用户信息

git config –global user.email “zhanhl@idste.cn”
git config –global user.name “zhanhl”

5. 初始化和checkout源代码

./git-repo/repo init -u git:192.168.1.125/platform/manifest -b android-4.4.2_r1
./git-repo/repo sync

创建android本地版本库.txt · 最后更改: 2020/08/24 14:45 (外部编辑)