forked from CyanogenMod/android_kernel_google_msm
-
Notifications
You must be signed in to change notification settings - Fork 3
/
glitch.sh
executable file
·173 lines (140 loc) · 5.21 KB
/
glitch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/bash
# Glitch kernel build-script (Aroma Edition) #
# #
# Options : #
# #
# clean : clean the build directory #
# cleank : clean the built kernel packages #
#################################################
############## Basic configuration ##############
# Device options :
target_name="N7" #defines the flashable zip device name
target_variant="-CM" #defines the flashable zip additional name for variants
target_device="N7-2013" #defines the name of device-related folders (can be the same as $target_name)
target_defconfig="Glitch_flo_defconfig" #defines the config to use for the build
# Toolchain selection :
# (default path is "kernel_tree_folder/../toolchains")
# -------linux-x86
#export CROSS_PREFIX="arm-eabi-4.6/bin/arm-eabi-"
#export CROSS_PREFIX="sabermod-androideabi-4.8.3/bin/arm-linux-androideabi-"
export CROSS_PREFIX="arm-cortex_a15-linux-gnueabihf-linaro_4.9.2-2014.09/bin/arm-cortex_a15-linux-gnueabihf-"
# -------darwin-x86
#export CROSS_PREFIX=""
########## End of basic configuration ############
setup ()
{
function mka() {
case `uname -s` in
Darwin)
make -j `sysctl hw.ncpu|cut -d" " -f2` "$@"
;;
*)
schedtool -B -n 1 -e ionice -n 1 make -j `cat /proc/cpuinfo | grep "^processor" | wc -l` "$@"
;;
esac
};
# Arch-dependent definitions
case `uname -s` in
Darwin)
KERNEL_DIR="$(dirname "$(greadlink -f "$0")")"
CROSS_PREFIX="$KERNEL_DIR/../toolchains/$CROSS_PREFIX"
;;
*)
KERNEL_DIR="$(dirname "$(readlink -f "$0")")"
CROSS_PREFIX="$KERNEL_DIR/../toolchains/$CROSS_PREFIX"
;;
esac
BUILD_DIR="../glitch-build/kernel"
if [ x = "x$NO_CCACHE" ] && ccache -V &>/dev/null ; then
CCACHE=ccache
CCACHE_BASEDIR="$KERNEL_DIR"
CCACHE_COMPRESS=1
CCACHE_DIR="$KERNEL_DIR/../.ccache"
export CCACHE_DIR CCACHE_COMPRESS CCACHE_BASEDIR
else
CCACHE=""
fi
}
build ()
{
export ARCH="arm"
local target=$target_device
echo "-----------------------------------------"
echo "Building for $target_device"
local target_dir="$BUILD_DIR/$target_device"
local module
rm -fr "$target_dir"
rm -f $KERNEL_DIR/tmp_$target_defconfig
rm -f $KERNEL_DIR/arch/arm/configs/release_$target_defconfig
mkdir -p "$target_dir"
. $KERNEL_DIR/../rev
#Variant has to use the same rev number as base
#counter=$((counter + 1))
echo "-----------------------------------------"
echo "Write release number in config (r"$counter")"
releasenumber='CONFIG_LOCALVERSION="-Glitch-N7-CM-r'$counter'"'
cp arch/arm/configs/$target_defconfig tmp_$target_defconfig;
sed "43s/.*/$releasenumber/g" tmp_$target_defconfig > release_$target_defconfig;
mv release_$target_defconfig arch/arm/configs/release_$target_defconfig
rm -f $KERNEL_DIR/tmp_$target_defconfig
mka -C "$KERNEL_DIR" O="$target_dir" release_$target_defconfig HOSTCC="$CCACHE gcc"
mka -C "$KERNEL_DIR" O="$target_dir" HOSTCC="$CCACHE gcc" CROSS_COMPILE="$CCACHE $CROSS_PREFIX" zImage modules
[[ -d release ]] || {
echo "-----------------------------------------"
echo "must be in kernel root dir"
exit 1;
}
echo "-----------------------------------------"
echo "copying modules and zImage"
mkdir -p $KERNEL_DIR/release/aroma/system/lib/modules/
cd $target_dir
find -name '*.ko' -exec cp -av {} $KERNEL_DIR/release/aroma/system/lib/modules/ \;
"$CROSS_PREFIX"strip --strip-unneeded $KERNEL_DIR/release/aroma/system/lib/modules/*
cd $KERNEL_DIR
mv $target_dir/arch/arm/boot/zImage $KERNEL_DIR/release/aroma/boot/glitch.zImage
cd $KERNEL_DIR
rm -f arch/arm/configs/release_$target_defconfig
echo "-----------------------------------------"
echo "Setting date in Aroma conf ("$(date +%B)" "$(date +%e)" "$(date +%Y)")"
AromaDateReplace='ini_set("rom_date", "'$(date +%B)' '$(date +%e)' '$(date +%Y)'");'
sed "37s/.*/$AromaDateReplace/g" ./release/aroma/META-INF/com/google/android/aroma-config > ./aroma-config.tmp;
mv ./aroma-config.tmp ./release/aroma/META-INF/com/google/android/aroma-config
echo "-----------------------------------------"
echo "packaging it up"
cd release/aroma
mkdir -p $KERNEL_DIR/release/$target_device
REL=Glitch-$target_name-r$counter$target_variant.zip
zip -q -r ${REL} boot config META-INF system wifi_mod pie_patch
#sha256sum ${REL} > ${REL}.sha256sum
mv ${REL}* $KERNEL_DIR/release/$target_device/
#Variant has to use the same rev number as base
#echo counter=$counter > $KERNEL_DIR/../rev;
rm boot/glitch.zImage
rm -r system/lib/modules/*
echo "-----------------------------------------"
echo ${REL}
}
setup
if [ "$1" = clean ] ; then
rm -fr "$BUILD_DIR"/*
cd release
rm `find ./ -name '*.*~'` -rf
rm `find ./ -name '*~'` -rf
cd $KERNEL_DIR
rm -f $KERNEL_DIR/tmp_$target_defconfig
rm -f arch/arm/configs/release_$target_defconfig
echo "-----------------------------"
echo "Previous build folder cleaned"
echo "-----------------------------"
else
if [ "$1" = cleank ] ; then
rm -fr "$KERNEL_DIR"/release/$target_device/*
echo "---------------------"
echo "Built kernels cleaned"
echo "---------------------"
else
time {
build $target_device
}
fi
fi