-
Notifications
You must be signed in to change notification settings - Fork 0
/
ts-builder.sh
executable file
·308 lines (265 loc) · 7.97 KB
/
ts-builder.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
#!/bin/bash
#
# Thanks to Tkkg1994 and djb77 for the script
#
# Thanks to MoRoGoku for the script
# Kernel Build Script v1.9, modified by ThunderStorms Team
#
# SETUP
# -----
export ARCH=arm64
export SUBARCH=arm64
# NO WORKS export BUILD_CROSS_COMPILE=~/kernel/toolchain/gcc-linaro-5.5.0-2017.10-i686_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
# export BUILD_CROSS_COMPILE=~/kernel/toolchain/aarch64-linux-android-4.9-master/bin/aarch64-linux-android-
export BUILD_CROSS_COMPILE=~/kernel/toolchain/aarch64-linux-android-4.9-o-mr1-iot-preview-8/bin/aarch64-linux-android-
# export BUILD_CROSS_COMPILE=~/kernel/toolchain/aarch64-linux-android-4.9/bin/aarch64-linux-android-
# NO WORKS export BUILD_CROSS_COMPILE=~kernel/toolchain/arm-eabi-4.8-master/bin/arm-eabi-
# NO WORKS export BUILD_CROSS_COMPILE=~/kernel/toolchain/arm32_arm64_cross_toolchain-master/bin/aarch64-linux-aarch64-linux-
# BL - export BUILD_CROSS_COMPILE=~/kernel/toolchain/aarch64-linux-gnu-7.3-master/bin/aarch64-linux-gnu-
# BL export BUILD_CROSS_COMPILE=~/kernel/toolchain/aarch64-linaro-linux-android-6.3.1/bin/aarch64-linux-android-
# WORKS export BUILD_CROSS_COMPILE=~/kernel/toolchain/aarch64-linux-android-4.9-945/bin/aarch64-linux-android-
#export BUILD_CROSS_COMPILE=~/kernel/toolchain/aarch64-sabermod-7.0/bin/aarch64-
#export BUILD_CROSS_COMPILE=~/kernel/kernel/toolchain/aarch64-uber-linux-android-4.9.4/bin/aarch64-linux-android-
#export BUILD_CROSS_COMPILE=~/kernel/toolchain/aarch64-linux-android-6.3/bin/aarch64-linux-android-
#export BUILD_CROSS_COMPILE=~/kernel/toolchain/linaro-7.2.1-master/bin/arm-linaro-linux-androideabi-
#export BUILD_CROSS_COMPILE=~/kernel/toolchain/aarch64-linux-android-7.0-kernel/bin/aarch64-linux-android-
#export BUILD_CROSS_COMPILE=~/kernel/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
export CROSS_COMPILE=$BUILD_CROSS_COMPILE
export BUILD_JOB_NUMBER=`grep processor /proc/cpuinfo|wc -l`
export ANDROID_MAJOR_VERSION=p
export PLATFORM_VERSION=9.0.0
export ANDROID_VERSION=90000
RDIR=$(pwd)
OUTDIR=$RDIR/arch/$ARCH/boot
DTSDIR=$RDIR/arch/$ARCH/boot/dts
DTBDIR=$OUTDIR/dtb
DTCTOOL=$RDIR/scripts/dtc/dtc
INCDIR=$RDIR/include
PAGE_SIZE=2048
DTB_PADDING=0
DEFCONFIG=ts-kernel_defconfig
DEFCONFIG_S7EDGE=hero2lte_defconfig
DEFCONFIG_S7FLAT=herolte_defconfig
# export K_VERSION="v1.9-WasEdition"
export K_VERSION="v1.9"
export K_BASE="U4CSC4"
export K_NAME="ThundeRStormS-Kernel"
export REVISION="RC"
export KBUILD_BUILD_VERSION="1"
S7DEVICE="PIE"
EDGE_LOG=Edge_build.log
FLAT_LOG=Flat_build.log
PORT=0
# FUNCTIONS
# ---------
FUNC_DELETE_PLACEHOLDERS()
{
find . -name \.placeholder -type f -delete
echo "Placeholders Deleted from Ramdisk"
echo ""
}
FUNC_CLEAN_DTB()
{
if ! [ -d $RDIR/arch/$ARCH/boot/dts ] ; then
echo "no directory : "$RDIR/arch/$ARCH/boot/dts""
else
echo "rm files in : "$RDIR/arch/$ARCH/boot/dts/*.dtb""
rm $RDIR/arch/$ARCH/boot/dts/*.dtb
rm $RDIR/arch/$ARCH/boot/dtb/*.dtb
rm $RDIR/arch/$ARCH/boot/boot.img-dtb
rm $RDIR/arch/$ARCH/boot/boot.img-zImage
fi
}
FUNC_BUILD_KERNEL()
{
echo ""
echo "build common config="$KERNEL_DEFCONFIG ""
echo "build variant config="$MODEL ""
cp -f $RDIR/arch/$ARCH/configs/$DEFCONFIG $RDIR/arch/$ARCH/configs/tmp_defconfig
cat $RDIR/arch/$ARCH/configs/$KERNEL_DEFCONFIG >> $RDIR/arch/$ARCH/configs/tmp_defconfig
#FUNC_CLEAN_DTB
make -j$BUILD_JOB_NUMBER ARCH=$ARCH \
CROSS_COMPILE=$BUILD_CROSS_COMPILE \
tmp_defconfig || exit -1
make -j$BUILD_JOB_NUMBER ARCH=$ARCH \
CROSS_COMPILE=$BUILD_CROSS_COMPILE || exit -1
echo ""
rm -f $RDIR/arch/$ARCH/configs/tmp_defconfig
}
FUNC_BUILD_DTB()
{
[ -f "$DTCTOOL" ] || {
echo "You need to run ./ts_builder.sh first!"
exit 1
}
case $MODEL in
G930)
DTSFILES="exynos8890-herolte_eur_open_04 exynos8890-herolte_eur_open_08
exynos8890-herolte_eur_open_09 exynos8890-herolte_eur_open_10"
;;
G935)
DTSFILES="exynos8890-hero2lte_eur_open_04 exynos8890-hero2lte_eur_open_08"
;;
*)
echo "Unknown device: $MODEL"
exit 1
;;
esac
mkdir -p $OUTDIR $DTBDIR
cd $DTBDIR || {
echo "Unable to cd to $DTBDIR!"
exit 1
}
rm -f ./*
echo "Processing dts files."
for dts in $DTSFILES; do
echo "=> Processing: ${dts}.dts"
${CROSS_COMPILE}cpp -nostdinc -undef -x assembler-with-cpp -I "$INCDIR" "$DTSDIR/${dts}.dts" > "${dts}.dts"
echo "=> Generating: ${dts}.dtb"
$DTCTOOL -p $DTB_PADDING -i "$DTSDIR" -O dtb -o "${dts}.dtb" "${dts}.dts"
done
echo "Generating dtb.img."
$RDIR/scripts/dtbtool_exynos/dtbtool -o "$OUTDIR/dtb.img" -d "$DTBDIR/" -s $PAGE_SIZE
echo "Done."
}
FUNC_BUILD_RAMDISK()
{
echo ""
echo "Building Ramdisk"
mv $RDIR/arch/$ARCH/boot/Image $RDIR/arch/$ARCH/boot/boot.img-zImage
mv $RDIR/arch/$ARCH/boot/dtb.img $RDIR/arch/$ARCH/boot/boot.img-dtb
cd $RDIR/builds
mkdir temp
cp -rf aik/. temp
cp -rf ramdisk/. temp
rm -f temp/split_img/boot.img-zImage
rm -f temp/split_img/boot.img-dtb
mv $RDIR/arch/$ARCH/boot/boot.img-zImage temp/split_img/boot.img-zImage
mv $RDIR/arch/$ARCH/boot/boot.img-dtb temp/split_img/boot.img-dtb
cd temp
case $MODEL in
G935)
echo "Ramdisk for G935"
;;
G930)
echo "Ramdisk for G930"
sed -i 's/SRPOI30A000KU/SRPOI17A000KU/g' split_img/boot.img-board
sed -i 's/G935/G930/g' ramdisk/default.prop
sed -i 's/hero2/hero/g' ramdisk/default.prop
;;
esac
echo "Done"
./repackimg.sh
cp -f image-new.img $RDIR/builds
cd ..
rm -rf temp
echo SEANDROIDENFORCE >> image-new.img
mv image-new.img $MODEL-boot.img
}
FUNC_BUILD_FLASHABLES()
{
cd $RDIR/builds
mkdir temp2
cp -rf zip/common/. temp2
mv *.img temp2/
cd temp2
echo ""
echo "Compressing kernels..."
tar cv *.img | xz -9 > kernel.tar.xz
mv kernel.tar.xz ts/
rm -f *.img
zip -9 -r ../$ZIP_NAME *
cd ..
rm -rf temp2
}
# MAIN PROGRAM
# ------------
MAIN()
{
(
START_TIME=`date +%s`
FUNC_DELETE_PLACEHOLDERS
FUNC_BUILD_KERNEL
FUNC_BUILD_DTB
FUNC_BUILD_RAMDISK
FUNC_BUILD_FLASHABLES
END_TIME=`date +%s`
let "ELAPSED_TIME=$END_TIME-$START_TIME"
echo "Total compile time is $ELAPSED_TIME seconds"
echo ""
) 2>&1 | tee -a ./$LOG
echo "Your flasheable release can be found in the build folder"
echo ""
}
MAIN2()
{
(
START_TIME=`date +%s`
FUNC_DELETE_PLACEHOLDERS
FUNC_BUILD_KERNEL
FUNC_BUILD_DTB
FUNC_BUILD_RAMDISK
END_TIME=`date +%s`
let "ELAPSED_TIME=$END_TIME-$START_TIME"
echo "Total compile time is $ELAPSED_TIME seconds"
echo ""
) 2>&1 | tee -a ./$LOG
echo "Your flasheable release can be found in the build folder"
echo ""
}
# PROGRAM START
# -------------
clear
echo "*****************************************"
echo "* ThunderStorms Kernel Build Script *"
echo "*****************************************"
echo ""
echo " CUSTOMIZABLE STOCK SAMSUNG KERNEL"
echo ""
echo " Build Kernel for:"
echo ""
echo "S7 Oreo"
echo "(1) S7 Flat SM-G930F/FD"
echo "(2) S7 Edge SM-G935F/FD"
echo "(3) S7 Edge + Flat F/FD"
echo ""
echo ""
read -p "Select an option to compile the kernel " prompt
if [ $prompt == "1" ]; then
MODEL=G930
DEVICE=$S7DEVICE
KERNEL_DEFCONFIG=$DEFCONFIG_S7FLAT
LOG=$FLAT_LOG
ZIP_DATE=`date +%Y%m%d`
export KERNEL_VERSION="$K_NAME-$K_BASE-PIE-$K_VERSION"
echo "S7 Flat G930F Selected"
ZIP_NAME=$K_NAME-$MODEL-PIE-$K_VERSION-$ZIP_DATE.zip
MAIN
elif [ $prompt == "2" ]; then
MODEL=G935
DEVICE=$S7DEVICE
KERNEL_DEFCONFIG=$DEFCONFIG_S7EDGE
LOG=$EDGE_LOG
ZIP_DATE=`date +%Y%m%d`
export KERNEL_VERSION="$K_NAME-$K_BASE-PIE-$K_VERSION"
echo "S7 Edge G935F Selected"
ZIP_NAME=$K_NAME-$MODEL-PIE-$K_VERSION-$ZIP_DATE.zip
MAIN
elif [ $prompt == "3" ]; then
MODEL=G935
DEVICE=$S7DEVICE
KERNEL_DEFCONFIG=$DEFCONFIG_S7EDGE
LOG=$EDGE_LOG
ZIP_DATE=`date +%Y%m%d`
export KERNEL_VERSION="$K_NAME-$K_BASE-PIE-$K_VERSION"
echo "S7 EDGE + FLAT Selected"
echo "Compiling EDGE ..."
MAIN2
MODEL=G930
KERNEL_DEFCONFIG=$DEFCONFIG_S7FLAT
LOG=$FLAT_LOG
export KERNEL_VERSION="$K_NAME-$K_BASE-PIE-$K_VERSION"
echo "Compiling FLAT ..."
ZIP_NAME=$K_NAME-G93X-PIE-$K_VERSION-$ZIP_DATE.zip
MAIN
fi