Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 185 lines (166 sloc) 4.863 kB
1f7ea2a @codeworkx tuna: teamhacksung buildscript, cyanogenmod defconfig
codeworkx authored
1 #!/bin/bash
2
3 BOARD=tuna
2675ba8 @KalimochoAz Changed build
KalimochoAz authored
4 DEVICEDIR=/sdcard/AROM
5 KNAME=kernel.cyano.RELEASE
6 DEVICE_CM_DIR=$ANDROID_BUILD_TOP/device/samsung/${BOARD}
7
8 WaitForDevice()
9 {
10 adb start-server
11 if [ $(adb get-state) != device -a $(adb shell busybox test -e /sbin/recovery 2> /dev/null; echo $?) != 0 ] ; then
12 echo "No device is online. Waiting for one..."
13 echo "Please connect USB and/or enable USB debugging"
14 until [ $(adb get-state) = device -o $(adb shell busybox test -e /sbin/recovery 2> /dev/null; echo $?) = 0 ];do
15 sleep 1
16 done
17 echo "Device Found.."
18 fi
19 }
1f7ea2a @codeworkx tuna: teamhacksung buildscript, cyanogenmod defconfig
codeworkx authored
20
21 setup ()
22 {
23 if [ x = "x$ANDROID_BUILD_TOP" ] ; then
24 echo "Android build environment must be configured"
25 exit 1
26 fi
27 . "$ANDROID_BUILD_TOP"/build/envsetup.sh
28
29 KERNEL_DIR="$(dirname "$(readlink -f "$0")")"
30 BUILD_DIR="$KERNEL_DIR/build"
31 # add modules which should be copied after build below
32 MODULES=("")
33
34 if [ x = "x$NO_CCACHE" ] && ccache -V &>/dev/null ; then
35 CCACHE=ccache
36 CCACHE_BASEDIR="$KERNEL_DIR"
37 CCACHE_COMPRESS=1
38 CCACHE_DIR="$BUILD_DIR/.ccache"
39 export CCACHE_DIR CCACHE_COMPRESS CCACHE_BASEDIR
40 else
41 CCACHE=""
42 fi
43
44 CROSS_PREFIX="$ANDROID_BUILD_TOP/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-"
45 }
46
2675ba8 @KalimochoAz Changed build
KalimochoAz authored
47 CheckVersion ()
48 {
49 if [ ! -f .Mayor ]
50 then
51 echo 1 > .Mayor
52 fi
53 if [ ! -f .Minor ]
54 then
55 echo 0 > .Minor
56 fi
57 sVersion=$(cat build/${BOARD}/include/config/kernel.release)
58 echo $sVersion
59 sVersionMerge=${sVersion:(-8)}
60 echo sVersionMerge
61 iMayor=$(cat .Mayor)
62 iMinor=$(cat .Minor)
63 }
64
65 CreateKernelZip ()
66 {
67 cd bin
68 rm *.zip
69 KZIPNAME=$KNAME.v$iMayor.$iMinor.$sVersionMerge.zip
70 zip $KZIPNAME * -r
71 if [ "$responseSend" == "y" ] ; then
72 WaitForDevice
73 echo Going into fastboot
74 if adb reboot-bootloader ; then
75 sleep 4
76 echo Pushing kernel file
77 if fastboot flash zimage kernel/zImage ; then
78 sleep 1
79 fastboot reboot
80 WaitForDevice
81 sleep 2
82 adb root
83 sleep 4
84 adb remount
85 sleep 2
86 echo Sending modules
87 for filename in system/modules/* ; do
88 echo Sending $filename to /system/modules
89 if adb push $filename /system/modules ; then
90 echo "Rebooting again"
91 adb reboot
92 fi
93 done
94 fi
95 fi
96 fi
97 cd ..
98 echo $KZIPNAME
99 }
100
101 UpgradeMinor ()
102 {
103 iMinor=$(($iMinor+1))
104 echo $iMinor > .Minor
105 }
106
107 CompileError ()
108 {
109 echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
110 echo ! COMPILACION FAILED
111 echo !
112 echo !
113 echo ! ---------------------- COMPILACION ERROR CODE: $RET
114 echo !
115 echo !
116 echo !
117 echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
118 }
119
1f7ea2a @codeworkx tuna: teamhacksung buildscript, cyanogenmod defconfig
codeworkx authored
120 build ()
121 {
122 local target=$1
123 echo "Building for $target"
124 local target_dir="$BUILD_DIR/$target"
125 local module
ce89517 @KalimochoAz Build script: do not rebuild
KalimochoAz authored
126 [ x = "x$NO_RM" ]
1f7ea2a @codeworkx tuna: teamhacksung buildscript, cyanogenmod defconfig
codeworkx authored
127 mkdir -p "$target_dir"
dead076 @KalimochoAz Update stand-alone script
KalimochoAz authored
128 [ x = "x$NO_DEFCONFIG" ] && mka -C "$KERNEL_DIR" O="$target_dir" ARCH=arm cyanogenmod_${BOARD}_defconfig HOSTCC="$CCACHE gcc"
1f7ea2a @codeworkx tuna: teamhacksung buildscript, cyanogenmod defconfig
codeworkx authored
129 if [ x = "x$NO_BUILD" ] ; then
2675ba8 @KalimochoAz Changed build
KalimochoAz authored
130 mka -C "$KERNEL_DIR" O="$target_dir" ARCH=arm HOSTCC="$CCACHE gcc" CROSS_COMPILE="$CCACHE $CROSS_PREFIX" modules
131 RET=$?
132 if [[ $RET == 0 ]] ; then
133 mka -C "$KERNEL_DIR" O="$target_dir" ARCH=arm HOSTCC="$CCACHE gcc" CROSS_COMPILE="$CCACHE $CROSS_PREFIX" zImage
134 RET=$?
135 if [[ $RET == 0 ]] ; then
136 cp "$target_dir"/arch/arm/boot/zImage bin/kernel/zImage
137 for module in "${MODULES[@]}" ; do
138 cp "$target_dir/$module" bin/system/modules
139 done
140 CheckVersion
141 CreateKernelZip
142 UpgradeMinor
143 else
144 CompileError
145 fi
146 else
147 CompileError
148 fi
1f7ea2a @codeworkx tuna: teamhacksung buildscript, cyanogenmod defconfig
codeworkx authored
149 fi
150 }
49f7b44 @KalimochoAz Update BuildScript
KalimochoAz authored
151
1f7ea2a @codeworkx tuna: teamhacksung buildscript, cyanogenmod defconfig
codeworkx authored
152 setup
153
2675ba8 @KalimochoAz Changed build
KalimochoAz authored
154 echo Type y + \"intro\" to send kernel to your mobile:
155 read -t 10 responseSend;
156 if [ "$responseSend" == "y" ] ; then
157 echo Sending to device after build .. $responseSend
158 else
159 echo Only compile .. $responseSend
160 fi
161
1f7ea2a @codeworkx tuna: teamhacksung buildscript, cyanogenmod defconfig
codeworkx authored
162 if [ "$1" = clean ] ; then
163 rm -fr "$BUILD_DIR"/*
164 exit 0
165 fi
166
167 targets=("$@")
168 if [ 0 = "${#targets[@]}" ] ; then
49f7b44 @KalimochoAz Update BuildScript
KalimochoAz authored
169 targets=(tuna)
1f7ea2a @codeworkx tuna: teamhacksung buildscript, cyanogenmod defconfig
codeworkx authored
170 fi
171
172 START=$(date +%s)
173
174 for target in "${targets[@]}" ; do
175 build $target
176 done
177
178 END=$(date +%s)
179 ELAPSED=$((END - START))
180 E_MIN=$((ELAPSED / 60))
181 E_SEC=$((ELAPSED - E_MIN * 60))
182 printf "Elapsed: "
183 [ $E_MIN != 0 ] && printf "%d min(s) " $E_MIN
184 printf "%d sec(s)\n" $E_SEC
Something went wrong with that request. Please try again.