rendered paste body#!/bin/bashfail() { echo "Failed" echo "$1" exec /bin/sh}function help() {cat <<EOFInvoke "build" from your shell to use the following functions:- mkroot: Makes a rootfs.- kernel27: Makes a 2.6.27 Linux kernel.- kernel35: Makes a 2.6.35 Linux kernel.- mkbundle: Makes a initrd,a rootfs and a 2.6.27 Linux kernel.- git_push_all: Commits and pushes from 2.6.27,Rootfs,Initrd source.- sync_all: Syncs all the sources.- build_cm6: Builds CyanogenMod 6.- build_cm7: Builds CyanogenMod 7.- build_custom: Builds a user-choosen build.- makeinitrd: Makes an initramfs.If you launch this script without any option will show the menuEOF}clean() { export LOG=$SOURCE_PATH/build.log cd $SOURCE_PATH echo "***Cleaning at {`date +%H:%M:%S`}" make clobber -j`cat /proc/cpuinfo | grep "^processor" | wc -l` >> $LOG 2>&1 make clean -j6 >> $LOG 2>&1 echo "***Finished cleaning at {`date +%H:%M:%S`}";}ics() { sudo swapon -U ecc31705-86f8-4424-9c8e-9dd02ccfe5f4 sudo swapon -U 2c054a7d-de4a-4478-a9e9-56b9456b86d3 echo "***Swap is on" export SOURCE_PATH=~/ICS export LOG=$SOURCE_PATH/build.log export OUTPUT_PATH=/media/HD2/out/ics export DEVICE_OUT_PATH=$SOURCE_PATH/out/target/product/maguro touch $LOG cd $SOURCE_PATH clean source build/envsetup.sh lunch full_maguro-eng schedtool -B -n 1 -e ionice -n 1 make -j6 >> $LOG 2>&1 [ $? -eq 0 ] || fail "***Failed to make the build" mkdir -p $OUTPUT_PATH mv -f $DEVICE_OUT_PATH/* $OUTPUT_PATH/ echo "***Cleaning so you have a bit of space" make clobber}xdandroid() { cd ~/xdandroid echo "Cleaning" #make clean -j6 >> xdandroid.log 2>&1 echo "Building" make otapackage -j6 >> xdandroid.log 2>&1 }boot() {echo "******************************************************You've choosen to make a boot image******************************************************" LOG=$SOURCE_PATH/recovery.log OUTPUT_PATH=$OUTPUT_PATH/boot/`date +%m%d-%H:%M`/ rm -f $LOG touch $LOG echo "***Choosing device at {`date +%H:%M:%S`}" echo " Running envsetup " >> $LOG 2>&1 . build/envsetup.sh >> $LOG 2>&1 $choice $device >> $LOG 2>&1 echo "Making recovery" >> $LOG 2>&1 echo "***Starting make at {`date +%H:%M:%S`}" make bootimage -j6 echo "***Make completed at {`date +%H:%M:%S`}" mkdir -p $DEVICE_OUT_PATH mv -f $DEVICE_OUT_PATH/recovery.img $OUTPUT_PATH mv -f $DEVICE_OUT_PATH/boot.img $OUTPUT_PATH}cm6_setup() { echo "Choosing cm6" export SOURCE_PATH=~/cm6 export device=full_kovsky-eng export DEVICE_OUT_PATH=$SOURCE_PATH/out/target/product/kovsky export TOOLCHAIN=$SOURCE_PATH/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- export OUTPUT_PATH=~/out/cm6 export MANIFEST="git://github.com/CyanogenMod/android.git -b froyo-stable" export choice=lunch export ANDROID_PREBUILT_ARMEABI=$SOURCE_PATH/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/ export PATH=$PATH:$JAVA_HOME/bin:$ANDROID_SDK_TOOLS:$ANDROID_PREBUILT_ARMEABI}build() { echo "******************************************************You've choosen to make a full build******************************************************" if grep -q /dev/sda5 /proc/mounts ; then echo "Swap already mounted" else sudo echo "Your password please" sudo swapon -U ecc31705-86f8-4424-9c8e-9dd02ccfe5f4 fi export LOG=$SOURCE_PATH/build.log OUTPUT_PATH=$OUTPUT_PATH/build/`date +%m%d-%H:%M`/ rm -f $LOG touch $LOG clean cd $SOURCE_PATH echo "***Choosing device at {`date +%H:%M:%S`}" echo " Running envsetup " >> $LOG 2>&1 . build/envsetup.sh >> $LOG 2>&1 $choice $device >> $LOG 2>&1 echo "Making build" >> $LOG 2>&1 echo "***Starting make at {`date +%H:%M:%S`}" mka bacon >> $LOG 2>&1 [ $? -eq 0 ] || fail "***Failed to make the build" echo "***Make completed at {`date +%H:%M:%S`}" mkdir -p $OUTPUT_PATH && mkdir -p $OUTPUT_PATH/img cd $DEVICE_OUT_PATH system=$(find -name "*.img" -size +3M) for i in $system ; do mv -f $i $OUTPUT_PATH/img/ >> $LOG 2>&1 done cd $SOURCE_PATH mv -f $DEVICE_OUT_PATH/*.zip $OUTPUT_PATH echo "Completed,choose what to do.." echo "**********************************************1}Nothing2}Copy the zip in the htc kitchen folder and launch the kitchen3}Copy the zip in the shared folder with windows**********************************************" read _opt if [ "$_opt" = "1" -o "$_opt" = "" ]; then echo "***Done" elif [ "$_opt" = "2" ]; then echo "***Copying" cp -f $OUTPUT_PATH/img/*.img ~/kitchen/original_update/ cp -f $OUTPUT_PATH/*.zip ~/kitchen/original_update/ kitchen elif [ "$_opt" = "3" ]; then echo "***Mounting" mountvm cp -f $OUTPUT_PATH/*.zip ~/files else echo "Bad choice" fi cd ~; }mountvm() { echo "Passowrd please" sudo echo "Thank you" sudo mount -t vboxsf NAND ~/files}kitchen() { echo "Starting" cd ~/kitchen . menu}build_noclean() { echo "******************************************************You've choosen to make a full build without cleaning******************************************************" if grep -q /dev/sda5 /proc/mounts; then echo "Swap already mounted" else sudo echo "Your password please" sudo swapon -U ecc31705-86f8-4424-9c8e-9dd02ccfe5f4 fi LOG=$SOURCE_PATH/build.log OUTPUT_PATH=$OUTPUT_PATH/build/`date +%m%d-%H:%M`/ rm -f $LOG touch $LOG cd $SOURCE_PATH echo "***Choosing device at {`date +%H:%M:%S`}" echo " Running envsetup " >> $LOG 2>&1 . build/envsetup.sh >> $LOG 2>&1 $choice $device >> $LOG 2>&1 echo "Making build" >> $LOG 2>&1 echo "***Starting make at {`date +%H:%M:%S`}" mka bacon >> $LOG 2>&1 [ $? -eq 0 ] || fail "***Failed to make the build" echo "***Make completed at {`date +%H:%M:%S`}" mkdir -p $OUTPUT_PATH && mkdir -p $OUTPUT_PATH/img system=$(find -name "*.img" -size +3M) for i in $system ; do mv -f $i $OUTPUT_PATH/img/ >> $LOG 2>&1 done mv -f $DEVICE_OUT_PATH/*zip $OUTPUT_PATH/ echo "Completed,choose what to do.." echo "**********************************************1}Nothing2}Copy the zip in the htc kitchen folder and launch the kitchen3}Copy the zip in the shared folder with windows**********************************************" read _opt if [ "$_opt" = "1" -o "$_opt" = "" ]; then echo "***Done" elif [ "$_opt" = "2" ]; then echo "***Copying" cp -f $OUTPUT_PATH/img/*.img ~/kitchen/original_update/ cp -f $OUTPUT_PATH/*.zip ~/kitchen/original_update/ kitchen elif [ "$_opt" = "3" ]; then echo "***Mounting" mountvm cp -f $OUTPUT_PATH/*.zip ~/files else echo "Bad choice" fi cd ~ } reposync() { cd $SOURCE_PATH export PATH=~/bin:$PATH schedtool -B -n 1 -e ionice -n 1 repo sync -j16}reposync_ics() { cd ~/ICS export PATH=~/bin:$PATH schedtool -B -n 1 -e ionice -n 1 repo sync -j16}cm7_setup() { echo "Choosing cm7" export SOURCE_PATH=~/cm7 export device=cyanogen_kovsky-eng export DEVICE_OUT_PATH=$SOURCE_PATH/out/target/product/kovsky export TOOLCHAIN=$SOURCE_PATH/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- export OUTPUT_PATH=~/out/cm7 export MANIFEST="git://github.com/CyanogenMod/android.git -b gingerbread" export choice=brunch export ANDROID_PREBUILT_ARMEABI=$SOURCE_PATH/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/ export PATH=$PATH:$JAVA_HOME/bin:$ANDROID_SDK_TOOLS:$ANDROID_PREBUILT_ARMEABI}editinfo() { VAR=~/variables.var if [ -e $VAR ]; then . $VAR else echo "You've choosen to change the standard paths." echo "Where's the source?" read SOURCE_PATH echo "What's the manifest?" read MANIFEST echo "What's the device?" read device echo "Where's Java located?" read JAVA_HOME echo "Where's the android SDK?" read ANDROID_SDK_TOOLS echo "What's used to choose the device,lunch,brunch or breakfast?" read choice export ANDROID_PREBUILT_ARMEABI=$SOURCE_PATH/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/ export PATH=$PATH:$JAVA_HOME/bin:$ANDROID_SDK_TOOLS:$ANDROID_PREBUILT_ARMEABI touch $VAR echo SOURCE_PATH=$SOURCE_PATH >> $VAR echo MANIFEST=$MANIFEST >> $VAR echo device=$device >> $VAR echo JAVA_HOME=$JAVA_HOME >> $VAR echo ANDROID_SDK_TOOLS=$ANDROID_SDK_TOOLS >> $VAR echo choice=$choice >> $VAR fi clear echo "Please check if the paths are set correctly." echo "******************************************************************}Environment:}Source is in $SOURCE_PATH}Manifest to be used is $MANIFEST}You're building for $device}Java is $JAVA_HOME}The SDK is in $ANDROID_SDK_TOOLS************************************************************************" echo "Are them set correctly?" read correct if [ "$correct" = "yes" -o "$correct" = "" ]; then clear echo "Let's go to the next step" init2 fi if [ "$correct" = "no" ]; then clear echo "Type 'em again" rm -f $VAR showinfo2 fi}kernel27() {echo "******************************************************You've choosen to make a 2.6.27 kernel******************************************************" export KPATH=/home/domenico/kernel if [ ! -d $KPATH ]; then echo "Where's the source?" read KPATH echo "Make sure that is the right path and that the source is in linux-msm folder" fi cd $KPATH echo "***Making .27 at {`date +%H:%M:%S`}" exec ./build.sh}kernel35() {echo "******************************************************You've choosen to make a 2.6.35 kernel******************************************************" export KPATH=/home/domenico/alex export KKPATH=$KPATH/alex-linux-xperia if [ ! -d $KPATH ]; then echo "Where's the source?" read KPATH fi cd $KKPATH echo "***Downloading changes from source at {`date +%H:%M:%S`}" schedtool -B -n 1 -e ionice -n 1 git pull cd $KPATH echo "***Making .27 at {`date +%H:%M:%S`}" exec ./build.sh}recovery() {echo "******************************************************You've choosen to make a recovery******************************************************" LOG=$SOURCE_PATH/recovery.log OUTPUT_PATH=$OUTPUT_PATH/recovery/`date +%m%d-%H:%M`/ rm -f $LOG touch $LOG echo "***Choosing device at {`date +%H:%M:%S`}" echo " Running envsetup " >> $LOG 2>&1 . build/envsetup.sh >> $LOG 2>&1 $choice $device >> $LOG 2>&1 echo "Making recovery" >> $LOG 2>&1 echo "***Starting make at {`date +%H:%M:%S`}" schedtool -B -n 1 -e ionice -n 1 make recoveryimage -j`cat /proc/cpuinfo | grep "^processor" | wc -l` >> $LOG 2>&1 || fail "***Build failed"; echo "***Make completed at {`date +%H:%M:%S`}" mkdir -p $DEVICE_OUT_PATH mv -f $DEVICE_OUT_PATH/recovery.img $OUTPUT_PATH mv -f $DEVICE_OUT_PATH/boot.img $OUTPUT_PATH}first() {LOG=$SOURCE_PATH/first.log touch $LOG echo "******************************************************You've choosen to prepare your environmentfor first build******************************************************" clear echo "Are you running Ubuntu or a Debian based Distro? (yes,no)" echo "Distro such as Linux Mint or Kubuntu are Debian based distro" read _distro if [ "$_distro" = "yes" ]; then clear echo "You'll be prompted to write your system password" sudo echo "Thank you" sudo add-apt-repository "deb http://archive.canonical.com/ maverick partner" sudo apt-get update >> $LOG 2>&1 sudo apt-get install -y git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.6-dev squashfs-tools build-essential zip curl libncurses5-dev >> $LOG 2>&1 sudo apt-get install -y pngcrush g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline5-dev zlib1g-dev sun-java6-jdk >> $LOG 2>&1 if [ ! -d ~/bin ]; then mkdir -p ~/bin fi if [ ! -f ~/bin/repo ]; then curl "http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo" > ~/bin/repo >> $LOG 2>&1 chmod a+x ~/bin/repo fi PATH=~/bin:$PATH if [ ! -d $SOURCE_PATH ]; then mkdir -p $SOURCE_PATH fi cd $SOURCE_PATH export PATH=~/bin:$PATH repo init -u $MANIFEST echo "******************************************************Going to sync,this may take a while******************************************************" schedtool -B -n 1 -e ionice -n 1 repo sync -j 10 cd $SOURCE_PATH/vendor/cyanogen ./get-rommanager >> $LOG 2>&1 cd ../../.. schedtool -B -n 1 -e ionice -n 1 make update-api -j`cat /proc/cpuinfo | grep "^processor" | wc -l` >> $LOG 2>&1 || echo "***Build failed"; exit echo "Now we're going to extract proprietary files for your $device" echo "Place `$device`_update.zip in $SOURCE_PATH" echo "Please don't put the '' in the name of the file.." echo "******************************************************" echo "What's your device manufacturer?" read manufacturer man=`echo $manufacturer | sed -e 's/ /_/g'` echo "Manufacturer is $man" cd $SOURCE_PATH/device/$man/$device . unzip-files.sh >> $LOG 2>&1fi if [ "$_distro" = "no" ]; then clear echo "You must install manually the following packages:{ git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.6-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev sun-java6-jdk pngcrush g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline5-dev gcc-4.3-multilib g++-4.3-multilib }******************************************************This script will now end******************************************************" fi}showinfo() {echo "******************************************************************}Environment:}Source is in $SOURCE_PATH}Manifest to be used is $MANIFEST}You're building for $device}Java is $JAVA_HOME************************************************************************"}extra() { echo "**********************************************1}Mount vmware shared partition2}Start htc kitchen**********************************************" read _opt if [ "$_opt" = "1" -o "$_opt" = "" ]; then mountvm fi if [ "$_opt" = "2" ]; then kitchen fi} init() {echo "**********************************************1}CyanogenMod6 Setup 2}CyanogenMod7 setup3}Make a 2.6.35 Kernel 4}Make a 2.6.27 Kernel5}Specify manually paths6}Extra functions7}Exit **********************************************"read _optif [ "$_opt" = "1" -o "$_opt" = "" ]; then cm6_setup echo "***Choose what to build now" init2elif [ "$_opt" = "2" ]; then cm7_setup echo "****Choose what to build now" init2elif [ "$_opt" = "3" ]; then kernel35 echo "***Done"elif [ "$_opt" = "4" ]; then kernel27 echo "***Done"elif [ "$_opt" = "5" ]; then editinfo echo "Choose what to build now" init2elif [ "$_opt" = "7" ]; then echo "****Bye" exitelif [ "$_opt" = "6" ]; then echo "***Extra functions" extra else clear echo "Bad Option" initfi}makeinitrd() { cd ~/system/new if [ -e "initrd.gz" ] && [ -e "../initrd.gz" ]; then rm -rf initrd.gz rm -rf ../initrd.gz fi find . | cpio -o -H newc | gzip -9 > initrd.gz}makerootfs() { cd ~/rootfs-midnight/scripts . generate-rootfs.sh}mkbundle() { if [ ! -d ~/out/bundle/`date +%H:%M:%S` ]; then mkdir -p ~/out/bundle/`date +%H:%M:%S` OPATH=~/out/bundle/`date +%H:%M:%S` fi makeinitrd cd ~ cp -f /system/new/initrd.gz $OPATH makerootfs cp -f ~/rootfs-output/rootfs-`date +%Y%m%d`.ext3 $OPATH/rootfs.ext3 kernel27}init2() {echo "**********************************************1}Make a build without cleaning 2}Make a build cleaning 3}Make a recovery image 4}Make a boot image 5}Sync with the repo 6}Run first setup7}Clean8}Exit the script **********************************************"read _optif [ "$_opt" = "2" ]; then buildelif [ "$_opt" = "1" -o "$_opt" = "" ]; then build_nocleanelif [ "$_opt" = "6" ]; then first echo "***Done"elif [ "$_opt" = "4" ]; then boot echo "***Done"elif [ "$_opt" = "3" ]; then recovery echo "***Done"elif [ "$_opt" = "5" ]; then reposync echo "***Done" init2elif [ "$_opt" = "7" ]; then clean init2elif [ "$_opt" = "8" ]; then echo "****Bye" exit else clear echo "Bad Option" init2fi;}if [ "$1" = "makeinitrd" ]; then makeinitrdelif [ "$1" = "build_cm6" ]; then cm6_setup buildelif [ "$1" = "sync_all" ]; then cm6_setup reposync echo "***CyanogenMod6 synced" cm7_setup reposync echo "***CyanogenMod7 synced" cd ~/ICS reposync_ics echo "***Ice Cream Sandwich synced" cd ~/kernel/linux-msm schedtool -B -n 1 -e ionice -n 1 git pull echo "***2.6.27 synced" cd ~/alex/alex-linux-xperia schedtool -B -n 1 -e ionice -n 1 git pull echo "***2.6.35 synced" echo "***Done"elif [ "$1" = "build_cm7" ]; then cm7_setup buildelif [ "$1" = "build_custom" ]; then editinfo elif [ "$1" = "kernel35" ]; then kernel35elif [ "$1" = "kernel27" ]; then kernel27elif [ "$1" = "mkroot" ]; then makerootfselif [ "$1" = "ics" ]; then icselif [ "$1" = "git_push_all" ]; then cd ~/rootfs-midnight git commit -a git push cd ~/system/new git commit -a git push cd ~/kernel/linux-msm git commit -a git pushelif [ "$1" = "mkbundle" ]; then mkbundleelif [ "$1" = "help" ]; then helpelif [ "$1" = "xdandroid" ]; then xdandroidelse initfi