dreampet 发表于 2015-8-21 11:08:35

i.mx6开发教程-搭建Android源码内网镜像服务器

本帖最后由 dreampet 于 2015-8-21 11:18 编辑

本篇教程的目的是让大家可以在Google被屏蔽的情况下利用清华大学的镜像服务器搭建任意分支的Android源码本地镜像服务器
(这个方法适合团队开发,如果自己开发,直接从清华大学的镜像服务器上checkout下来就可以了)

系统:Ubuntu 14.04
平台:SABRESD-DL

1. 搭建git 服务器
a. 安装git-daemon
sudo apt-get installgit-all
sudo apt-get install git-daemon-sysvinitb.配置git-daemon
sudo gedit /etc/default/git-daemon配置文件内容如下(我已经配置好的,用户名是dev,git仓库目录为~/coderepo)
# Defaults for git-daemon initscript
# sourced by /etc/init.d/git-daemon
# installed at /etc/default/git-daemon by the maintainer scripts

#
# This is a POSIX shell fragment
#

GIT_DAEMON_ENABLE=true                                                                      #是否启用git-daemon
GIT_DAEMON_USER=dev                                                                           #运行git-daemon的用户,该用户需要具备对仓库目录的读写权限
GIT_DAEMON_BASE_PATH=/home/dev/coderepo                              #仓库目录
GIT_DAEMON_DIRECTORY="/var/cache/git /home/dev/coderepo"    #白名单,至少要包括仓库目录

# Additional options that are passed to the Daemon.                              #参数设置,允许上传下载等
GIT_DAEMON_OPTIONS="--export-all --enable=upload-pack --enable=upload-archive --enable=receive-pack --informative-errors"c. 启动git-daemon服务
sudo /etc/init.d/git-daemon startd. 检查git-daemon是否正常启动
service --status-all |grep 'git-daemon'如果git-daemon前面是'+'号,说明已经正常启动

2. 安装repo
sudo apt-get install python-dev phablet-tools
3. 建立android主干代码镜像
git config --global user.email "xxx@xxx.com"
git config --global user.name "xxx"
cd ~/coderepo
mkdir android
cd android
repo init -u git://aosp.tuna.tsinghua.edu.cn/android/platform/manifest --repo-url=git://aosp.tuna.tsinghua.edu.cn/android/git-repo --mirror
repo sync
这一步的时间会比较漫长,大约需要下载35G的内容,清华的服务器速度还是很快的,我下载时全程平均速度均在1M左右;

4. 建立Android分支增量代码镜像
这一步主要是利用了git的--reference选项,在主干代码的基础上建立分支镜像,下面以android 5.0.2为例
cd ~/coderepo
mkdir android502
cd android502
repo init -u git://aosp.tuna.tsinghua.edu.cn/android/platform/manifest --repo-url=git://aosp.tuna.tsinghua.edu.cn/android/git-repo --reference=/home/dev/coderepo/android -b android-5.0.2_r1 --mirror
repo sync可以看到 在repo init阶段,我增加了--reference=/home/dev/coderepo/android 这个选项,也就是第三步获取到的主干代码位置(你们需要根据自己的实际目录修改),这样可以在repo sync过程中,略过已经存在的项目
这一步的时间相对就很短了,因为只需要下载1.5G左右的数据即可

5.建立I.MX6内核及u-boot代码镜像
cd ~/coderepo
mkdir imx
cd imx
git clone --mirror git://git.freescale.com/imx/linux-2.6-imx.git   #建立内核源码镜像
git clone --mirror git://git.freescale.com/imx/uboot-imx.git       #建立u-boot源码镜像
我这边连接飞思卡尔的服务器很慢,这两步的时间也是比较长,平均速度不超过50K

6. 到此,整个源码镜像服务器就建立完成了,可以看下此时的空间占用情况
dev@HeJia-dev:~/coderepo$ du --max-depth=1 -h
1.1G      ./imx
1.5G      ./android502
35G      ./android
1.8G      ./android443
39G      .
dev@HeJia-dev:~/coderepo$
我这边还建了4.4.3的分支镜像,可以看到通过这个方式可以建立任意Android分支源码镜像,并且不会重复占用磁盘空间

7. 检出代码进行开发
下面的操作就跟飞思卡尔BSP里的Android User's Guide差不多了,只需要将git地址修改为本地服务器地址即可
a. 检出Android 5.0.2源码
cd ~
mkdir myandroid
cd myandroid
repo init -u git://127.0.0.1/android502/platform/manifest --repo-url=git://127.0.0.1/android502/git-repo -b android-5.0.2_r1
repo syncb. 检出内核代码

cd ~/myandroid
git clone git://127.0.0.1/imx/linux-2.6-imx.git kernel_imx
cd kernel_imx
git checkout l5.0.0_1.0.0-gac. 检出u-boot代码
cd ~/myandroid/bootable/bootloader
git clone git://127.0.0.1/imx/uboot-imx.git uboot-imx
cd uboot-imx
git checkout l5.0.0_1.0.0-ga8. 以上是在本机上测试,局域网内其它机器只需要替换IP地址即可。
    (完)

lkm_unication 发表于 2015-8-21 13:43:45

mark一下,i.mx6开发教程-搭建Android源码内网镜像服务器, 感谢LZ的分享{:handshake:}

codefish 发表于 2015-8-21 14:04:42

感谢分享。。。

my二月兰 发表于 2015-8-21 20:17:29

正愁怎么下载呢,非常感谢哦{:lol:}

hmsfeng 发表于 2015-8-21 21:45:00

确实不错,有这方法方便多了,感谢

my二月兰 发表于 2015-8-22 06:25:34

你好,如果直接从清华服务器上下载源码的命令是什么样的,为什么我的会一直报错,下载不下来,还有我好想无法安装那个repo,求大师指点,谢谢

my二月兰 发表于 2015-8-22 07:25:46

我下载的过程中老是报错,fatal:unable to connect to aosp..tuna.tsinghua.edu.cn:
                                 aosp.tuna.tsinghua.edu.cn:errno=???
报这样的错误影响下载吗,我现在是让他断线后,自动重复下载的,不需要手动重复 再敲入repo sync

dreampet 发表于 2015-8-22 10:59:16

my二月兰 发表于 2015-8-22 07:25
我下载的过程中老是报错,fatal:unable to connect to aosp..tuna.tsinghua.edu.cn:
                     ...

应该是你的网络连接不稳定,清华大学的服务器是在教育网内,或者是你的并发连接超过4,清华的网站只允许4并发。
可以用下面的脚本保存成.sh格式,运行后出错就会自动自动重试。
#!/bin/bash
echo “======= start repo sync =======”
repo sync -j4
while [ $? == 1 ]; do
echo “====== sync failed! re-sync again =====”
sleep 3
repo sync -j4
done

my二月兰 发表于 2015-8-22 11:44:22

dreampet 发表于 2015-8-22 10:59
应该是你的网络连接不稳定,清华大学的服务器是在教育网内,或者是你的并发连接超过4,清华的网站只允许4 ...

我用的是移动宽带,是不是不稳定啊?

my二月兰 发表于 2015-8-22 11:51:04

还有一个问题,就是/etc/hosts下添加东西吗?

我是一个大白菜 发表于 2018-8-8 14:47:33

大哥,为什么我下载后居然有106G,而且我要把下载链接的地方git换成https才可以下载的

jordonwu 发表于 2020-4-15 07:19:26

Mark.         

Junp2098 发表于 2020-7-27 21:49:17

mark,顶一顶

dam 发表于 2020-7-28 06:52:12


mark,顶一顶
页: [1]
查看完整版本: i.mx6开发教程-搭建Android源码内网镜像服务器