Script to Build Android Kernel Under Ubuntu

#!/bin/bash
#
ANDROID=”android-4.1.1_r6.1″
GCC=4.4.3

KERNEL=goldfish
KCONFIG=goldfish_armv7_defconfig

#GIT_SERVER=aosp.zhenglei.net
GIT_SERVER=127.0.0.1
GIT_PATH=”git/aosp”

PREBUILT=prebuilt
HOST=”linux-x86″
ARCH=”arm”
BUILD_PATH=”build”

function get_Tool {
LOC=”$1″
TAG=”$2″
VER=”$3″
TOOL_CHAIN=${ARCH}-eabi-${GCC}

if [ ! -d ${LOC}/${TOOL_CHAIN} ];then
if [ ! -d ${PREBUILT}/${TOOL_PATH} ];then
if [ -d ${PREBUILT} ];then
rm -rf ${PREBUILT}
fi
git clone git://${GIT_SERVER}/${GIT_PATH}/platform/prebuilt
fi

cd ${PREBUILT}
CUR_BRANCH=`git branch|grep “^* “|sed “s/^* //”`
if [ “${CUR_BRANCH}” != “${TAG}” ];then
#    git tag -l
git checkout -b ${TAG}
fi
cd ..

cp -r ${PREBUILT}/${HOST}/toolchain/${TOOL_CHAIN} ${LOC}

fi
TOOL_PATH=”`pwd`/${LOC}/${TOOL_CHAIN}”
}

function get_Kernel {
kernel=”$1″
if [ ! -d ${kernel} ];then
git clone git://${GIT_SERVER}/${GIT_PATH}/kernel/${kernel}.git
fi

cd ${kernel}
# git branch -a
CUR_BRANCH=`git branch|grep “^* “|sed “s/^* //”`
if [ “${CUR_BRANCH}” != “${kernel}” ];then
git checkout -t remotes/origin/android-${kernel}-2.6.29 -b ${kernel}
fi
if [ ! -d ../${BUILD_PATH}/${kernel} ];then
mkdir ../${BUILD_PATH}/${kernel}
git archive –format tar HEAD|tar x -C ../${BUILD_PATH}/${kernel}/
fi
cd ..
}

function build_Kernel {
config=$1
cd ${BUILD_PATH}/${kernel}
#ls -l arch/${ARCH}/configs/
make ${config}

START=`date +%s`
echo “Start to build at time:  $START”
echo “################################”
echo
echo

make -j4

echo
echo
echo “################################”
FINISH=`date +%s`
echo “Finish build at time: $FINISH”
echo
ELAPSED=`expr $FINISH – $START`
echo “Elapsed time: $ELAPSED”
cd ..
cd ..
}

##### Main ######
if [ ! -d ${BUILD_PATH} ];then
mkdir ${BUILD_PATH}
fi

rm -rf ${BUILD_PATH}/*

get_Tool $BUILD_PATH $ANDROID $GCC

export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=arm-eabi-
export PATH=${TOOL_PATH}/bin:$PATH

get_Kernel $KERNEL

build_Kernel $KCONFIG

# Output

cp ${BUILD_PATH}/${KERNEL}/arch/${ARCH}/boot/zImage ${BUILD_PATH}/${KERNEL}/

# Luanch emulator with build kernel
# emulator -kernel ${KERNEL}/zImage

Mirror of Google Android Repository on Ubuntu 10.10

###########################################
# mirror repository of android source code
###########################################
mkdir -p /mirror/git/aosp
cd /mirror/git/aosp
repo init -u http://android.gogolesource.com/mirror/manifest.git –mirror
repo sync -j18
sudo chown -R gitdaemon .

#####################################
# Install Git Daemon on own server (repo.zhenglei.net)
#####################################
sudo apt-get install git-daemon-run

#####################################
# Update Config of Git Daemon
#####################################
cat /etc/sv/git-daemon/run
#!/bin/sh
GIT_DAEMON_CONF=”/etc/git-daemon.conf”
if [ -f ${GIT_DAEMON_CONF} ];then
GIT_DAEMON=`cat ${GIT_DAEMON_CONF}`
else
GIT_DAEMON=””
fi
exec 2>&1
echo ‘git-daemon starting.’
exec chpst -ugitdaemon \
“$(git –exec-path)”/git-daemon –verbose  –export-all –reuseaddr  “${GIT_DAEMON}” –base-path=/mirror /mirror/git

#####################################
# Restart Git Daemon
#####################################
sv stop git-daemon
sv start git-daemon

################################################
# Access REPO mirror
################################################

## Clone Whole aosp
mkdir -p /build/android
cd /build/android
repo init -u git://repo.zhenglei.net/aosp/mirror/manifest.git –mirror
repo sync -j18

## Clone Platform only
repo init -u git://repo.zhenglei.net/aosp/platform/manifest.git –mirror
repo sync -j18

## Clone accessories only
repo init -u git://repo.zhenglei.net/aosp/accessories/manifest.git –mirror
repo sync -j18

## Clone Kernel only
git  clone –mirror  git://repo.zhenglei.net/aosp/kernel/common.git
git  clone –mirror  git://repo.zhenglei.net/aosp/kernel/exynos.git
git  clone –mirror  git://repo.zhenglei.net/aosp/kernel/goldfish.git
git  clone –mirror  git://repo.zhenglei.net/aosp/kernel/msm.git
git  clone –mirror  git://repo.zhenglei.net/aosp/kernel/omap.git
git  clone –mirror  git://repo.zhenglei.net/aosp/kernel/samsung.git
git  clone –mirror  git://repo.zhenglei.net/aosp/kernel/tegra.git

 

#Clone Device

git  clone –mirror  git://repo.zhenglei.net/aosp/device/generic/goldfish.git

git  clone –mirror  git://repo.zhenglei.net/aosp/device/samsung/tuna.git

#### Checkout Branching ####

repo init -u git://repo.zhenglei.net/aosp/platform/manifest.git -b  android-4.1.1_r6.1
repo sync -j 18

## Create New Branching in local ##
repo start android-4.1.1_r6.1_jrd_dev –all

## Push New Branching to the server ##
sudo sv stop git-daemon
export GIT_DAEMON=”–enable=receive-pack”
sudo sv start git-daemon
repo forall -c git push aosp android-4.1.1_r6.1_jrd_dev
sudo sv stop git-daemon
export GIT_DAEMON=
sudo sv start git-daemon

 

 

 

 

Update git on Ubuntu 10.10 for aosp access

Now, it is  required to have git version 1.7.2 to access Google android repository,  need to update git version on ubuntu 10.10 manually:

sudo apt-get clean

sudo apt-get update

sudo apt-get install libcurl4-gnutls-dev

wget http://github.com/git/git/archive/v1.7.2.5.zip

unzip v1.7.2.5.zip

cd git-1.7.2.5

make configure

./configure –prefix=/usr

make all

sudo make install

 

 

 

Economic VPS

Due to the security issue of micolog on Gogle App Engine,  I have to move the blog to VPS with WordPress.

ComfortHost low end vps is most suitable for my case, compare with several VPS I used before:

yardvps, ==> one year more, xen based, price hither

bluevm vps ==> unable to support L2TP vps

Good technology & support , reasonable cost, support OpenVPN/PPTP/L2PE on my 128M openVZ vps.(blog.zhenglei.net, UK)

Just purchase 11$/year 256M VPS (US IP) to try IP SEC on it.

http://www.comforthost.net/billing/cart.php?a=confproduct&i=0

Following:

http://www.lowendbox.com/blog/spotvps-10-99year-256mb-openvz-vps-in-4-us-locations/