加入收藏 | 设为首页 | 会员中心 | 我要投稿 | RSS
您当前的位置:首页 > 教程文章 > Android开发

如何建立本地Android源代码镜像

时间:2014-04-16 00:00:36  来源:  作者:

Step 1: 安装git和repo
git的安装与使用之前已经介绍过,详见
安装repo:
$mkdir ~/bin
$PATH=~/bin:$PATH
PS:如果不想每次都输入上面这条语句,可以在.bashrc中加入 export PATH=~/bin:$PATH
$curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$chmod a+x ~/bin/repo
Step 2: 安装git服务
$sudo apt-get install git-daemon-run
修改配置:
源代码容量较大,这里我在机器上挂了一块新硬盘专门存储源码,挂载点为/mnt/source
$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=/mnt/source /mnt/source
下面重启服务
$sudo sv stop git-daemon
$sudo sv start git-daemon
使用如下命令可以查看配置是否生效
$sudo ps -ef | grep “git”
Step 3: 建立本地Android源代码镜像
$mkdir /mnt/source/google
$cd /mnt/source/google
$repo init –-mirror -u https://android.googlesource.com/platform/manifest.git -b android-2.4.3_r1
$repo sync
同步的时间与网络连接速度有关。
Step 4:使用本地源
首先创建一个repo的副本
$cp ~/bin/repo ~/bin/repo-custom
使用文本编辑器打开副本,修改其中REPO_URL的值为本地服务的地址,如:git://127.0.0.1/google/
创建一个工作目录,并用本地库进行同步
$mkdir ~/test
$cd ~/test
$repo-custom init -u git://127.0.0.1/google/platform/manifest -b master
$vi .repo/manifests/default.xml
将fetch的值指向本地地址git://127.0.0.1/google/
$repo-custom sync

####################################################

Using a local mirror


When using several clients, especially in situations where bandwidth is scarce, it is better to create a local mirror of the entire server content, and to sync clients from that mirror (which requires no network access). The download for a full mirror is smaller than the download of two clients, while containing more information.

These instructions assume that the mirror is created in /usr/local/aosp/mirror. The first step is to create and sync the mirror itself, which uses close to 13GB of network bandwidth and a similar amount of disk space. Notice the --mirror flag, which can only be specified when creating a new client:

$ mkdir -p /usr/local/aosp/mirror 
$ cd
/usr/local/aosp/mirror 
$ repo init
-u https://android.googlesource.com/mirror/manifest --mirror 
$ repo sync

Once the mirror is synced, new clients can be created from it. Note that it's important to specify an absolute path:

$ mkdir -p /usr/local/aosp/master 
$ cd
/usr/local/aosp/master 
$ repo init
-u /usr/local/aosp/mirror/platform/manifest.git 
$ repo sync

Finally, to sync a client against the server, the mirror needs to be synced against the server, then the client against the mirror:

$ cd /usr/local/aosp/mirror 
$ repo sync 
$ cd
/usr/local/aosp/master 
$ repo sync

It's possible to store the mirror on a LAN server and to access it over NFS, SSH or Git. It's also possible to store it on a removable drive and to pass that drive around between users or between machines.

来顶一下
返回首页
返回首页
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
推荐资讯
在CentOS下搭建Android 开发环境
在CentOS下搭建Androi
轻松搭建属于自己的Ubuntu发行版
轻松搭建属于自己的Ub
利用SUSE Studio 打造自己的个性化Linux发行版
利用SUSE Studio 打造
那些采用PHP技术的IT大企业
那些采用PHP技术的IT大
相关文章
    无相关信息
栏目更新
栏目热门