-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
292 lines (252 loc) · 6.72 KB
/
build.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
#!/bin/bash
#
# Thanks to Tkkg1994 and djb77 for the script
#
# MoRoKernel Build Script v1.2 modded by Arianoxx
#
# For
#
# ArianoxxKernel
#
# SETUP
# -----
export ARCH=arm64
export SUBARCH=arm64
export BUILD_CROSS_COMPILE=/home/arianoxx-dev/aarch64-linux-android-4.9/bin/aarch64-linux-android-
#export BUILD_CROSS_COMPILE=/home/arianoxx-dev/kernel/toolchains/aarch64-ubertc-5.4.1-20170929/bin/aarch64-linux-android-
#export BUILD_CROSS_COMPILE=/home/arianoxx-dev/kernel/toolchains/aarch64-ubertc-6.4.1-20170929/bin/aarch64-linux-android-
#export BUILD_CROSS_COMPILE=/home/arianoxx-dev/kernel/toolchains/aarch64-ubertc-7.2.1-20170929/bin/aarch64-linux-android-
#export BUILD_CROSS_COMPILE=/home/arianoxx-dev/kernel/toolchains/aarch64-ubertc-7.3.1-20180314/bin/aarch64-linux-android-
#export BUILD_CROSS_COMPILE=/home/arianoxx-dev/kernel/toolchains/aarch64-linaro-7.3/bin/aarch64-linux-gnu-
export CROSS_COMPILE=$BUILD_CROSS_COMPILE
export BUILD_JOB_NUMBER=`grep processor /proc/cpuinfo|wc -l`
export PLATFORM_VERSION=9.0.0
export ANDROID_MAJOR_VERSION=p
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=arianoxx_defconfig
DEFCONFIG_S7EDGE=arianoxx_defconfig_edge
DEFCONFIG_S7FLAT=arianoxx_defconfig_flat
export K_VERSION="v2.2"
export K_NAME="ArianoxKernel"
export REVISION="RC"
export KBUILD_BUILD_VERSION="1"
S7DEVICE="OREO"
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 ./build.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/build
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/build
cd ..
rm -rf temp
echo SEANDROIDENFORCE >> image-new.img
mv image-new.img $MODEL-boot.img
}
FUNC_BUILD_FLASHABLES()
{
cd $RDIR/build
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 script/
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 "MoRoKernel & Arianoxx Build Script"
echo "**********************************"
echo ""
echo ""
echo "Build Kernel for:"
echo ""
echo "S7 Oreo"
echo "(1) S7 Flat SM-G930F"
echo "(2) S7 Edge SM-G935F"
echo "(3) S7 Edge + Flat"
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
export KERNEL_VERSION="$K_NAME-Oreo-$K_VERSION"
echo "S7 Flat G930F Selected"
ZIP_NAME=$K_NAME-$MODEL-O-$K_VERSION.zip
MAIN
elif [ $prompt == "2" ]; then
MODEL=G935
DEVICE=$S7DEVICE
KERNEL_DEFCONFIG=$DEFCONFIG_S7EDGE
LOG=$EDGE_LOG
export KERNEL_VERSION="$K_NAME-Oreo-$K_VERSION"
echo "S7 Edge G935F Selected"
ZIP_NAME=$K_NAME-$MODEL-O-$K_VERSION.zip
MAIN
elif [ $prompt == "3" ]; then
MODEL=G935
DEVICE=$S7DEVICE
KERNEL_DEFCONFIG=$DEFCONFIG_S7EDGE
LOG=$EDGE_LOG
export KERNEL_VERSION="$K_NAME-Oreo-$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-Oreo-$K_VERSION"
echo "Compiling FLAT ..."
ZIP_NAME=$K_NAME-G93X-O-$K_VERSION.zip
MAIN
fi