-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild_menu
executable file
·322 lines (271 loc) · 10.4 KB
/
build_menu
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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
#!/bin/bash
# AFANEH-KERNEL-BUILD menu
# Variables
menu_version="v2.3"
DIR=`readlink -f .`
OUT_DIR=$DIR/out
PARENT_DIR=`readlink -f ${DIR}/..`
VERSION=$1
DEFCONFIG_LOKI=loki_defconfig
export CROSS_COMPILE=$PARENT_DIR/clang-r416183b/bin/aarch64-linux-gnu-
export CC=$PARENT_DIR/clang-r416183b/bin/clang
export PLATFORM_VERSION=12
export ANDROID_MAJOR_VERSION=s
export PATH=$PARENT_DIR/clang-r416183b/bin:$PATH
export PATH=$PARENT_DIR/build-tools/path/linux-x86:$PATH
export PATH=$PARENT_DIR/gas/linux-x86:$PATH
export TARGET_SOC=s5e9925
export LLVM=1 LLVM_IAS=1
export ARCH=arm64
# Color
ON_BLUE=`echo -e "\033[44m"` # On Blue
BRED=`echo -e "\033[1;31m"` # Bold Red
BBLUE=`echo -e "\033[1;34m"` # Bold Blue
BGREEN=`echo -e "\033[1;32m"` # Bold Green
UNDER_LINE=`echo -e "\e[4m"` # Text Under Line
STD=`echo -e "\033[0m"` # Text Clear
# Functions
pause(){
read -p "${BRED}$2${STD}Press ${BBLUE}[Enter]${STD} key to $1..." fackEnterKey
}
clang(){
if [ ! -d $PARENT_DIR/clang-r416183b ]; then
pause 'clone Android Clang/LLVM Prebuilts'
git clone https://github.com/crdroidandroid/android_prebuilts_clang_host_linux-x86_clang-r416183b $PARENT_DIR/clang-r416183b
. $DIR/build_menu
fi
}
gas(){
if [ ! -d $PARENT_DIR/gas/linux-x86 ]; then
pause 'clone prebuilt binaries of GNU `as` (the assembler)'
git clone https://android.googlesource.com/platform/prebuilts/gas/linux-x86 $PARENT_DIR/gas/linux-x86
. $DIR/build_menu
fi
}
build_tools(){
if [ ! -d $PARENT_DIR/build-tools ]; then
pause 'clone prebuilt binaries of build tools'
git clone https://android.googlesource.com/platform/prebuilts/build-tools $PARENT_DIR/build-tools
. $DIR/build_menu
fi
}
variant(){
findconfig=""
findconfig=($(ls arch/arm64/configs/exynos2200_* 2>/dev/null))
declare -i i=1
shift 2
echo ""
echo "${ON_BLUE}Variant Selection:${STD}"
for e in "${findconfig[@]}"; do
echo " $i. $(basename $e | cut -d'_' -f2)"
i=i+1
done
local choice
read -p "Enter choice [ 1 - $((i-1)) ] " choice
i="$choice"
if [[ $i -gt 0 && $i -le ${#findconfig[@]} ]]; then
export v="${findconfig[$i-1]}"
export VARIANT=$(basename $v | cut -d'_' -f2)
echo ${VARIANT} selected
pause 'continue'
else
pause 'return to Main menu' 'Invalid option, '
. $DIR/build_menu
fi
}
clean(){
echo "${BGREEN}***** Cleaning in Progress *****${STD}"
make clean
make mrproper
[ -d "$OUT_DIR" ] && rm -rf $OUT_DIR
echo "${BGREEN}***** Cleaning Done *****${STD}"
pause 'continue'
}
build_kernel(){
KERNEL_MAKE_ENV="LOCALVERSION=-loki"
variant
echo "${GREEN}***** Compiling kernel *****${STD}"
START_TIME=`date +%T`
START_TIME_SEC=`date +%s`
[ ! -d "out" ] && mkdir -p out/${VARIANT}
cp -f $(pwd)/arch/arm64/configs/exynos2200_${VARIANT}_defconfig $(pwd)/arch/arm64/configs/tmp_defconfig
cat $(pwd)/arch/arm64/configs/$DEFCONFIG_LOKI >> $(pwd)/arch/arm64/configs/tmp_defconfig
make -j$(nproc) -C $(pwd) $KERNEL_MAKE_ENV tmp_defconfig
make -j$(nproc) -C $(pwd) $KERNEL_MAKE_ENV
END_TIME=`date +%T`
END_TIME_SEC=`date +%s`
echo ""
echo "Start compile time is $START_TIME."
echo "End compile time is $END_TIME."
let "ELAPSED_TIME=$END_TIME_SEC - $START_TIME_SEC"
echo "Total compile time is $ELAPSED_TIME seconds."
echo ""
[ -e arch/arm64/boot/Image.gz ] && cp arch/arm64/boot/Image.gz $(pwd)/out/${VARIANT}/Image.gz
if [ -e arch/arm64/boot/Image ]; then
cp arch/arm64/boot/Image $(pwd)/out/${VARIANT}/Image
echo "${GREEN}***** Ready to Roar *****${STD}"
rm $(pwd)/arch/arm64/configs/tmp_defconfig
pause 'continue'
else
pause 'return to Main menu' 'Kernel STUCK in BUILD!, '
fi
}
build_and_zip(){
KERNEL_MAKE_ENV="LOCALVERSION=-loki"
echo "${GREEN}***** Cleaning in Progress *****${STD}"
make clean
make mrproper
[ -d "out" ] && rm -rf out
echo "${GREEN}***** Cleaning Done *****${STD}"
echo ""
echo "---------------------------------------"
echo ""
echo "${GREEN}***** Compiling kernel *****${STD}"
[ ! -d "out" ] && mkdir -p out/r0s
cp -f $(pwd)/arch/arm64/configs/exynos2200_r0s_defconfig $(pwd)/arch/arm64/configs/tmp_defconfig
cat $(pwd)/arch/arm64/configs/$DEFCONFIG_LOKI >> $(pwd)/arch/arm64/configs/tmp_defconfig
make -j$(nproc) -C $(pwd) $KERNEL_MAKE_ENV tmp_defconfig
make -j$(nproc) -C $(pwd) $KERNEL_MAKE_ENV
cp arch/arm64/boot/Image $(pwd)/out/r0s/Image
cd $PARENT_DIR/AnyKernel3
git reset --hard
cp $(pwd)/out/r0s/Image zImage
sed -i "s/ExampleKernel by osm0sis/r0s kernel by jgudec/g" anykernel.sh
sed -i "s/=maguro/=r0s/g" anykernel.sh
sed -i "s/=toroplus/=/g" anykernel.sh
sed -i "s/=toro/=/g" anykernel.sh
sed -i "s/=tuna/=/g" anykernel.sh
sed -i "s/platform\/omap\/omap_hsmmc\.0\/by-name\/boot/bootdevice\/by-name\/boot/g" anykernel.sh
sed -i "s/backup_file/#backup_file/g" anykernel.sh
sed -i "s/replace_string/#replace_string/g" anykernel.sh
sed -i "s/insert_line/#insert_line/g" anykernel.sh
sed -i "s/append_file/#append_file/g" anykernel.sh
sed -i "s/patch_fstab/#patch_fstab/g" anykernel.sh
sed -i "s/dump_boot/split_boot/g" anykernel.sh
sed -i "s/write_boot/flash_boot/g" anykernel.sh
zip -r9 $PARENT_DIR/Loki_Kernel_v${VERSION}_r0s_AOSP.zip * -x .git README.md *placeholder
sed -i 's|/dev/block/bootdevice/by-name/boot|/dev/block/by-name/boot|g' anykernel.sh
zip -r9 $PARENT_DIR/Loki_Kernel_v${VERSION}_r0s_OneUI.zip * -x .git README.md *placeholder
cd $DIR
[ -d "out" ] && rm -rf out/g0s
[ ! -d "out" ] && mkdir -p out/g0s
cp -f $(pwd)/arch/arm64/configs/exynos2200_g0s_defconfig $(pwd)/arch/arm64/configs/tmp_defconfig
cat $(pwd)/arch/arm64/configs/$DEFCONFIG_LOKI >> $(pwd)/arch/arm64/configs/tmp_defconfig
make -j$(nproc) -C $(pwd) $KERNEL_MAKE_ENV tmp_defconfig
make -j$(nproc) -C $(pwd) $KERNEL_MAKE_ENV
cp arch/arm64/boot/Image $(pwd)/out/g0s/Image
cd $PARENT_DIR/AnyKernel3
git reset --hard
cp $(pwd)/out/g0s/Image zImage
sed -i "s/ExampleKernel by osm0sis/g0s kernel by jgudec/g" anykernel.sh
sed -i "s/=maguro/=g0s/g" anykernel.sh
sed -i "s/=toroplus/=/g" anykernel.sh
sed -i "s/=toro/=/g" anykernel.sh
sed -i "s/=tuna/=/g" anykernel.sh
sed -i "s/platform\/omap\/omap_hsmmc\.0\/by-name\/boot/bootdevice\/by-name\/boot/g" anykernel.sh
sed -i "s/backup_file/#backup_file/g" anykernel.sh
sed -i "s/replace_string/#replace_string/g" anykernel.sh
sed -i "s/insert_line/#insert_line/g" anykernel.sh
sed -i "s/append_file/#append_file/g" anykernel.sh
sed -i "s/patch_fstab/#patch_fstab/g" anykernel.sh
sed -i "s/dump_boot/split_boot/g" anykernel.sh
sed -i "s/write_boot/flash_boot/g" anykernel.sh
zip -r9 $PARENT_DIR/Loki_Kernel_v${VERSION}_g0s_AOSP.zip * -x .git README.md *placeholder
sed -i 's|/dev/block/bootdevice/by-name/boot|/dev/block/by-name/boot|g' anykernel.sh
zip -r9 $PARENT_DIR/Loki_Kernel_v${VERSION}_g0s_OneUI.zip * -x .git README.md *placeholder
cd $DIR
[ -d "out" ] && rm -rf out/b0s
[ ! -d "out" ] && mkdir -p out/b0s
cp -f $(pwd)/arch/arm64/configs/exynos2200_b0s_defconfig $(pwd)/arch/arm64/configs/tmp_defconfig
cat $(pwd)/arch/arm64/configs/$DEFCONFIG_LOKI >> $(pwd)/arch/arm64/configs/tmp_defconfig
make -j$(nproc) -C $(pwd) $KERNEL_MAKE_ENV tmp_defconfig
make -j$(nproc) -C $(pwd) $KERNEL_MAKE_ENV
cp arch/arm64/boot/Image $(pwd)/out/b0s/Image
cd $PARENT_DIR/AnyKernel3
git reset --hard
cp $(pwd)/out/b0s/Image zImage
sed -i "s/ExampleKernel by osm0sis/b0s kernel by jgudec/g" anykernel.sh
sed -i "s/=maguro/=b0s/g" anykernel.sh
sed -i "s/=toroplus/=/g" anykernel.sh
sed -i "s/=toro/=/g" anykernel.sh
sed -i "s/=tuna/=/g" anykernel.sh
sed -i "s/platform\/omap\/omap_hsmmc\.0\/by-name\/boot/bootdevice\/by-name\/boot/g" anykernel.sh
sed -i "s/backup_file/#backup_file/g" anykernel.sh
sed -i "s/replace_string/#replace_string/g" anykernel.sh
sed -i "s/insert_line/#insert_line/g" anykernel.sh
sed -i "s/append_file/#append_file/g" anykernel.sh
sed -i "s/patch_fstab/#patch_fstab/g" anykernel.sh
sed -i "s/dump_boot/split_boot/g" anykernel.sh
sed -i "s/write_boot/flash_boot/g" anykernel.sh
zip -r9 $PARENT_DIR/Loki_Kernel_v${VERSION}_b0s_AOSP.zip * -x .git README.md *placeholder
sed -i 's|/dev/block/bootdevice/by-name/boot|/dev/block/by-name/boot|g' anykernel.sh
zip -r9 $PARENT_DIR/Loki_Kernel_v${VERSION}_b0s_OneUI.zip * -x .git README.md *placeholder
cd $DIR
}
anykernel3(){
if [ ! -d $PARENT_DIR/AnyKernel3 ]; then
pause 'clone AnyKernel3 - Flashable Zip Template'
git clone https://github.com/osm0sis/AnyKernel3 $PARENT_DIR/AnyKernel3
fi
variant
if [ -e $DIR/arch/arm64/boot/Image ]; then
cd $PARENT_DIR/AnyKernel3
git reset --hard
cp $DIR/arch/arm64/boot/Image zImage
sed -i "s/ExampleKernel by osm0sis/${VARIANT} kernel by afaneh92/g" anykernel.sh
sed -i "s/=maguro/=${VARIANT}/g" anykernel.sh
sed -i "s/=toroplus/=/g" anykernel.sh
sed -i "s/=toro/=/g" anykernel.sh
sed -i "s/=tuna/=/g" anykernel.sh
sed -i "s/platform\/omap\/omap_hsmmc\.0\/by-name\/boot/bootdevice\/by-name\/boot/g" anykernel.sh
sed -i "s/backup_file/#backup_file/g" anykernel.sh
sed -i "s/replace_string/#replace_string/g" anykernel.sh
sed -i "s/insert_line/#insert_line/g" anykernel.sh
sed -i "s/append_file/#append_file/g" anykernel.sh
sed -i "s/patch_fstab/#patch_fstab/g" anykernel.sh
sed -i "s/dump_boot/split_boot/g" anykernel.sh
sed -i "s/write_boot/flash_boot/g" anykernel.sh
zip -r9 $PARENT_DIR/Loki_Kernel_v${VERSION}_${VARIANT}_AOSP.zip * -x .git README.md *placeholder
sed -i 's|/dev/block/bootdevice/by-name/boot|/dev/block/by-name/boot|g' anykernel.sh
zip -r9 $PARENT_DIR/Loki_Kernel_v${VERSION}_${VARIANT}_OneUI.zip * -x .git README.md *placeholder
cd $DIR
pause 'continue'
else
pause 'return to Main menu' 'Build kernel first, '
fi
}
# Run once
clang
gas
build_tools
# Show menu
show_menus(){
clear
echo "${ON_BLUE} B U I L D - M E N U ${STD}"
echo "1. ${Under_Line}B${STD}uild kernel"
echo "2. ${Under_Line}C${STD}lean"
echo "3. Make ${Under_Line}f${STD}lashable zips"
echo "4. Build and create zips for all 3 devices"
echo "5. E${Under_Line}x${STD}it"
}
# Read input
read_options(){
local choice
read -p "Enter choice [ 1 - 5] " choice
case $choice in
1|b|B) build_kernel ;;
2|c|C) clean ;;
3|f|F) anykernel3;;
4|y|Y) build_and_zip;;
5|x|X) exit 0;;
*) pause 'return to Main menu' 'Invalid option, '
esac
}
# Trap CTRL+C, CTRL+Z and quit singles
trap '' SIGINT SIGQUIT SIGTSTP
# Step # Main logic - infinite loop
while true
do
show_menus
read_options
done