2011年2月8日

Construct Android team build repository

Developing an Android based device is not a simple task, and usually need a team to work together. Some members handles kernel drivers and BSP, some for HAL and middle ware, and others for framework and applications. There're some tools to simplify those daily complex jobs, e.g. Apache Marven for project management and Hudson for continues integration. There's a good article to introduce such environment by Kamil: http://novoda.com/2010/08/13/android-continuous-integration-android-maven-plugin/

For a small team, it may too overloaded or you may not want to learn so many tools. So in this article, I'll try to construct a simple and easy to use environment for starters.

1. Install git-daemon
git-daemon is a really simple server for git repositories. It listens to TCP port "DEFAULT_GIT_PORT" aka 9418.

$ sudo apt-get install git-daemon-run

Check if the git service running:
$ grep 9418 /etc/services
git 9418/tcp # Git Version Control System

If you want to stop git-daemon, type:
$ sudo sv stop git-daemon


2. Modify the settings from the script:

$ sudo vi etc/sv/git-daemon/run

#!/bin/sh
exec 2>&1
echo 'git-daemon starting.'
exec chpst -ugitdaemon \
/usr/lib/git-core/git-daemon --verbose --export-all --base-path=/var/cache/git


where --export-all to export all directory under the --base-path /var/cache/git
From network client side, it is a mapping from git://server ip addr/ to /var/cache/git


You can add to a network service, so when the server reboot it will run automatically:
Ubuntu 10.04: cop the file of /sv/git-daemon/run to /etc/init.d 



3. Mirror codes from source.android.com

$ mkdir /var/cache/git/android-mirror/
$ chown git.git /var/cache/git/android-mirror/
$ cd /var/cache/git/android-mirror
$ repo init -u git://android.git.kernel.org/platform/manifest.git --mirror
$ repo sync

You're starting to download the source codes from Google site. This will take several hours depending on the bandwidth.



4. Build your local repository 


$ mkdir /var/cache/git/our-android
$ cd /var/cache/git/our-android
$ repo init -u git://server address/android-mirror/platform/manifest.git --mirror


You need modify the remote server address in .repo/manifest.xml 


$ vi .repo/manifest.xml



<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <remote  name="korg"
           fetch="git://android.git.kernel.org/"


to 



<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <remote  name="korg"
           fetch="git://server address/android-mirror/"


then sync again:

$ repo sync



5. Select a branch, 2.3.1_r1 for example,  for your team development


a) Download android-2.3.1_r1


$ mkdir my-android
$ cd my-android
$ repo init -u git://server address/our-android/platform/manifest.git -b android-2.3.1_r1


This will request you to enter name and email address.
After finishing init, modify the  .repo/manifest.xml


-fetch ="git://android.git.kernel.org/"
+featch="git://server address/our-android/"


then sync the branch codes:
$ repo sync


b) start the branch master for development
$ repo start master-2.3.1_r1 --all


c) set remote repository nick name to my-korg
$repo forall -c 'git remote add mykorg /pub/gittrees/our-android/ $REPO_PROJECT.git $@'


If you want to remote myorg, can be done by: $repo forall -c git remote rm myorg


d) subnit to public repository
$ repo forall -c git push mykorg master-2.3.1_r1:refs/heads/master-2.3.1_r1


May need a "sudo" for access right.


$ repo sync


e) create a manifest branch for the public version


$ cd my-android/.repo/manifests
$ git checkout -b master-2.3.1_r1
$ vi default.xml


modify:



<manifest>   
   <remote name="korg" 
- fetch="git://android.git.kernel.org/" 
+ fetch="git://172.20.158.5/our-repository/" review="review.source.android.com" />   
- <default revision="refs/tags/android-2.1_r2" 
+ <default revision="refs/heads/master-2.1_r2" 
            remote="korg" />

Commit the branch to public repository:

$git commit -a   
$git remote add our-android /pub/gittrees/our-android/platform/manifest.git   
$git push our-android master-2.3.1_r1:refs/heads/master-2.3.1_r1  


The team development repository is done now. It's path is: /pub/gittrees/our-android/

Team member can check out the code by visiting git://your-server-ip/your-repository/platform/manifest.git

$repo init -u git://server address/our-android/platform/manifest.git –b master-2.3.1_r1  



---

沒有留言:

張貼留言