forked from Matti67/android_kernel_samsung_a50-common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
225 lines (214 loc) · 6.19 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
#!/bin/bash
echo "Setting Up Environment"
echo ""
export ARCH=arm64
export SUBARCH=arm64
export KBUILD_BUILD_USER=neel0210
export KBUILD_BUILD_HOST=Catelina
# Variables
export Image="$(pwd)/out/arch/arm64/boot/Image.gz-dtb"
export TC="/home/neel/Desktop/toolchain/"
export VMTC="$(pwd)/clang"
START(){
# Calculate compilation time
START=$(date +"%s")
}
#
END(){
END=$(date +"%s")
DIFF=$((END - START))
echo -e "Kernel has been compiled successfully and it took $((DIFF / 60)) minute(s) and $((DIFF % 60)) second(s)"
echo "Done!"
}
CLEAN(){
make clean && make mrproper
rm -rf out/arch/arm64/boot/Image.gz-dtb
rm -rf KKRT/*.zip
rm -rf KKRT/Image.gz-dtb
rm -rf out
}
# Enforcing
KERNEL="a50_defconfig"
clear
echo "---------------------------"
echo checking if bulding offline
echo "---------------------------"
if [ -d "$TC" ]; then
echo "building offline; thus exporting paths"
export CROSS_COMPILE=/home/neel/Desktop/toolchain/19/bin/aarch64-linux-android-
export CLANG_TRIPLE=/home/neel/Desktop/toolchain/14/bin/aarch64-linux-gnu-
export CC=/home/neel/Desktop/toolchain/14/clang
export CROSS_COMPILE_ARM32=/home/neel/Desktop/toolchain/1932/bin/arm-linux-androideabi-
export CCACHE_EXEC="/usr/bin/ccache"
export USE_CCACHE=1
ccache -M 50G
export CCACHE_COMPRESS=1
export CCACHE_DIR="/home/neel/Desktop/ccache/.ccache"
else
echo "Not finding Toolchains at Home/toolchains; thus clonning them; would take some couple of minutes"
if [ -d "$VMTC" ]; then
echo exporting paths
export CROSS_COMPILE=$(pwd)/linaro/bin/aarch64-linux-android-
export CROSS_COMPILE_ARM32=$(pwd)/gcc32/bin/arm-linux-androideabi-
export CLANG_TRIPLE=$(pwd)/clang/bin/aarch64-linux-gnu-
export CC=$(pwd)/clang/bin/clang
else
git clone --depth=1 https://github.com/LineageOS/android_prebuilts_gcc_linux-x86_aarch64_aarch64-linux-android-4.9 --single-branch -b lineage-19.0 linaro
git clone --depth=1 https://github.com/LineageOS/android_prebuilts_gcc_linux-x86_arm_arm-linux-androideabi-4.9 --single-branch -b lineage-19.0 gcc32
git clone --depth=1 https://github.com/KakarotKernel/clang.git clang
export CROSS_COMPILE=$(pwd)/linaro/bin/aarch64-linux-android-
export CROSS_COMPILE_ARM32=$(pwd)/gcc32/bin/arm-linux-androideabi-
export CLANG_TRIPLE=$(pwd)/clang/bin/aarch64-linux-gnu-
export CC=$(pwd)/clang/bin/clang
fi
fi
clear
echo "========================="
echo "Remove old Kernel Build"
echo "========================="
rm -rf CORE/*.zip
echo " "
echo "====================================="
echo "Give Perms to fetch-latest-wireguard"
echo "====================================="
chmod a+x scripts/fetch-latest-wireguard.sh
############################################
# If other device make change here
############################################
clear
DB(){
echo "==================="
echo "Building KRNL Clean"
echo "==================="
START
rm -rf out/arch/arm64/boot/Image.gz-dtb
rm -rf KKRT/*.zip
rm -rf KKRT/Image.gz-dtb
clear
echo "================"
echo "Compiling Kernel "
echo "================"
make $KERNEL O=out CC=clang
make -j$(nproc --all) O=out CC=clang
echo
if [ -f "$Image" ]; then
echo "Image compiled; packing it"
cp -r ./out/arch/arm64/boot/Image.gz-dtb ./KKRT/Image.gz-dtb
rm -rf KKRT/*.zip
cd KKRT
. zip.sh
cd ..
changelog=`cat KKRT/changelog.txt`
for i in KKRT/*.zip
do
curl -F "document=@$i" --form-string "caption=$changelog" "https://api.telegram.org/bot${BOT_TOKEN}/sendDocument?chat_id=${CHAT_ID}&parse_mode=HTML"
done
echo ""
END
else
echo "Kernel isnt compiled, letting Neel know"
curl -F text="Realme 6 pro: RUI Kernel is not compiled, come and check @neel0210" "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage?chat_id=${CHAT_ID}&parse_mode=Markdown"
fi
}
KKRT(){
echo "==================="
echo "Building KRNL Clean"
echo "==================="
echo Clean build leftovers
START
make clean && make mrproper
rm -rf out/arch/arm64/boot/Image.gz-dtb
rm -rf KKRT/*.zip
rm -rf KKRT/Image.gz-dtb
clear
echo "================"
echo "Compiling Kernel "
echo "================"
make $KERNEL O=out CC=clang
make -j$(nproc --all) O=out CC=clang
echo
if [ -f "$Image" ]; then
echo "Image compiled; packing it"
cp -r ./out/arch/arm64/boot/Image.gz-dtb ./KKRT/Image.gz-dtb
rm -rf KKRT/*.zip
cd KKRT
. zip.sh
cd ..
changelog=`cat KKRT/changelog.txt`
for i in KKRT/*.zip
do
curl -F "document=@$i" --form-string "caption=$changelog" "https://api.telegram.org/bot${BOT_TOKEN}/sendDocument?chat_id=${CHAT_ID}&parse_mode=HTML"
done
echo ""
END
else
echo "Kernel isnt compiled, letting Neel know"
curl -F text="Realme 6 pro: RUI Kernel is not compiled, come and check @neel0210" "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage?chat_id=${CHAT_ID}&parse_mode=Markdown"
fi
}
#
FLASHING(){
echo "X......Checking if Kernel ZIP is present or not"
sleep 2
cd KKRT
ZIP=$(find *.zip)
if [ -f $ZIP ];
then
echo "X.....$ZIP is able to be flashed"
fi
cd ..
echo "X......Flashing Kernel"
echo "X......Rebooting to recovery"
echo "X......Make sure USB debugging is enabled"
echo "X......If enabled, press ANYKEY now to reboot to recovery"
read -n1 -r key
adb reboot recovery
echo "X......As soon as you boot into recovery, run ADB sideload and then press ANY KEY"
read -n1 -r key
cd KKRT
adb sideload $ZIP >/dev/null 2>&1
cd ..
echo "X......Flashing Done!"
}
clear
echo " "
echo " _ __ _ ________ _____ _ _ "
echo "| | / /| | / /| ___ \_ _| ___ ___ _ __(_)_ __ | |_ "
echo "| |/ / | |/ / | |_/ / | | / __|/ __| '__| | '_ \| __|"
echo "| \ | \ | / | | \__ \ (__| | | | |_) | |_ "
echo "| |\ \| |\ \| |\ \ | | |___/\___|_| |_| .__/ \__|"
echo "\_| \_/\_| \_/\_| \_| \_/ |_| "
echo " coded by Neel0210 "
echo "Select"
echo "1 = Clean"
echo "2 = Clean Build"
echo "3 = Dirty Build"
echo "4 = Update dependencies"
echo "5 = Flash kernel using adb"
echo "6 = exit"
read n
if [ $n -eq 1 ]; then
CLEAN
fi
#
if [ $n -eq 2 ]; then
KKRT
fi
#
if [ $n -eq 3 ]; then
DB
fi
#
if [ $n -eq 4 ]; then
sudo bash scripts/bin
fi
#
if [ $n -eq 5 ]; then
FLASHING
fi
#
if [ $n -eq 6 ]; then
echo "Quiting now"
sleep 2
exit
fi