-
Notifications
You must be signed in to change notification settings - Fork 27
/
build_menu
executable file
·162 lines (143 loc) · 4.11 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
#!/bin/bash
# Afaneh menu V2.0
# Variables
DIR=`readlink -f .`
PARENT_DIR=`readlink -f ${DIR}/..`
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
KERNEL_MAKE_ENV="LOCALVERSION=-RealKing"
# 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
}
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/release_* 2>/dev/null))
declare -i i=1
shift 2
for e in "${findconfig[@]}"; do
echo "$i) $(basename $e | cut -d'_' -f2)"
i=i+1
done
echo ""
read -p "Select variant: " REPLY
i="$REPLY"
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 "${GREEN}***** Cleaning in Progress *****${STD}"
make clean
make mrproper
[ -d "out" ] && rm -rf out
echo "${GREEN}***** Cleaning Done *****${STD}"
pause 'continue'
}
build_kernel(){
variant
echo "${GREEN}***** Compiling kernel *****${STD}"
[ ! -d "out" ] && mkdir out
make -j$(nproc) -C $(pwd) $KERNEL_MAKE_ENV release_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
echo "${GREEN}***** Ready to Roar *****${STD}"
pause 'continue'
else
pause 'return to Main menu' 'Kernel STUCK in BUILD!, '
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
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
zip -r9 $PARENT_DIR/${VARIANT}_kernel_`date '+%Y_%m_%d'`.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 zip"
echo "4. E${Under_Line}x${STD}it"
}
# Read input
read_options(){
local choice
read -p "Enter choice [ 1 - 4] " choice
case $choice in
1|b|B) build_kernel ;;
2|c|C) clean ;;
3|f|F) anykernel3;;
4|x|X) exit 0;;
*) pause 'return to Main menu' 'Invalid option, '
esac
}
# Trap CTRL+C, CTRL+Z and quit singles
# Step # Main logic - infinite loop
while true
do
show_menus
read_options
done