标签 android 下的文章

经常要从CM7源代码构建ROM,于是以Atrix4G为例写了这个脚本,实现自动编译新版CM7。
当然,脚本可能还有一些不完善的地方,欢迎大家提出来。

#!/bin/sh
#
# 编译环境 Ubuntu Desktop 11.10
# 参考文献 http://www.anrip.com/post/261
# http://developer.android.com/sdk/installing.html
# http://source.android.com/source/initializing.html
# http://wiki.cyanogenmod.com/wiki/Motorola_Droid:_Compile_CyanogenMod_%28Linux%29
#

sudo su -
ulimit -S -n 1024

# 设定工作目录
export WORK=/media/workspace
export PATH=$PATH:$WORK/bin
mkdir -p $WORK/CyanogenMod
mkdir -p $WORK/bin

# 安装必要的软件包
apt-get install git-core zip curl gnupg flex bison \
  gperf pngcrush schedtool build-essential squashfs-tools \
  libsdl1.2-dev libesd0-dev libwxgtk2.6-dev libncurses5-dev zlib1g-dev

# 安装其他软件包
if [ $(getconf LONG_BIT) == 64 ]; then
  apt-get install lib32z1-dev lib32ncurses5-dev lib32readline5-dev g++-multilib
fi

# 安装java-sdk
apt-get install openjdk-6-jdk

# 安装android-sdk
cd $WORK/
wget http://dl.google.com/android/android-sdk_r14-linux.tgz
tar xvf android-sdk_r14-linux.tgz && rm android-sdk_r14-linux.tgz

# 手动选择并安装platform-tools
$WORK/android-sdk-linux/tools/android
export PATH=$PATH:$WORK/android-sdk-linux/platform-tools

# 安装repo工具
cd $WORK/bin/
wget https://dl-ssl.google.com/dl/googlesource/git-repo/repo
chmod 0755 repo

# 同步CM7源码
cd $WORK/source/
repo init -u git://github.com/source/android.git -b gingerbread
repo sync -j16

# 把编译选项-m64改成-m32
cd $WORK/source/external/clearsilver/
if [ $(getconf LONG_BIT) == 32 ]; then
  sed -i "s/-m64/-m32/g" cgi/Android.mk
  sed -i "s/-m64/-m32/g" cs/Android.mk
  sed -i "s/-m64/-m32/g" java-jni/Android.mk
  sed -i "s/-m64/-m32/g" util/Android.mk
fi

# 获取设备专属文件(需调试模式连接手机)
cd $WORK/source/device/motorola/olympus/
./extract-files.sh

# 下载Rom管理器
cd $WORK/source/vendor/cyanogen/
./get-rommanager

# 编译CM7源码
cd $WORK/source/
source build/envsetup.sh
brunch olympus