从供应商那里拿到的rk3128android 4.4的源码包。解压前压缩包大概5G,通过命令解压后发现只有一个隐藏的.repo 目录大小4096。
然后执行命令 repo sync -l
意思是从本地工作树跟新代码。
完成 后。所有的代码都已经在服务器端。
在 代码服务器端新建rks这个目录用于存放纯代码库。
进入服务器端的代码库路径 rk/.repo/project-objects
这里面存放的是远程代码库在本地的映射。projects存放的是本地代码库,每次repo sync 时候。都是project-objects的代码库和projects代码库比较。然后更新本地代码, 所以我们远程也要建立相关的代码库。通过命令 find -name “*.git” > src_git.txt
显示所以git代码库:
太多了截取一段显示。
然后将文件 src_git.txt 拷贝到服务器端。
在rk代码库根目录执行work2mirror.py获取mirror的脚本获得本地所以的git代码库
work2mirror.py内容:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os, sys, shutil
cwd = os.path.abspath( os.path.dirname( __file__ ) )
repodir = os.path.join( cwd, '.repo' )
S_repo = 'repo'
TRASHDIR = 'old_work_tree'
if not os.path.exists( os.path.join(repodir, S_repo) ):
print >> sys.stderr, "Must run under repo work_dir root."
sys.exit(1)
sys.path.insert( 0, os.path.join(repodir, S_repo) )
from manifest_xml import XmlManifest
manifest = XmlManifest( repodir )
if manifest.IsMirror:
print >> sys.stderr, "Already mirror, exit."
sys.exit(1)
trash = os.path.join( cwd, TRASHDIR )
for project in manifest.projects:
# 移动旧的版本库路径到镜像模式下新的版本库路径
newgitdir = os.path.join( cwd, '%s.git' % project.name )
if os.path.exists( project.gitdir ) and project.gitdir != newgitdir:
if not os.path.exists( os.path.dirname(newgitdir) ):
os.makedirs( os.path.dirname(newgitdir) )
print "Rename %s to %s." % (project.gitdir, newgitdir)
os.rename( project.gitdir, newgitdir )
# 移动工作区到待删除目录
if project.worktree and os.path.exists( project.worktree ):
newworktree = os.path.join( trash, project.relpath )
if not os.path.exists( os.path.dirname(newworktree) ):
os.makedirs( os.path.dirname(newworktree) )
print "Move old worktree %s to %s." % (project.worktree, newworktree )
os.rename( project.worktree, newworktree )
if os.path.exists ( os.path.join( newgitdir, 'config' ) ):
# 修改版本库的配置
os.chdir( newgitdir )
os.system( "git config core.bare true" )
os.system( "git config remote.korg.fetch '+refs/heads/*:refs/heads/*'" )
# 删除 remotes 分支,因为作为版本库镜像不需要 remote 分支
if os.path.exists ( os.path.join( newgitdir, 'refs', 'remotes' ) ):
print "Delete " + os.path.join( newgitdir, 'refs', 'remotes' )
shutil.rmtree( os.path.join( newgitdir, 'refs', 'remotes' ) )
# 设置 menifest 为镜像
mp = manifest.manifestProject
mp.config.SetString('repo.mirror', 'true')
主要内容是把rk/.repo/projects目录中的代码库根据project-objects映射关系拷贝到相应的目录下。
结果所有的git源码库都放入到devices rk 和 platform 下。
platform内容:
然后在devices rk 和 platform 三个目录拷贝到 home/git/repositories/rks下。
至此 服务器端的代码库已经建好。
在服务器端 home/git/repositories/ 新建 manifest.git 代码库用于存放default.xml。
git init –bare manifest.git
default.xml内容:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote fetch=".." name="rks" />
<remote fetch=".." name="rk" />
<default remote="rks" revision="master" sync-c="true" sync-j="4" />
<project name="rks/device/common" path="device/common"/>
<project name="rks/platform/abi/cpp" path="abi/cpp"/>
<project name="rks/platform/art" path="art"/>
<project name="rks/platform/bionic" path="bionic"/>
<project name="rks/platform/bootable/bootloader/legacy" path="bootable/bootloader/legacy"/>
<project name="rks/platform/bootable/diskinstaller" path="bootable/diskinstaller"/>
<project name="rks/platform/bootable/recovery" path="bootable/recovery"/>
<project name="rks/platform/build" path="build" >
<copyfile dest="Makefile" src="core/root.mk" />
</project>
<project name="rks/platform/cts" path="cts"/>
<project name="rks/platform/dalvik" path="dalvik"/>
<project name="rks/platform/developers/build" path="developers/build"/>
<project name="rks/platform/developers/demos" path="developers/demos"/>
<project name="rks/platform/developers/docs" path="developers/docs"/>
<project name="rks/platform/developers/samples/android" path="developers/samples/android"/>
<project name="rks/platform/development" path="development"/>
<project name="rks/platform/docs/source.android.com" path="docs/source.android.com"/>
<project name="rks/platform/external/aac" path="external/aac"/>
<project name="rks/platform/external/alsa-lib" path="external/alsa-lib"/>
<project name="rks/platform/external/alsa-utils" path="external/alsa-utils"/>
<project name="rks/platform/external/android-clat" path="external/android-clat"/>
<project name="rks/platform/external/android-mock" path="external/android-mock"/>
<project name="rks/platform/external/ant-glob" path="external/ant-glob"/>
<project name="rks/platform/external/antlr" path="external/antlr"/>
<project name="rks/platform/external/apache-harmony" path="external/apache-harmony"/>
<project name="rks/platform/external/apache-http" path="external/apache-http"/>
截取一段显示。主要用于 repo sync 更新本地代码库使用。
在客户端:
git clone [email protected]:manifest.git manifest
把 default.xml 放入 manifest 目录中
git add default.xml
git commit -m”添加 default.xml”
然后 新建测试目录rk_test
repo init -u git://192.168.1.27/manifest.git
repo sync
测试可以正常下载所以代码。并编译通过