forked from ExtremeXT/M62-backport
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathworkflows.sh
More file actions
executable file
·239 lines (210 loc) · 6.4 KB
/
workflows.sh
File metadata and controls
executable file
·239 lines (210 loc) · 6.4 KB
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
#!/bin/bash
abort()
{
cd -
echo "-----------------------------------------------"
echo "Kernel compilation failed! Exiting..."
echo "-----------------------------------------------"
exit -1
}
unset_flags()
{
cat << EOF
Usage: $(basename "$0") [options]
Options:
-m, --model [value] Specify the model code of the phone
-k, --ksu [Y/n] Include KernelSU
-r, --recovery [y/N] Compile kernel for an Android Recovery
EOF
}
while [[ $# -gt 0 ]]; do
case "$1" in
--model|-m)
MODEL="$2"
shift 2
;;
--ksu|-k)
KSU_OPTION="$2"
shift 2
;;
--recovery|-r)
RECOVERY_OPTION="$2"
shift 2
;;
*)\
unset_flags
exit 1
;;
esac
done
echo "Preparing the build environment..."
pushd $(dirname "$0") > /dev/null
CORES=`cat /proc/cpuinfo | grep -c processor`
# Define toolchain variables
CLANG_DIR=$PWD/toolchain/neutron_18
PATH=$CLANG_DIR/bin:$PATH
# Check if toolchain exists
if [ ! -f "$CLANG_DIR/bin/clang-18" ]; then
echo "-----------------------------------------------"
echo "Toolchain not found! Downloading..."
echo "-----------------------------------------------"
rm -rf $CLANG_DIR
mkdir -p $CLANG_DIR
pushd toolchain/neutron_18 > /dev/null
bash <(curl -s "https://raw.githubusercontent.com/Neutron-Toolchains/antman/main/antman") -S=05012024
echo "-----------------------------------------------"
echo "Patching toolchain..."
echo "-----------------------------------------------"
bash <(curl -s "https://raw.githubusercontent.com/Neutron-Toolchains/antman/main/antman") --patch=glibc
echo "-----------------------------------------------"
echo "Cleaning up..."
popd > /dev/null
fi
MAKE_ARGS="
LLVM=1 \
LLVM_IAS=1 \
ARCH=arm64 \
O=out
"
# Define specific variables
case $MODEL in
beyond0lte)
BOARD=SRPRI28A016KU
SOC=exynos9820
;;
beyond1lte)
BOARD=SRPRI28B016KU
SOC=exynos9820
;;
beyond2lte)
BOARD=SRPRI17C016KU
SOC=exynos9820
;;
beyondx)
BOARD=SRPSC04B014KU
SOC=exynos9820
;;
d1)
BOARD=SRPSD26B009KU
SOC=exynos9825
;;
d1xks)
BOARD=SRPSD23A002KU
SOC=exynos9825
;;
d2s)
BOARD=SRPSC14B009KU
SOC=exynos9825
;;
d2x)
BOARD=SRPSC14C009KU
SOC=exynos9825
;;
d2xks)
BOARD=SRPSD23C002KU
SOC=exynos9825
;;
*)
unset_flags
exit
esac
if [[ "$RECOVERY_OPTION" == "y" ]]; then
RECOVERY=recovery.config
KSU_OPTION=n
fi
if [ -z $KSU_OPTION ]; then
read -p "Include KernelSU (y/N): " KSU_OPTION
fi
if [[ "$KSU_OPTION" == "y" ]]; then
KSU=ksu.config
fi
rm -rf build/out/$MODEL
mkdir -p build/out/$MODEL/zip/files
mkdir -p build/out/$MODEL/zip/META-INF/com/google/android
# Build kernel image
echo "-----------------------------------------------"
echo "Defconfig: "$KERNEL_DEFCONFIG""
if [ -z "$KSU" ]; then
echo "KSU: No"
else
echo "KSU: Yes"
fi
if [ -z "$RECOVERY" ]; then
echo "Recovery: N"
else
echo "Recovery: Y"
fi
echo "-----------------------------------------------"
echo "Building kernel using "$KERNEL_DEFCONFIG""
echo "Generating configuration file..."
echo "-----------------------------------------------"
make ${MAKE_ARGS} -j$CORES exynos9820_defconfig $MODEL.config $KSU $RECOVERY || abort
echo "Building kernel..."
echo "-----------------------------------------------"
make ${MAKE_ARGS} -j$CORES || abort
# Define constant variables
KERNEL_PATH=build/out/$MODEL/Image
KERNEL_OFFSET=0x00008000
RAMDISK_OFFSET=0xF0000000
SECOND_OFFSET=0xF0000000
TAGS_OFFSET=0x00000100
BASE=0x10000000
CMDLINE='loop.max_part=7'
HASHTYPE=sha1
HEADER_VERSION=1
OS_PATCH_LEVEL=2025-01
OS_VERSION=14.0.0
PAGESIZE=2048
RAMDISK=build/out/$MODEL/ramdisk.cpio.gz
OUTPUT_FILE=build/out/$MODEL/boot.img
## Build auxiliary boot.img files
# Copy kernel to build
cp out/arch/arm64/boot/Image build/out/$MODEL
echo "-----------------------------------------------"
# Build dtb
if [[ "$SOC" == "exynos9820" ]]; then
echo "Building common exynos9820 Device Tree Blob Image..."
echo "-----------------------------------------------"
./toolchain/mkdtimg cfg_create build/out/$MODEL/dtb.img build/dtconfigs/exynos9820.cfg -d out/arch/arm64/boot/dts/exynos
fi
if [[ "$SOC" == "exynos9825" ]]; then
echo "Building common exynos9825 Device Tree Blob Image..."
echo "-----------------------------------------------"
./toolchain/mkdtimg cfg_create build/out/$MODEL/dtb.img build/dtconfigs/exynos9825.cfg -d out/arch/arm64/boot/dts/exynos
fi
echo "-----------------------------------------------"
# Build dtbo
echo "Building Device Tree Blob Output Image for "$MODEL"..."
echo "-----------------------------------------------"
./toolchain/mkdtimg cfg_create build/out/$MODEL/dtbo.img build/dtconfigs/$MODEL.cfg -d out/arch/arm64/boot/dts/samsung
echo "-----------------------------------------------"
if [ -z "$RECOVERY" ]; then
# Build ramdisk
echo "Building RAMDisk..."
echo "-----------------------------------------------"
pushd build/ramdisk > /dev/null
find . ! -name . | LC_ALL=C sort | cpio -o -H newc -R root:root | gzip > ../out/$MODEL/ramdisk.cpio.gz || abort
popd > /dev/null
echo "-----------------------------------------------"
# Create boot image
echo "Creating boot image..."
echo "-----------------------------------------------"
./toolchain/mkbootimg --base $BASE --board $BOARD --cmdline "$CMDLINE" --hashtype $HASHTYPE \
--header_version $HEADER_VERSION --kernel $KERNEL_PATH --kernel_offset $KERNEL_OFFSET \
--os_patch_level $OS_PATCH_LEVEL --os_version $OS_VERSION --pagesize $PAGESIZE \
--ramdisk $RAMDISK --ramdisk_offset $RAMDISK_OFFSET --second_offset $SECOND_OFFSET \
--tags_offset $TAGS_OFFSET -o $OUTPUT_FILE || abort
# Build zip
echo "Building zip..."
echo "-----------------------------------------------"
cp build/out/$MODEL/boot.img build/out/$MODEL/zip/files/boot.img
cp build/out/$MODEL/dtb.img build/out/$MODEL/zip/files/dtb.img
cp build/out/$MODEL/dtbo.img build/out/$MODEL/zip/files/dtbo.img
cp build/update-binary build/out/$MODEL/zip/META-INF/com/google/android/update-binary
cp build/updater-script build/out/$MODEL/zip/META-INF/com/google/android/updater-script
pushd build/out/$MODEL/zip > /dev/null
zip -r ../ExtremeKRNL-Nexus-"$MODEL".zip .
popd > /dev/null
fi
popd > /dev/null
echo "Build finished successfully!"