Advertisement
playfulgod

shabby's new kernel build script

Feb 11th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3.     # This is my usage information
  4.     [ $# -eq 0 ] && { echo "Usage:
  5.      $0 Kernel-name [Stock,CM,CM101]"; exit 1; }
  6.  
  7.     # This says if its a kernel compiled using *MY* defconfig :)
  8.     # You may as well remove this
  9.     #if [ $3 == "shabby" ];
  10.     #then
  11.         #DEFCONFIG=Shabbypenguin_d2-r530_defconfig
  12.     #else
  13.     #DEFCONFIG=cyanogen_d2-r530_defconfig
  14.     #fi
  15.  
  16.     # These setup our build enviroment
  17.     THREADS=$(expr 4 + $(grep processor /proc/cpuinfo | wc -l))
  18.     MAKE="make -j${THREADS}"
  19.     ARCH="ARCH=arm"
  20.     CROSS="CROSS_COMPILE=/home/shabbypenguin/android/CM10/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-"
  21.  
  22.     # Setup our directories now
  23.     DIR=~/android/Kernels
  24.     TOOLS=$DIR/tools
  25.     KERNEL=$DIR/SGH-Krait
  26.     PACK=$KERNEL/package
  27.     OUT=$KERNEL/arch/arm/boot
  28.  
  29.     # These are extra variables designed to make things easier
  30.     UPDATER=$TOOLS/Updater-Scripts/d2
  31.     MODULES=$UPDATER/system/lib/modules
  32.     KERNELNAME=$1
  33.     KBUILD_BUILD_VERSION=$1
  34.     export KBUILD_BUILD_VERSION
  35.  
  36.     # Set our Ramdisk locations
  37.     STOCK=$DIR/Ramdisks/d2mtr
  38.     CM=$DIR/Ramdisks/d2mtr-CM
  39.     CM101=$DIR/Ramdisks/d2mtr-CM10-1
  40.  
  41.     # These are for mkbootimg
  42.     PAGE=2048
  43.     BASE=0x80200000
  44.     RAMADDR=0x81500000
  45.     CMDLINE='"androidboot.hardware=qcom user_debug=31 zcache"'
  46.  
  47.     # -----------------------------------------------------------------------------------------------
  48.     # Dont mess with below here unless you know what you are doing
  49.     # -----------------------------------------------------------------------------------------------
  50.  
  51.     export USE_CCACHE=1
  52.     export $ARCH
  53.     export $CROSS
  54.  
  55.     # This cleans out crud and makes new config
  56.     #$MAKE clean
  57.     #$MAKE mrproper
  58.     rm -rf $MODULES
  59.     rm -rf $PACK
  60.     [ -d "$PACK" ] || mkdir "$PACK"
  61.     [ -d "$MODULES" ] || mkdir -p "$MODULES"
  62.     exec > >(tee $PACK/buildlog.txt) 2>&1
  63.     $MAKE $DEFCONFIG
  64.  
  65.     # Finally making the kernel
  66.     #$MAKE zImage
  67.     #$MAKE modules
  68.  
  69.     # These move files to easier locations
  70.     find -name '*.ko' -exec cp -av {} $MODULES/ \;
  71.  
  72.     # -----------------------------------------------------------------------------------------------
  73.     # This part packs the img up :)
  74.     # In order for this part to work you need the mkbootimg tools
  75.     # -----------------------------------------------------------------------------------------------
  76.  
  77.     # This will base ramdisks location off $2
  78.     if [ $2 == "Stock" ];
  79.     then
  80.         RAMDISK=$STOCK
  81.     else
  82.         if [ $2 == "CM" ];
  83.         then
  84.             RAMDISK=$CM
  85.             else
  86.             if [ $2 == "CM101" ];
  87.             then
  88.                 RAMDISK=$CM101
  89.             fi
  90.         fi
  91.     fi
  92.  
  93.     cd $PACK
  94.     cp $OUT/zImage $PACK
  95.     $TOOLS/mkbootfs $RAMDISK | gzip > $PACK/ramdisk.gz
  96.     $TOOLS/mkbootimg --cmdline "$CMDLINE" --kernel $PACK/zImage --ramdisk $PACK/ramdisk.gz --pagesize $PAGE --base $BASE --ramdiskaddr $RAMADDR -o $PACK/boot.img
  97.     rm -rf ramdisk.gz
  98.     rm -rf zImage    
  99.     cp -R $UPDATER/* $PACK
  100.     zip -r $KERNELNAME"-"$2".zip" * -x "*.txt"
  101.     # -----------------------------------------------------------------------------------------------
  102.     # All Done
  103.     echo $KERNELNAME"-"$2 "was made!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement