-
Notifications
You must be signed in to change notification settings - Fork 0
/
1.sh
executable file
·207 lines (146 loc) · 5.76 KB
/
1.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
#!/bin/bash
# Export
export CLANG_PATH=$CLANG_PATH
export PATH=$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH
export CC=clang-11
export CROSS_COMPILE=aarch64-linux-gnu-
export CLANG_TRIPLE=aarch64-linux-gnu-
export CROSS_COMPILE_ARM32=arm-linux-gnueabi-
export CODENAME=joyeus
export DEFCONFIG=akame_defconfig
export OUT_DIR=out
export ANYKERNEL_DIR=AnyKernel3
export ARCH=arm64
export CORES="-j16"
export CONFIG=".config"
export NKD=AkameKernel-joeuse
export CODENAME=joeuse
export UN=root
pwd=$PWD
DATE=$(date +'%d-%m-%Y')
BUILD_START=$(date +"%s")
blue='\033[0;34m'
cyan='\033[0;36m'
yellow='\033[0;33m'
red='\033[0;31m'
nocol='\033[0m'
echo -e "$red\n ##----------------------------------------------------------------------------##$nocol\n"
echo -e "$blue\n #### ## ## ## ## ####### ######## ######## ### ## "
echo -e " ## ### ### ### ### ## ## ## ## ## ## ## ## "
echo -e " ## #### #### #### #### ## ## ## ## ## ## ## ## "
echo -e " ## ## ### ## ## ### ## ## ## ######## ## ## ## ## "
echo -e " ## ## ## ## ## ## ## ## ## ## ######### ## "
echo -e " ## ## ## ## ## ## ## ## ## ## ## ## ## "
echo -e " #### ## ## ## ## ####### ## ## ## ## ## ########$nocol"
echo -e "$red\n ##----------------------------------------------------------------------------##$nocol\n"
echo -e "$yellow\n ##============================================================================##"
echo -e " ##========================= Build Kernel From Source =========================##"
echo -e " ##============================================================================##$nocol\n"
sudo ccache make ${DEFCONFIG} \
PATH=${PATH} \
CC=${CC} \
CLANG_TRIPLE=${CLANG_TRIPLE} \
CROSS_COMPILE=${CROSS_COMPILE} \
CROSS_COMPILE_ARM32=${CROSS_COMPILE_ARM32} \
ARCH=${ARCH} \
O=${OUT_DIR} \
${CORES}
# LTO And LLD Optimizations
scripts/config --file ${OUT_DIR}/${CONFIG} \
-d LTO \
-d LTO_CLANG \
-e TOOLS_SUPPORT_RELR \
-e LD_BFD
sudo ccache make all \
PATH=${PATH} \
CC=${CC} \
CLANG_TRIPLE=${CLANG_TRIPLE} \
CROSS_COMPILE=${CROSS_COMPILE} \
CROSS_COMPILE_ARM32=${CROSS_COMPILE_ARM32} \
ARCH=${ARCH} \
O=${OUT_DIR} \
${CORES}
sudo ccache make dtbo.img \
PATH=${PATH} \
CC=${CC} \
CLANG_TRIPLE=${CLANG_TRIPLE} \
CROSS_COMPILE=${CROSS_COMPILE} \
CROSS_COMPILE_ARM32=${CROSS_COMPILE_ARM32} \
ARCH=${ARCH} \
O=${OUT_DIR} \
${CORES}
sudo make firmware_install modules_install \
PATH=${PATH} \
CC=${CC} \
CLANG_TRIPLE=${CLANG_TRIPLE} \
CROSS_COMPILE=${CROSS_COMPILE} \
CROSS_COMPILE_ARM32=${CROSS_COMPILE_ARM32} \
ARCH=${ARCH} \
O=${OUT_DIR} \
${CORES}
echo -e "$yellow\n ##============================================================================##"
echo -e " ##=========================== Build Kernel Headers ===========================##"
echo -e " ##============================================================================##$nocol\n"
sudo rm -rf /${UN}/kernel-headers/kernel-headers/
sudo rm -rf /${UN}/tmp
rm -rf /${UN}/kernel-headers-${CODENAME}.tar.xz
mkdir /${UN}/kernel-headers/kernel-headers/
cp -r * /${UN}/kernel-headers/kernel-headers/
cd /${UN}/kernel-headers/kernel-headers/
sudo make ${DEFCONFIG} prepare \
PATH=${PATH} \
CC=${CC} \
CLANG_TRIPLE=${CLANG_TRIPLE} \
CROSS_COMPILE=${CROSS_COMPILE} \
CROSS_COMPILE_ARM32=${CROSS_COMPILE_ARM32} \
ARCH=${ARCH} \
${CORES}
mkdir /${UN}/tmp
cp -r arch/arm* Makefile out/modules.* out/scripts/mod/modpost out/scripts/genksyms/genksyms include scripts drivers/misc /${UN}/tmp
rm -rf *
cp -r /${UN}/tmp/* $PWD
mv modpost scripts/mod/
mv genksyms scripts/genksyms/
rm -rf /${UN}/tmp
mkdir arch
cp -r arm* arch
rm -rf arm*
mkdir drivers
cp -r misc drivers
rm -rf misc
cd /${UN}/kernel-headers/kernel-headers/
#tar czf kernel-headers-${CODENAME}.tar.xz *
#mv kernel-headers-${CODENAME}.tar.xz /${UN}
cd /${UN}/
sudo dpkg-deb --build kernel-headers kernel-headers-${CODENAME}.deb
ls
echo -e "$yellow\n ##============================================================================##"
echo -e " ##===================== Creating A Flashable *.zip Archive ===================##"
echo -e " ##============================================================================##$nocol\n"
cd /${UN}/${NKD}
rm -rf AnyKernel3
cp /${UN}/AnyKernel3 /${UN}/${NKD} -r
KERNEL_NAME=$(make kernelrelease O=out PATH=${PATH} \
CC=${CC} \
CLANG_TRIPLE=${CLANG_TRIPLE} \
CROSS_COMPILE=${CROSS_COMPILE} \
CROSS_COMPILE_ARM32=${CROSS_COMPILE_ARM32} \
ARCH=${ARCH} \
${CORES} | grep +)
mkdir -p ${ANYKERNEL_DIR}/modules/system/lib/modules/${KERNEL_NAME}/kernel
mkdir -p ${ANYKERNEL_DIR}/modules/vendor/firmware
cd /${UN}/${NKD}
cd out && cp $(find -name *.ko) --parents ../${ANYKERNEL_DIR}/modules/system/lib/modules/${KERNEL_NAME}/kernel
cp $(find -name *.bin) ../${ANYKERNEL_DIR}/modules/vendor/firmware
cp $(find -name *.fw) ../${ANYKERNEL_DIR}/modules/vendor/firmware
cp modules.* ../${ANYKERNEL_DIR}/modules/system/lib/modules/ && cd ..
#find -name '*.dtb' -exec cat {} + > dtb
#cp $(find -name Image.gz-dtb) ${ANYKERNEL_DIR}
cp $(find -name dtbo.img) ${ANYKERNEL_DIR}
cp $(find -name Image) ${ANYKERNEL_DIR}
cp $(find -name dtb) ${ANYKERNEL_DIR}
cd ${ANYKERNEL_DIR} && zip -r -9 AkameKernel.zip * -x .git README.md *placeholder
BUILD_END=$(date +"%s")
DIFF=$(($BUILD_END - $BUILD_START))
echo -e "$blue Kernel compiled on $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds$nocol"