forked from ophub/amlogic-s9xxx-armbian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrebuild
executable file
·548 lines (471 loc) · 18.7 KB
/
rebuild
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
#!/bin/bash
#=========================================================================
# Description: Build armbian for amlogic s9xxx
# Copyright (C) 2021 https://github.com/ophub/amlogic-s9xxx-armbian
#=========================================================================
#===== Do not modify the following parameter settings, Start =====
make_path=${PWD}
armbian_outputpath=${make_path}/build/output/images
build_path=${make_path}/build-armbian
armbian_path=${build_path}/amlogic-armbian
dtb_path=${build_path}/amlogic-dtb
kernel_path=${build_path}/amlogic-kernel
uboot_path=${build_path}/amlogic-u-boot
configfiles_path=${build_path}/common-files
tmp_dir=${make_path}/tmp_dir
tmp_outpath=${tmp_dir}/tmp_out
tmp_armbian=${tmp_dir}/tmp_armbian
tmp_build=${tmp_dir}/tmp_build
tmp_aml_image=${tmp_dir}/tmp_aml_image
kernel_library="https://github.com/ophub/kernel/tree/main/pub"
#kernel_library="https://github.com/ophub/kernel/trunk/pub"
version_branch="stable"
build_armbian=("s922x" "s922x-n2" "s905x3" "s905x2" "s912" "s905d" "s905x" "s905w")
build_kernel=("default")
auto_kernel="true"
SKIP_MB=68
BOOT_MB=256
ROOT_MB=2748
#===== Do not modify the following parameter settings, End =======
die() {
echo -e " [\033[1;31m Error \033[0m] ${1}"
exit 1
}
process() {
echo -e " [\033[1;32m ${build_soc}${out_kernel} \033[0m] ${1}"
}
download_kernel() {
cd ${make_path}
# Convert kernel library address to svn format
if [[ ${kernel_library} == http* && $(echo ${kernel_library} | grep "tree/main") != "" ]]; then
kernel_library="${kernel_library//tree\/main/trunk}"
fi
kernel_library="${kernel_library}/${version_branch}"
# Set empty array
tmp_arr_kernels=()
# Convert kernel library address to API format
server_kernel_url=${kernel_library#*com\/}
server_kernel_url=${server_kernel_url//trunk/contents}
server_kernel_url="https://api.github.com/repos/${server_kernel_url}"
# Query the latest kernel in a loop
i=1
for KERNEL_VAR in ${build_kernel[*]}; do
echo -e "(${i}) Auto query the latest kernel version of the same series for [ ${KERNEL_VAR} ]"
MAIN_LINE_M=$(echo "${KERNEL_VAR}" | cut -d '.' -f1)
MAIN_LINE_V=$(echo "${KERNEL_VAR}" | cut -d '.' -f2)
MAIN_LINE_S=$(echo "${KERNEL_VAR}" | cut -d '.' -f3)
MAIN_LINE="${MAIN_LINE_M}.${MAIN_LINE_V}"
# Check the version on the server (e.g LATEST_VERSION="124")
LATEST_VERSION=$(curl -s "${server_kernel_url}" | grep "name" | grep -oE "${MAIN_LINE}.[0-9]+" | sed -e "s/${MAIN_LINE}.//g" | sort -n | sed -n '$p')
if [[ "$?" -eq "0" && ! -z "${LATEST_VERSION}" ]]; then
tmp_arr_kernels[${i}]="${MAIN_LINE}.${LATEST_VERSION}"
else
tmp_arr_kernels[${i}]="${KERNEL_VAR}"
fi
echo -e "(${i}) [ ${tmp_arr_kernels[$i]} ] is latest kernel. \n"
let i++
done
# Reset the kernel array to the latest kernel version
unset build_kernel
build_kernel=${tmp_arr_kernels[*]}
# Synchronization related kernel
i=1
for KERNEL_VAR in ${build_kernel[*]}; do
if [ ! -d "${kernel_path}/${KERNEL_VAR}" ]; then
echo -e "(${i}) [ ${KERNEL_VAR} ] Kernel loading from [ ${kernel_library}/${KERNEL_VAR} ]"
svn checkout ${kernel_library}/${KERNEL_VAR} ${kernel_path}/${KERNEL_VAR} >/dev/null
rm -rf ${kernel_path}/${KERNEL_VAR}/.svn >/dev/null && sync
else
echo -e "(${i}) [ ${KERNEL_VAR} ] Kernel is in the local directory."
fi
let i++
done
sync
}
make_image() {
cd ${make_path}
rm -rf ${tmp_dir} 2>/dev/null && sync
mkdir -p ${tmp_outpath} ${tmp_armbian} ${tmp_build} ${tmp_aml_image} && sync
# Get armbian version and release
armbian_image_name=$(ls ${armbian_outputpath}/*-trunk_*.img 2>/dev/null | awk -F "/Armbian_" '{print $2}')
out_release=$(echo ${armbian_image_name} | awk -F "buster" '{print $1}' | grep -oE '[1-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}' 2>/dev/null)
out_version=$(echo ${armbian_image_name} | awk -F "buster" '{print $NF}' | grep -oE '[1-9].[0-9]{1,3}.[0-9]{1,3}' 2>/dev/null)
[[ -n "${out_release}" && -n "${out_version}" ]] || die "Invalid file: ${armbian_outputpath}/*-trunk_*.img"
if [ -n "${new_kernel}" ]; then
make_version=${new_kernel}
else
make_version=${out_version}
fi
# Make Amlogic s9xxx armbian
build_image_file="${tmp_outpath}/Armbian_${out_release}_Aml_${build_soc}_buster_${make_version}_$(date +"%Y.%m.%d.%H%M").img"
rm -f ${build_image_file}
sync
IMG_SIZE=$((SKIP_MB + BOOT_MB + ROOT_MB))
dd if=/dev/zero of=${build_image_file} bs=1M count=${IMG_SIZE} conv=fsync >/dev/null 2>&1
sync
parted -s ${build_image_file} mklabel msdos 2>/dev/null
parted -s ${build_image_file} mkpart primary fat32 $((SKIP_MB))M $((SKIP_MB + BOOT_MB - 1))M 2>/dev/null
parted -s ${build_image_file} mkpart primary ext4 $((SKIP_MB + BOOT_MB))M 100% 2>/dev/null
sync
loop_new=$(losetup -P -f --show "${build_image_file}")
[ ${loop_new} ] || die "losetup ${build_image_file} failed."
mkfs.vfat -n "BOOT" ${loop_new}p1 >/dev/null 2>&1
mke2fs -F -q -t ext4 -L "ROOTFS" -m 0 ${loop_new}p2 >/dev/null 2>&1
sync
}
extract_armbian() {
cd ${make_path}
armbian_image_file="${tmp_aml_image}/armbian_${build_soc}_${make_version}.img"
rm -f ${armbian_image_file} 2>/dev/null && sync
cp -f $(ls ${armbian_outputpath}/*-trunk_*.img 2>/dev/null | head -n 1) ${armbian_image_file}
sync && sleep 3
loop_old=$(losetup -P -f --show "${armbian_image_file}")
[ ${loop_old} ] || die "losetup ${armbian_image_file} failed."
if ! mount ${loop_old}p1 ${tmp_armbian}; then
die "mount ${loop_old}p1 failed!"
fi
cd ${tmp_armbian}
# Delete soft link (ln -sf TrueFile Link)
rm -rf bin lib sbin tmp var/sbin
sync
}
replace_kernel() {
# Replace if specified
if [[ ! "${build_kernel[*]}" =~ "default" ]]; then
cd ${make_path}
build_boot=$(ls ${kernel_path}/${new_kernel}/boot-${new_kernel}-*.tar.gz 2>/dev/null | head -n 1)
build_dtb=$(ls ${kernel_path}/${new_kernel}/dtb-amlogic-${new_kernel}-*.tar.gz 2>/dev/null | head -n 1)
build_modules=$(ls ${kernel_path}/${new_kernel}/modules-${new_kernel}-*.tar.gz 2>/dev/null | head -n 1)
build_header=$(ls ${kernel_path}/${new_kernel}/header-${new_kernel}-*.tar.gz 2>/dev/null | head -n 1)
# 01 For /boot five files
(cd ${tmp_armbian}/boot && rm -rf *-${out_version}-* uInitrd zImage dtb* 2>/dev/null && sync)
tar -xzf ${build_boot} -C ${tmp_armbian}/boot && sync
[ "$(ls ${tmp_armbian}/boot/*-${new_kernel}-* -l 2>/dev/null | grep "^-" | wc -l)" -ge "4" ] || die "boot/ 5 files is missing."
# 02 For dtb files
mkdir -p ${tmp_armbian}/boot/dtb/amlogic && sync
tar -xzf ${build_dtb} -C ${tmp_armbian}/boot/dtb/amlogic && sync
# 03 For usr/lib/modules/*
(cd ${tmp_armbian}/usr/lib/modules && rm -rf * 2>/dev/null && sync)
tar -xzf ${build_modules} -C ${tmp_armbian}/usr/lib/modules && sync
(cd ${tmp_armbian}/usr/lib/modules/*/ && echo "build source" | xargs rm -f && sync)
if [ "$(ls ${tmp_armbian}/usr/lib/modules/${new_kernel}* -l 2>/dev/null | grep "^d" | wc -l)" -ne "1" ]; then
die "${tmp_armbian}/usr/lib/modules/${new_kernel}-* kernel folder is missing."
fi
# 04 For header files, usr/local/include
if [[ -n "${build_header}" && -f "${build_header}" ]]; then
rm -rf ${tmp_armbian}/usr/local/include/* 2>/dev/null && sync
tar -xzf ${build_header} -C ${tmp_armbian}/usr/local && sync
fi
sync
fi
}
copy_files() {
cd ${tmp_armbian}
#Check if writing to EMMC is supported
MODULES_NOW=$(ls usr/lib/modules/ 2>/dev/null)
VERSION_NOW=$(echo ${MODULES_NOW} | grep -oE '^[1-9].[0-9]{1,3}' 2>/dev/null)
#echo -e "This Kernel [ ${VERSION_NOW} ]"
k510_ver=$(echo "${VERSION_NOW}" | cut -d '.' -f1)
k510_maj=$(echo "${VERSION_NOW}" | cut -d '.' -f2)
if [ "${k510_ver}" -eq "5" ]; then
if [ "${k510_maj}" -ge "10" ]; then
K510="1"
else
K510="0"
fi
elif [ "${k510_ver}" -gt "5" ]; then
K510="1"
else
K510="0"
fi
#echo -e "K510: [ ${K510} ]"
case "${build_soc}" in
s905x3 | x96 | hk1 | h96 | ugoosx3)
FDTFILE="meson-sm1-x96-max-plus-100m.dtb"
UBOOT_OVERLOAD="u-boot-x96maxplus.bin"
MAINLINE_UBOOT="/lib/u-boot/x96maxplus-u-boot.bin.sd.bin"
ANDROID_UBOOT="/lib/u-boot/hk1box-bootloader.img"
AMLOGIC_SOC="s905x3"
;;
s905x2 | x96max4g | x96max2g)
FDTFILE="meson-g12a-x96-max.dtb"
UBOOT_OVERLOAD="u-boot-x96max.bin"
MAINLINE_UBOOT="/lib/u-boot/x96max-u-boot.bin.sd.bin"
ANDROID_UBOOT=""
AMLOGIC_SOC="s905x2"
;;
s905x | hg680p | b860h)
FDTFILE="meson-gxl-s905x-p212.dtb"
UBOOT_OVERLOAD="u-boot-p212.bin"
MAINLINE_UBOOT=""
ANDROID_UBOOT=""
AMLOGIC_SOC="s905x"
;;
s905w | x96mini | tx3mini)
FDTFILE="meson-gxl-s905w-tx3-mini.dtb"
UBOOT_OVERLOAD="u-boot-s905x-s912.bin"
MAINLINE_UBOOT=""
ANDROID_UBOOT=""
AMLOGIC_SOC="s905w"
;;
s905d | n1)
FDTFILE="meson-gxl-s905d-phicomm-n1.dtb"
UBOOT_OVERLOAD="u-boot-n1.bin"
MAINLINE_UBOOT=""
ANDROID_UBOOT="/lib/u-boot/u-boot-2015-phicomm-n1.bin"
AMLOGIC_SOC="s905d"
;;
s912 | h96proplus | octopus)
FDTFILE="meson-gxm-octopus-planet.dtb"
UBOOT_OVERLOAD="u-boot-zyxq.bin"
MAINLINE_UBOOT=""
ANDROID_UBOOT=""
AMLOGIC_SOC="s912"
;;
s912-t95z | s912-t95z-plus)
FDTFILE="meson-gxm-t95z-plus.dtb"
UBOOT_OVERLOAD="u-boot-s905x-s912.bin"
MAINLINE_UBOOT=""
ANDROID_UBOOT=""
AMLOGIC_SOC="s912"
;;
s922x | belink | belinkpro | ugoos)
FDTFILE="meson-g12b-gtking-pro.dtb"
UBOOT_OVERLOAD="u-boot-gtkingpro.bin"
MAINLINE_UBOOT="/lib/u-boot/gtkingpro-u-boot.bin.sd.bin"
ANDROID_UBOOT=""
AMLOGIC_SOC="s922x"
;;
s922x-n2 | odroid-n2 | n2)
FDTFILE="meson-g12b-gtking-pro-rev_a.dtb"
UBOOT_OVERLOAD="u-boot-odroid-n2.bin"
MAINLINE_UBOOT="/lib/u-boot/odroid-n2-u-boot.bin.sd.bin"
ANDROID_UBOOT=""
AMLOGIC_SOC="s922x"
;;
*)
die "Have no this soc: [ ${build_soc} ]"
;;
esac
cd ${make_path}
# Write the specified bootloader
if [[ "${MAINLINE_UBOOT}" != "" && -f "${tag_rootfs}/usr${MAINLINE_UBOOT}" ]]; then
dd if=${tag_rootfs}/usr${MAINLINE_UBOOT} of=${loop_new} bs=1 count=444 conv=fsync 2>/dev/null
dd if=${tag_rootfs}/usr${MAINLINE_UBOOT} of=${loop_new} bs=512 skip=1 seek=1 conv=fsync 2>/dev/null
#echo -e "For [ ${build_soc} ] write Mainline bootloader: ${MAINLINE_UBOOT}"
elif [[ "${ANDROID_UBOOT}" != "" && -f "${tag_rootfs}/usr${ANDROID_UBOOT}" ]]; then
dd if=${tag_rootfs}/usr${ANDROID_UBOOT} of=${loop_new} bs=1 count=444 conv=fsync 2>/dev/null
dd if=${tag_rootfs}/usr${ANDROID_UBOOT} of=${loop_new} bs=512 skip=1 seek=1 conv=fsync 2>/dev/null
#echo -e "For [ ${build_soc} ] write Android bootloader: ${ANDROID_UBOOT}"
fi
sync
# Reorganize the /boot partition
mkdir -p ${tmp_build}/boot
# Copy the original boot core file
cp -rf ${tmp_armbian}/boot/*-${make_version}-* ${tmp_build}/boot && sync
(cd ${tmp_build}/boot && cp -f uInitrd-* uInitrd && cp -f vmlinuz-* zImage && chmod +x * && sync)
# Unzip the relevant files
tar -xzf "${armbian_path}/boot-common.tar.gz" -C ${tmp_build}/boot
tar -xzf "${armbian_path}/root-common.tar.gz" -C ${tmp_armbian}
# Complete the u-boot file to facilitate the booting of the 5.10+ kernel
cp -f ${uboot_path}/* ${tmp_build}/boot && sync
# Complete the dtb file
cp -rf ${dtb_path}/* ${tmp_build}/boot/dtb/amlogic && sync
cp -rf ${tmp_armbian}/boot/dtb/amlogic/* ${tmp_build}/boot/dtb/amlogic && sync
chmod +x ${tmp_build}/boot/dtb/amlogic/*
# Create a dual-partition general directory
tag_bootfs="${tmp_outpath}/bootfs"
tag_rootfs="${tmp_outpath}/rootfs"
mkdir -p ${tag_bootfs} ${tag_rootfs} && sync
if ! mount ${loop_new}p2 ${tag_rootfs}; then
die "mount ${loop_new}p2 failed!"
fi
if ! mount ${loop_new}p1 ${tag_bootfs}; then
die "mount ${loop_new}p1 failed!"
fi
# Copy boot files
cp -rf ${tmp_build}/boot/* ${tag_bootfs} && sync
# Copy rootfs files
rm -rf ${tmp_armbian}/boot/* 2>/dev/null
cp -rf ${tmp_armbian}/* ${tag_rootfs} && sync
# Complete file for ${root}: [ /etc ], [ /usr/lib/u-boot ] etc.
if [ "$(ls ${configfiles_path}/files 2>/dev/null | wc -w)" -ne "0" ]; then
cp -rf ${configfiles_path}/files/* ${tag_rootfs} && sync
fi
cd ${tag_bootfs}
# Add u-boot.ext for 5.10 kernel
if [[ -n "${UBOOT_OVERLOAD}" && -f "${UBOOT_OVERLOAD}" ]]; then
cp -f ${UBOOT_OVERLOAD} u-boot.ext && sync
chmod +x u-boot.ext
fi
# Edit the uEnv.txt
if [ ! -f "uEnv.txt" ]; then
die "The uEnv.txt File does not exist"
else
old_fdt_dtb="meson-gxl-s905d-phicomm-n1.dtb"
sed -i "s/${old_fdt_dtb}/${FDTFILE}/g" uEnv.txt
fi
# For s912-t95z-plus /boot/extlinux/extlinux.conf
[ "${FDTFILE}" == "meson-gxm-t95z-plus.dtb" ] && cp -rf ${configfiles_path}/patches/boot/s912-t95z-plus/* .
sync
cd ${tag_rootfs}
# Replace the boot directory with the latest file
rm -rf boot/* 2>/dev/null && sync
(cd usr/lib/firmware && mv *.hcd brcm/)
# Add soft connection
ln -sf usr/bin bin
ln -sf usr/lib lib
ln -sf usr/sbin sbin
ln -sf var/tmp tmp
ln -sf usr/share/zoneinfo/Asia/Shanghai etc/localtime
chmod 777 var/tmp
chown man:root var/cache/man -R
chmod g+s var/cache/man -R
chown root:root usr/bin/sudo
chmod 4755 usr/bin/sudo
chown 0 usr/lib/sudo/sudoers.so
chmod 644 usr/lib/sudo/sudoers.so
chmod 4755 usr/lib/policykit-1/polkit-agent-helper-1
# Delete related files
rm -f etc/apt/sources.list.save 2>/dev/null
rm -f etc/apt/*.gpg~ 2>/dev/null
rm -f etc/systemd/system/basic.target.wants/armbian-resize-filesystem.service 2>/dev/null
rm -f var/lib/dpkg/info/linux-image* 2>/dev/null
# Add firmware information to the etc/armbian-aml-release
echo "FDTFILE='${FDTFILE}'" >>etc/armbian-aml-release 2>/dev/null
echo "U_BOOT_EXT='${K510}'" >>etc/armbian-aml-release 2>/dev/null
echo "UBOOT_OVERLOAD='${UBOOT_OVERLOAD}'" >>etc/armbian-aml-release 2>/dev/null
echo "MAINLINE_UBOOT='${MAINLINE_UBOOT}'" >>etc/armbian-aml-release 2>/dev/null
echo "ANDROID_UBOOT='${ANDROID_UBOOT}'" >>etc/armbian-aml-release 2>/dev/null
echo "KERNEL_VERSION='${KERNEL_VERSION}'" >>etc/armbian-aml-release 2>/dev/null
echo "SOC='${AMLOGIC_SOC}'" >>etc/armbian-aml-release 2>/dev/null
echo "K510='${K510}'" >>etc/armbian-aml-release 2>/dev/null
echo "PACKAGED_DATE='$(date +%Y-%m-%d)'" >>etc/armbian-aml-release 2>/dev/null
# Custom banner name
sed -i "s|BOARD_NAME=.*|BOARD_NAME=\"Aml ${AMLOGIC_SOC}\"|g" etc/armbian-release
sync
cd ${make_path}
umount -f ${tmp_armbian} 2>/dev/null
umount -f ${tag_rootfs} 2>/dev/null
umount -f ${tag_bootfs} 2>/dev/null
losetup -D 2>/dev/null
sync
}
clean_tmp() {
cd ${tmp_outpath}
gzip *.img && sync && mv -f *.img.gz ${armbian_outputpath}
sync
cd ${make_path}
rm -rf ${tmp_dir} 2>/dev/null
sync
}
while [ "${1}" ]; do
case "${1}" in
-d | --default)
: ${version_branch:="${version_branch}"}
: ${build_armbian:="${build_armbian}"}
: ${build_kernel:="${build_kernel}"}
: ${ROOT_MB:="${ROOT_MB}"}
;;
-b | --build)
if [ -n "${2}" ]; then
unset build_armbian
oldIFS=$IFS
IFS=_
build_armbian=(${2})
IFS=$oldIFS
shift
else
die "Invalid -b parameter [ ${2} ]!"
fi
;;
-k | --kernel)
if [ -n "${2}" ]; then
oldIFS=$IFS
IFS=_
build_kernel=(${2})
IFS=$oldIFS
shift
else
die "Invalid -k parameter [ ${2} ]!"
fi
;;
-a | --autokernel)
if [ -n "${2}" ]; then
auto_kernel="${2}"
shift
else
die "Invalid -a parameter [ ${2} ]!"
fi
;;
-v | --versionbranch)
if [ -n "${2}" ]; then
version_branch="${2}"
shift
else
die "Invalid -v parameter [ ${2} ]!"
fi
;;
-s | --size)
if [[ -n "${2}" && "${2}" -ge "1000" ]]; then
ROOT_MB="${2}"
shift
else
die "Invalid -s parameter [ ${2} ]!"
fi
;;
*)
die "Invalid option [ ${1} ]!"
;;
esac
shift
done
# Set whether to replace the kernel
[ "${auto_kernel}" == "true" ] && download_kernel
[ $(id -u) = 0 ] || die "please run this script as root: [ sudo ./$0 ]"
echo -e "Welcome to build armbian for amlogic s9xxx STB! \n"
echo -e "Server space usage before starting to compile: \n$(df -hT ${PWD}) \n"
echo -e "Armbian SoC List: [ $(echo ${build_armbian[*]} | tr "\n" " ") ]"
echo -e "Kernel List: [ $(echo ${build_kernel[*]} | tr "\n" " ") ]"
echo -e "Ready, start build armbian... \n"
# Start loop compilation
k=1
for b in ${build_armbian[*]}; do
i=1
for x in ${build_kernel[*]}; do
{
echo -n "(${k}.${i}) Start build armbian [ ${b} - ${x} ]. "
now_remaining_space=$(df -hT ${PWD} | grep '/dev/' | awk '{print $5}' | sed 's/.$//')
if [[ "${now_remaining_space}" -le "2" ]]; then
echo "Remaining space is less than 2G, exit this packaging. \n"
break
else
echo "Remaining space is ${now_remaining_space}G."
fi
build_soc="${b}"
if [ "${x}" == "default" ]; then
new_kernel=""
out_kernel=""
else
new_kernel="${x}"
out_kernel=" - ${x}"
fi
process " (1/5) make new armbian image."
make_image
process " (2/5) extract old armbian files."
extract_armbian
process " (3/5) replace kernel for armbian."
replace_kernel
process " (4/5) copy files to new image."
copy_files
process " (5/5) clear temp files."
clean_tmp
echo -e "(${k}.${i}) Build successfully. \n"
let i++
}
done
let k++
done
echo -e "Server space usage after compilation: \n$(df -hT ${PWD}) \n"
sync
exit 0