-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild_menu
executable file
·242 lines (215 loc) · 7.41 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
#!/bin/bash
# Hari menu v3.0 based on afaneh menu
# Variables
DIR=`readlink -f .`
PARENT_DIR=`readlink -f ${DIR}/..`
export PLATFORM_VERSION=11
export ANDROID_MAJOR_VERSION=r
export SEC_BUILD_CONF_VENDOR_BUILD_OS=13
export CROSS_COMPILE=$PARENT_DIR/aarch64-linux-android-4.9/bin/aarch64-linux-android-
export CLANG_TRIPLE=$PARENT_DIR/clang-r383902/bin/aarch64-linux-gnu-
export ARCH=arm64
export LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN=$PARENT_DIR/aarch64-linux-android-4.9/bin
export CLANG_PREBUILT_BIN=$PARENT_DIR/clang-r383902/bin
export PATH=$PATH:$LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN:$CLANG_PREBUILT_BIN
export LLVM=1
#export USE_CCACHE=1
#export CCACHE_EXEC=/usr/bin/ccache
#export CCACHE_DIR=/mnt/ccache
#ccache -M 50G -F 0
# Color
ON_BLUE=`echo -e "\033[44m"` # On Blue
RED=`echo -e "\033[1;31m"` # Red
BLUE=`echo -e "\033[1;34m"` # Blue
GREEN=`echo -e "\033[1;32m"` # Green
Under_Line=`echo -e "\e[4m"` # Text Under Line
STD=`echo -e "\033[0m"` # Text Clear
# Functions
pause(){
read -p "${RED}$2${STD}Press ${BLUE}[Enter]${STD} key to $1..." fackEnterKey
}
toolchain(){
if [ ! -d $PARENT_DIR/aarch64-linux-android-4.9 ]; then
pause 'clone Toolchain aarch64-linux-android-4.9 cross compiler'
git clone --branch android-9.0.0_r59 https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9 $PARENT_DIR/aarch64-linux-android-4.9
. $DIR/build_menu
fi
}
clang(){
if [ ! -d $PARENT_DIR/clang-r383902 ]; then
pause 'clone Android Clang/LLVM Prebuilts'
git clone https://github.com/AOSP-10/prebuilts_clang_host_linux-x86_clang-r383902 $PARENT_DIR/clang-r383902
. $DIR/build_menu
fi
}
clean(){
echo "${GREEN}***** Cleaning in Progress *****${STD}"
make clean -j$(nproc)
make mrproper -j$(nproc)
[ -d "out" ] && rm -rf out
echo "${GREEN}***** Cleaning Done *****${STD}"
}
build_kernel(){
KERNEL_MAKE_ENV="LOCALVERSION=-Hari-v${harikernelver}-OneUI"
echo "${GREEN}***** Compiling kernel for ${VARIANT} *****${STD}"
[ ! -d "out" ] && mkdir out
make -j$(nproc) -C $(pwd) $KERNEL_MAKE_ENV hari_${VARIANT}_defconfig
make -j$(nproc) -C $(pwd) $KERNEL_MAKE_ENV
[ -e arch/arm64/boot/Image.gz ] && cp arch/arm64/boot/Image.gz $(pwd)/out/Image.gz
if [ -e arch/arm64/boot/Image ]; then
cp arch/arm64/boot/Image $(pwd)/out/Image
DTB_DIR=$(pwd)/arch/arm64/boot/dts
$(pwd)/tools/mkdtimg cfg_create $(pwd)/out/dtb.img dt.configs/exynos2100.cfg -d ${DTB_DIR}/exynos
$(pwd)/tools/mkdtimg cfg_create $(pwd)/out/dtbo.img dt.configs/${VARIANT}.cfg -d ${DTB_DIR}/samsung/${VARIANT}
echo "${GREEN}***** Ready to Roar *****${STD}"
else
echo 'Error'
fi
}
install-kernel-modules(){
[ -d "$2" ] && rm -rf $2
mkdir -p $2
sed -e 's/\(.*kernel.*\):/\/\1:/g' -e 's/ \([^ ]*kernel[^ ]*\)/ \/\1/g' $1/modules.dep > $2/modules.dep
cp $1/modules.softdep $2
cp $1/modules.alias $2
for MOD in $modules; do
MODULE="$(basename $MOD)"
sed -i "s|\(.*kernel.*\)\/$MODULE:|/lib/modules/$MODULE:|" $2/modules.dep
sed -i "s| \([^ ]*kernel.*\)\/$MODULE| /lib/modules/$MODULE|" $2/modules.dep
basename $MOD >> $2/modules.load;
cp $MOD $2
done
}
build_kernel_modules(){
if [ -e $DIR/arch/arm64/boot/Image ]; then
# Build modules
echo "${GREEN}***** Installing Kernel Modules *****${STD}"
[ ! -d "out/tmp_modules" ] && mkdir -p out/tmp_modules
make -j$(nproc) -C $(pwd) $KERNEL_MAKE_ENV modules
make -j$(nproc) -C $(pwd) $KERNEL_MAKE_ENV INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=$(pwd)/out/tmp_modules modules_install
kernel_release=$(cat include/config/kernel.release)
kernel_modules_dir=$DIR/out/tmp_modules/lib/modules/$kernel_release
kernel_modules_out=$DIR/out/lib/modules
modules=$(find $kernel_modules_dir -type f -name '*.ko');
install-kernel-modules $kernel_modules_dir $kernel_modules_out
[ -d "out/tmp_modules" ] && rm -rf out/tmp_modules
echo "${GREEN}***** Ready to Roar *****${STD}"
pause 'continue'
else
pause 'return to Main menu' 'Build kernel first, '
fi
}
anykernel3(){
if [ ! -d $PARENT_DIR/AnyKernel3 ]; then
pause 'clone AnyKernel3 - Flashable Zip Template'
git clone https://github.com/osm0sis/AnyKernel3 $PARENT_DIR/AnyKernel3
fi
[ -e $PARENT_DIR/${VARIANT}_kernel.zip ] && rm $PARENT_DIR/${VARIANT}_kernel.zip
if [ -e $DIR/arch/arm64/boot/Image ]; then
cd $PARENT_DIR/AnyKernel3
git reset --hard
cp $DIR/arch/arm64/boot/Image zImage
cp $DIR/out/dtbo.img dtbo.img
sed -i "s/ExampleKernel by osm0sis/${VARIANT} HariKernel (OneUI) by Haridhayal/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/omap\/omap_hsmmc\.0\/by-name\/boot/13100000\.ufs\/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/## end boot install/flash_dtbo/g" anykernel.sh
zip -r9 $PARENT_DIR/${releasefilename}.zip * -x .git README.md *placeholder
cd $DIR
else
echo 'Done building Flashable zip for ${VARIANT}'
fi
}
build_kernel_o1s(){
read -p "Enter Kernel Release Version v" harikernelver
VARIANT=o1s
build_kernel
curtime=`date +"%m_%d_%H%M"`
releasefilename=HariKernel_Test_${curtime}_OneUI_${VARIANT}
anykernel3
clean
}
build_kernel_t2s(){
read -p "Enter Kernel Release Version v" harikernelver
VARIANT=t2s
build_kernel
curtime=`date +"%m_%d_%H%M"`
releasefilename=HariKernel_Test_${curtime}_OneUI_${VARIANT}
anykernel3
clean
}
build_kernel_p3s(){
read -p "Enter Kernel Release Version v" harikernelver
VARIANT=p3s
build_kernel
curtime=`date +"%m_%d_%H%M"`
releasefilename=HariKernel_Test_${curtime}_OneUI_${VARIANT}
anykernel3
clean
}
build_kernel_all_devices(){
read -p "Enter Kernel Release Version v" harikernelver
VARIANT=o1s
build_kernel
releasefilename=HariKernel_v${harikernelver}_OneUI_${VARIANT}
anykernel3
clean
VARIANT=t2s
build_kernel
releasefilename=HariKernel_v${harikernelver}_OneUI_${VARIANT}
anykernel3
clean
VARIANT=p3s
build_kernel
releasefilename=HariKernel_v${harikernelver}_OneUI_${VARIANT}
anykernel3
clean
pause 'All the builds are done'
}
# Run once
toolchain
clang
# Show menu
show_menus(){
echo "${ON_BLUE} B U I L D - M E N U ${STD}"
echo "1. ${Under_Line}B${STD}uild kernel for o1s"
echo "2. ${Under_Line}B${STD}uild kernel for t2s"
echo "3. ${Under_Line}B${STD}uild kernel for p3s"
echo "4. ${Under_Line}B${STD}uild kernel for all devices"
echo "5. Build kernel ${Under_Line}m${STD}odules"
echo "6. ${Under_Line}C${STD}lean"
echo "7. Make ${Under_Line}f${STD}lashable zip"
echo "8. E${Under_Line}x${STD}it"
}
# Read input
read_options(){
local choice
read -p "Enter choice [ 1 - 8] " choice
case $choice in
1|b|B) build_kernel_o1s ;;
2|b|B) build_kernel_t2s ;;
3|b|B) build_kernel_p3s ;;
4|a|A) build_kernel_all_devices ;;
5|m|M) build_kernel_modules ;;
6|c|C) clean ;;
7|f|F) anykernel3;;
8|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