Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
orangepi-xunlong
GitHub Repository: orangepi-xunlong/orangepi-build
Path: blob/next/scripts/main.sh
22121 views
1
#!/bin/bash
2
#
3
# Copyright (c) 2013-2021 Igor Pecovnik, igor.pecovnik@gma**.com
4
#
5
# This file is licensed under the terms of the GNU General Public
6
# License version 2. This program is licensed "as is" without any
7
# warranty of any kind, whether express or implied.
8
#
9
# Main program
10
#
11
12
13
cleanup_list() {
14
local varname="${1}"
15
local list_to_clean="${!varname}"
16
list_to_clean="${list_to_clean#"${list_to_clean%%[![:space:]]*}"}"
17
list_to_clean="${list_to_clean%"${list_to_clean##*[![:space:]]}"}"
18
echo ${list_to_clean}
19
}
20
21
22
23
24
if [[ $(basename "$0") == main.sh ]]; then
25
26
echo "Please use build.sh to start the build process"
27
exit 255
28
29
fi
30
31
32
33
34
# default umask for root is 022 so parent directories won't be group writeable without this
35
# this is used instead of making the chmod in prepare_host() recursive
36
umask 002
37
38
# destination
39
if [ -d "$CONFIG_PATH/output" ]; then
40
DEST="${CONFIG_PATH}"/output
41
else
42
DEST="${SRC}"/output
43
fi
44
45
[[ -z $REVISION ]] && REVISION="3.0.8"
46
47
[[ $DOWNLOAD_MIRROR == "china" ]] && NTP_SERVER="cn.pool.ntp.org"
48
49
if [[ $BUILD_ALL != "yes" ]]; then
50
# override stty size
51
[[ -n $COLUMNS ]] && stty cols $COLUMNS
52
[[ -n $LINES ]] && stty rows $LINES
53
TTY_X=$(($(stty size | awk '{print $2}')-6)) # determine terminal width
54
TTY_Y=$(($(stty size | awk '{print $1}')-6)) # determine terminal height
55
fi
56
57
# We'll use this title on all menus
58
backtitle="Orange Pi building script, http://www.orangepi.org"
59
titlestr="Choose an option"
60
61
# Warnings mitigation
62
[[ -z $LANGUAGE ]] && export LANGUAGE="en_US:en" # set to english if not set
63
[[ -z $CONSOLE_CHAR ]] && export CONSOLE_CHAR="UTF-8" # set console to UTF-8 if not set
64
65
# Libraries include
66
67
# shellcheck source=debootstrap.sh
68
source "${SRC}"/scripts/debootstrap.sh # system specific install
69
# shellcheck source=image-helpers.sh
70
source "${SRC}"/scripts/image-helpers.sh # helpers for OS image building
71
# shellcheck source=distributions.sh
72
source "${SRC}"/scripts/distributions.sh # system specific install
73
# shellcheck source=desktop.sh
74
source "${SRC}"/scripts/desktop.sh # desktop specific install
75
# shellcheck source=compilation.sh
76
source "${SRC}"/scripts/compilation.sh # patching and compilation of kernel, uboot, ATF
77
# shellcheck source=compilation-prepare.sh
78
#source "${SRC}"/scripts/compilation-prepare.sh # drivers that are not upstreamed
79
# shellcheck source=makeboarddeb.sh
80
source "${SRC}"/scripts/makeboarddeb.sh # board support package
81
# shellcheck source=general.sh
82
source "${SRC}"/scripts/general.sh # general functions
83
# shellcheck source=chroot-buildpackages.sh
84
source "${SRC}"/scripts/chroot-buildpackages.sh # chroot packages building
85
# shellcheck source=pack.sh
86
source "${SRC}"/scripts/pack-uboot.sh
87
# shellcheck source=build-cix-image.sh
88
source "${SRC}"/scripts/build-cix-image.sh
89
90
91
# set log path
92
LOG_SUBPATH=${LOG_SUBPATH:=debug}
93
94
# compress and remove old logs
95
mkdir -p "${DEST}"/${LOG_SUBPATH}
96
(cd "${DEST}"/${LOG_SUBPATH} && tar -czf logs-"$(<timestamp)".tgz ./*.log) > /dev/null 2>&1
97
rm -f "${DEST}"/${LOG_SUBPATH}/*.log > /dev/null 2>&1
98
date +"%d_%m_%Y-%H_%M_%S" > "${DEST}"/${LOG_SUBPATH}/timestamp
99
100
# delete compressed logs older than 7 days
101
(cd "${DEST}"/${LOG_SUBPATH} && find . -name '*.tgz' -mtime +7 -delete) > /dev/null
102
103
if [[ $PROGRESS_DISPLAY == none ]]; then
104
105
OUTPUT_VERYSILENT=yes
106
107
elif [[ $PROGRESS_DISPLAY == dialog ]]; then
108
109
OUTPUT_DIALOG=yes
110
111
fi
112
113
if [[ $PROGRESS_LOG_TO_FILE != yes ]]; then unset PROGRESS_LOG_TO_FILE; fi
114
115
116
117
SHOW_WARNING=yes
118
119
120
121
if [[ $USE_CCACHE != no ]]; then
122
123
CCACHE=ccache
124
export PATH="/usr/lib/ccache:$PATH"
125
# private ccache directory to avoid permission issues when using build script with "sudo"
126
# see https://ccache.samba.org/manual.html#_sharing_a_cache for alternative solution
127
[[ $PRIVATE_CCACHE == yes ]] && export CCACHE_DIR=$EXTER/cache/ccache
128
129
else
130
131
CCACHE=""
132
133
fi
134
135
136
137
138
if [[ -n $REPOSITORY_UPDATE ]]; then
139
140
# select stable/beta configuration
141
if [[ $BETA == yes ]]; then
142
DEB_STORAGE=$DEST/debs-beta
143
REPO_STORAGE=$DEST/repository-beta
144
REPO_CONFIG="aptly-beta.conf"
145
else
146
DEB_STORAGE=$DEST/debs
147
REPO_STORAGE=$DEST/repository
148
REPO_CONFIG="aptly.conf"
149
fi
150
151
# For user override
152
if [[ -f "${USERPATCHES_PATH}"/lib.config ]]; then
153
display_alert "Using user configuration override" "userpatches/lib.config" "info"
154
source "${USERPATCHES_PATH}"/lib.config
155
fi
156
157
repo-manipulate "$REPOSITORY_UPDATE"
158
exit
159
160
fi
161
162
163
164
165
if [[ -z $BOARD ]]; then
166
167
#options+=("orangepir1" "Allwinner H2+ quad core 256MB RAM WiFi SPI 2xETH")
168
#options+=("orangepizero" "Allwinner H2+ quad core 256MB/512MB RAM WiFi SPI")
169
#options+=("orangepipc" "Allwinner H3 quad core 1GB RAM")
170
#options+=("orangepipcplus" "Allwinner H3 quad core 1GB RAM WiFi eMMC")
171
#options+=("orangepione" "Allwinner H3 quad core 512MB RAM")
172
#options+=("orangepilite" "Allwinner H3 quad core 512MB RAM WiFi")
173
#options+=("orangepiplus" "Allwinner H3 quad core 1GB/2GB RAM WiFi GBE eMMC")
174
#options+=("orangepiplus2e" "Allwinner H3 quad core 2GB RAM WiFi GBE eMMC")
175
#options+=("orangepizeroplus2h3" "Allwinner H3 quad core 512MB RAM WiFi/BT eMMC")
176
#options+=("orangepipch5" "Allwinner H5 quad core 1GB RAM")
177
#options+=("orangepipc2" "Allwinner H5 quad core 1GB RAM GBE SPI")
178
#options+=("orangepioneh5" "Allwinner H5 quad core 512MB/1GB RAM")
179
#options+=("orangepiprime" "Allwinner H5 quad core 2GB RAM GBE WiFi/BT")
180
#options+=("orangepizeroplus" "Allwinner H5 quad core 512MB RAM GBE WiFi SPI")
181
#options+=("orangepizeroplus2h5" "Allwinner H5 quad core 512MB RAM WiFi/BT eMMC")
182
options+=("orangepi3" "Allwinner H6 quad core 1GB/2GB RAM GBE WiFi/BT eMMC USB3")
183
options+=("orangepi3-lts" "Allwinner H6 quad core 2GB RAM GBE WiFi/BT-AW859A eMMC USB3")
184
#options+=("orangepilite2" "Allwinner H6 quad core 1GB RAM WiFi/BT USB3")
185
#options+=("orangepioneplus" "Allwinner H6 quad core 1GB RAM GBE")
186
options+=("orangepizero2" "Allwinner H616 quad core 512MB/1GB RAM WiFi/BT GBE SPI")
187
#options+=("orangepizero2-b" "Allwinner H616 quad core 512MB/1GB RAM WiFi/BT GBE SPI")
188
#options+=("orangepizero2-lts" "Allwinner H616 quad core 1.5GB RAM WiFi/BT GBE SPI")
189
options+=("orangepizero3" "Allwinner H618 quad core 1GB/1.5GB/2GB/4GB RAM WiFi/BT GBE SPI")
190
options+=("orangepizero2w" "Allwinner H618 quad core 1GB/1.5GB/2GB/4GB RAM WiFi/BT SPI")
191
options+=("orangepizero3w" "Allwinner H618 quad core 1GB/1.5GB/2GB/4GB RAM WiFi/BT SPI")
192
#options+=("orangepizero3plus" "Allwinner H618 quad core 1GB/1.5GB/2GB/4GB RAM WiFi/BT GBE eMMC")
193
#options+=("orangepir1b" "Allwinner H618 quad core 1.5GB/2GB/4GB RAM WiFi/BT GBE SPI")
194
#options+=("orangepi400" "Allwinner H616 quad core 4GB RAM WiFi/BT GBE eMMC VGA")
195
options+=("orangepi4" "Rockchip RK3399 hexa core 4GB RAM GBE eMMC USB3 USB-C WiFi/BT")
196
options+=("orangepi4a" "Allwinner T527 octa core 2-4GB RAM GBE WiFi/BT NVMe eMMC")
197
options+=("orangepi4-lts" "Rockchip RK3399 hexa core 4GB RAM GBE eMMC USB3 USB-C WiFi/BT")
198
#options+=("aipcliteb" "Allwinner T736 octa core 2-4GB RAM GBE WiFi/BT NVMe")
199
options+=("orangepi4pro" "Allwinner A733 octa core 4-16GB RAM GBE USB3 WiFi/BT NVMe eMMC")
200
options+=("orangepi800" "Rockchip RK3399 hexa core 4GB RAM GBE eMMC USB3 USB-C WiFi/BT VGA")
201
options+=("orangepi5" "Rockchip RK3588S octa core 4-16GB RAM GBE USB3 USB-C NVMe")
202
options+=("orangepicm5" "Rockchip RK3588S octa core 4-16GB RAM GBE USB3 USB-C")
203
options+=("orangepicm5-tablet" "Rockchip RK3588S octa core 4-16GB RAM USB3 USB-C WiFi/BT")
204
options+=("orangepi5b" "Rockchip RK3588S octa core 4-16GB RAM GBE USB3 USB-C WiFi/BT eMMC")
205
#options+=("orangepitab" "Rockchip RK3588S octa core 4-16GB RAM USB-C WiFi/BT NVMe")
206
#options+=("orangepi900" "Rockchip RK3588 octa core 4-16GB RAM 2.5GBE USB3 USB-C WiFi/BT NVMe")
207
options+=("orangepi5pro" "Rockchip RK3588S octa core 4-16GB RAM GBE USB3 WiFi/BT NVMe eMMC")
208
options+=("orangepi5max" "Rockchip RK3588 octa core 4-16GB RAM 2.5GBE USB3 WiFi/BT NVMe eMMC")
209
options+=("orangepi5ultra" "Rockchip RK3588 octa core 4-16GB RAM 2.5GBE USB3 WiFi/BT NVMe eMMC")
210
options+=("orangepi5plus" "Rockchip RK3588 octa core 4-32GB RAM 2.5GBE USB3 USB-C WiFi/BT NVMe eMMC")
211
options+=("orangepicm4" "Rockchip RK3566 quad core 2-8GB RAM GBE eMMC USB3 NvMe WiFi/BT")
212
options+=("orangepi3b" "Rockchip RK3566 quad core 2-8GB RAM GBE eMMC USB3 NvMe WiFi/BT")
213
options+=("orangepi6plus" "Cix P1 12-core 16-64GB RAM 5GBE USB3 USB-C WiFi/BT NVMe")
214
options+=("orangepirv" "Starfive JH7110 quad core 2-8GB RAM GBE USB3 NvMe WiFi/BT")
215
options+=("orangepirv2" "Ky X1 octa core 2-8GB RAM GBE USB3 WiFi/BT NVMe eMMC")
216
options+=("orangepir2s" "Ky X1 octa core 2-8GB RAM 2.5GBE USB3 eMMC")
217
#options+=("orangepir1plus" "Rockchip RK3328 quad core 1GB RAM 2xGBE USB2 SPI")
218
#options+=("orangepi3plus" "Amlogic S905D3 quad core 2/4GB RAM SoC eMMC GBE USB3 SPI WiFi/BT")
219
220
menustr="Please choose a Board."
221
BOARD=$(whiptail --title "${titlestr}" --backtitle "${backtitle}" \
222
--menu "${menustr}" "${TTY_Y}" "${TTY_X}" $((TTY_Y - 8)) \
223
--cancel-button Exit --ok-button Select "${options[@]}" \
224
3>&1 1>&2 2>&3)
225
226
unset options
227
[[ -z $BOARD ]] && exit_with_error "No option selected"
228
fi
229
230
BOARD_TYPE="conf"
231
# shellcheck source=/dev/null
232
source "${EXTER}/config/boards/${BOARD}.${BOARD_TYPE}"
233
LINUXFAMILY="${BOARDFAMILY}"
234
235
[[ -z $KERNEL_TARGET ]] && exit_with_error "Board configuration does not define valid kernel config"
236
237
# if BUILD_OPT, KERNEL_CONFIGURE, BOARD, BRANCH or RELEASE are not set, display selection menu
238
if [[ -z $BUILD_OPT ]]; then
239
240
if [[ $BOARDFAMILY != "cix" ]]; then
241
options+=("u-boot" "U-boot package")
242
fi
243
options+=("kernel" "Kernel package")
244
options+=("rootfs" "Rootfs and all deb packages")
245
options+=("image" "Full OS image for flashing")
246
247
if [[ $BOARDFAMILY != "cix" ]]; then
248
menustr="Compile image | rootfs | kernel | u-boot"
249
else
250
menustr="Compile image | rootfs | kernel"
251
fi
252
BUILD_OPT=$(whiptail --title "${titlestr}" --backtitle "${backtitle}" --notags \
253
--menu "${menustr}" "${TTY_Y}" "${TTY_X}" $((TTY_Y - 8)) \
254
--cancel-button Exit --ok-button Select "${options[@]}" \
255
3>&1 1>&2 2>&3)
256
257
unset options
258
[[ -z $BUILD_OPT ]] && exit_with_error "No option selected"
259
[[ $BUILD_OPT == rootfs ]] && ROOT_FS_CREATE_ONLY="yes"
260
fi
261
262
263
264
265
if [[ ${BUILD_OPT} =~ kernel|image ]]; then
266
267
if [[ -z $KERNEL_CONFIGURE ]]; then
268
269
options+=("no" "Do not change the kernel configuration")
270
options+=("yes" "Show a kernel configuration menu before compilation")
271
272
menustr="Select the kernel configuration."
273
KERNEL_CONFIGURE=$(whiptail --title "${titlestr}" --backtitle "$backtitle" --notags \
274
--menu "${menustr}" $TTY_Y $TTY_X $((TTY_Y - 8)) \
275
--cancel-button Exit --ok-button Select "${options[@]}" \
276
3>&1 1>&2 2>&3)
277
278
unset options
279
[[ -z $KERNEL_CONFIGURE ]] && exit_with_error "No option selected"
280
fi
281
fi
282
283
284
285
286
if [[ -z $BRANCH ]]; then
287
288
options=()
289
[[ $KERNEL_TARGET == *current* ]] && options+=("current" "Recommended. Come with best support")
290
[[ $KERNEL_TARGET == *legacy* ]] && options+=("legacy" "Old stable / Legacy")
291
[[ $KERNEL_TARGET == *next* ]] && options+=("next" "Use the latest kernel")
292
293
menustr="Select the target kernel branch\nExact kernel versions depend on selected board"
294
# do not display selection dialog if only one kernel branch is available
295
if [[ "${#options[@]}" == 2 ]]; then
296
BRANCH="${options[0]}"
297
else
298
BRANCH=$(whiptail --title "${titlestr}" --backtitle "${backtitle}" \
299
--menu "${menustr}" "${TTY_Y}" "${TTY_X}" $((TTY_Y - 8)) \
300
--cancel-button Exit --ok-button Select "${options[@]}" \
301
3>&1 1>&2 2>&3)
302
fi
303
unset options
304
[[ -z $BRANCH ]] && exit_with_error "No kernel branch selected"
305
[[ $BRANCH == dev && $SHOW_WARNING == yes ]] && show_developer_warning
306
307
fi
308
309
if [[ $BUILD_OPT =~ rootfs|image && -z $RELEASE ]]; then
310
311
options=()
312
313
distros_options
314
315
menustr="Select the target OS release package base"
316
RELEASE=$(whiptail --title "Choose a release package base" --backtitle "${backtitle}" \
317
--menu "${menustr}" "${TTY_Y}" "${TTY_X}" $((TTY_Y - 8)) \
318
--cancel-button Exit --ok-button Select "${options[@]}" \
319
3>&1 1>&2 2>&3)
320
#echo "options : ${options}"
321
[[ -z $RELEASE ]] && exit_with_error "No release selected"
322
323
unset options
324
fi
325
326
# don't show desktop option if we choose minimal build
327
[[ $BUILD_MINIMAL == yes ]] && BUILD_DESKTOP=no
328
329
if [[ $BUILD_OPT =~ rootfs|image && -z $BUILD_DESKTOP ]]; then
330
331
# read distribution support status which is written to the orangepi-release file
332
set_distribution_status
333
334
options=()
335
options+=("no" "Image with console interface (server)")
336
options+=("yes" "Image with desktop environment")
337
338
menustr="Select the target image type"
339
BUILD_DESKTOP=$(whiptail --title "Choose image type" --backtitle "${backtitle}" \
340
--menu "${menustr}" "${TTY_Y}" "${TTY_X}" $((TTY_Y - 8)) \
341
--cancel-button Exit --ok-button Select "${options[@]}" \
342
3>&1 1>&2 2>&3)
343
unset options
344
[[ -z $BUILD_DESKTOP ]] && exit_with_error "No option selected"
345
if [[ ${BUILD_DESKTOP} == "yes" ]]; then
346
BUILD_MINIMAL=no
347
SELECTED_CONFIGURATION="desktop"
348
fi
349
350
fi
351
352
if [[ $BUILD_OPT =~ rootfs|image && $BUILD_DESKTOP == no && -z $BUILD_MINIMAL ]]; then
353
354
options=()
355
options+=("no" "Standard image with console interface")
356
options+=("yes" "Minimal image with console interface")
357
menustr="Select the target image type"
358
BUILD_MINIMAL=$(whiptail --title "Choose image type" --backtitle "${backtitle}" \
359
--menu "${menustr}" "${TTY_Y}" "${TTY_X}" $((TTY_Y - 8)) \
360
--cancel-button Exit --ok-button Select "${options[@]}" \
361
3>&1 1>&2 2>&3)
362
unset options
363
[[ -z $BUILD_MINIMAL ]] && exit_with_error "No option selected"
364
if [[ $BUILD_MINIMAL == "yes" ]]; then
365
SELECTED_CONFIGURATION="cli_minimal"
366
else
367
SELECTED_CONFIGURATION="cli_standard"
368
fi
369
370
fi
371
372
#prevent conflicting setup
373
if [[ $BUILD_DESKTOP == "yes" ]]; then
374
BUILD_MINIMAL=no
375
SELECTED_CONFIGURATION="desktop"
376
elif [[ $BUILD_MINIMAL != "yes" || -z "${BUILD_MINIMAL}" ]]; then
377
BUILD_MINIMAL=no # Just in case BUILD_MINIMAL is not defined
378
BUILD_DESKTOP=no
379
SELECTED_CONFIGURATION="cli_standard"
380
elif [[ $BUILD_MINIMAL == "yes" ]]; then
381
BUILD_DESKTOP=no
382
SELECTED_CONFIGURATION="cli_minimal"
383
fi
384
385
#[[ ${KERNEL_CONFIGURE} == prebuilt ]] && [[ -z ${REPOSITORY_INSTALL} ]] && \
386
#REPOSITORY_INSTALL="u-boot,kernel,bsp,orangepi-zsh,orangepi-config,orangepi-firmware${BUILD_DESKTOP:+,orangepi-desktop}"
387
388
389
#shellcheck source=configuration.sh
390
source "${SRC}"/scripts/configuration.sh
391
392
# optimize build time with 100% CPU usage
393
CPUS=$(grep -c 'processor' /proc/cpuinfo)
394
if [[ $USEALLCORES != no ]]; then
395
396
CTHREADS="-j$((CPUS + CPUS/2))"
397
398
else
399
400
CTHREADS="-j1"
401
402
fi
403
404
call_extension_method "post_determine_cthreads" "config_post_determine_cthreads" << 'POST_DETERMINE_CTHREADS'
405
*give config a chance modify CTHREADS programatically. A build server may work better with hyperthreads-1 for example.*
406
Called early, before any compilation work starts.
407
POST_DETERMINE_CTHREADS
408
409
if [[ $BETA == yes ]]; then
410
IMAGE_TYPE=nightly
411
elif [[ $BETA != "yes" && $BUILD_ALL == yes && -n $GPG_PASS ]]; then
412
IMAGE_TYPE=stable
413
else
414
IMAGE_TYPE=user-built
415
fi
416
417
branch2dir() {
418
[[ "${1}" == "head" ]] && echo "HEAD" || echo "${1##*:}"
419
}
420
421
BOOTSOURCEDIR="${BOOTDIR}/$(branch2dir "${BOOTBRANCH}")"
422
LINUXSOURCEDIR="${KERNELDIR}/$(branch2dir "${KERNELBRANCH}")"
423
[[ -n $ATFSOURCE ]] && ATFSOURCEDIR="${ATFDIR}/$(branch2dir "${ATFBRANCH}")"
424
425
BSP_CLI_PACKAGE_NAME="orangepi-bsp-cli-${BOARD}"
426
BSP_CLI_PACKAGE_FULLNAME="${BSP_CLI_PACKAGE_NAME}_${REVISION}_${ARCH}"
427
BSP_DESKTOP_PACKAGE_NAME="orangepi-bsp-desktop-${BOARD}"
428
BSP_DESKTOP_PACKAGE_FULLNAME="${BSP_DESKTOP_PACKAGE_NAME}_${REVISION}_${ARCH}"
429
430
CHOSEN_UBOOT=linux-u-boot-${BRANCH}-${BOARD}
431
CHOSEN_KERNEL=linux-image-${BRANCH}-${LINUXFAMILY}
432
CHOSEN_ROOTFS=${BSP_CLI_PACKAGE_NAME}
433
CHOSEN_DESKTOP=orangepi-${RELEASE}-desktop-${DESKTOP_ENVIRONMENT}
434
CHOSEN_KSRC=linux-source-${BRANCH}-${LINUXFAMILY}
435
436
do_default() {
437
438
start=$(date +%s)
439
440
# Check and install dependencies, directory structure and settings
441
# The OFFLINE_WORK variable inside the function
442
prepare_host
443
444
[[ "${JUST_INIT}" == "yes" ]] && exit 0
445
446
[[ $CLEAN_LEVEL == *sources* ]] && cleaning "sources"
447
448
# fetch_from_repo <url> <dir> <ref> <subdir_flag>
449
450
# ignore updates help on building all images - for internal purposes
451
if [[ ${IGNORE_UPDATES} != yes ]]; then
452
453
display_alert "Downloading sources" "" "info"
454
455
if [[ $BOARDFAMILY != "cix" ]]; then
456
457
[[ $BUILD_OPT =~ u-boot|image ]] && fetch_from_repo "$BOOTSOURCE" "$BOOTDIR" "$BOOTBRANCH" "yes"
458
459
fi
460
461
if [[ $BOARDFAMILY == "cix" ]]; then
462
463
if [[ ${GITEE_SERVER} == yes ]]; then
464
fetch_from_repo "https://gitee.com/orangepi-xunlong/component_cix-$BRANCH.git" "${EXTER}/cache/sources/component_cix-$BRANCH" "branch:main"
465
466
if [[ ! -f "${EXTER}/cache/sources/component_cix-$BRANCH/debs/cix-npu-onnxruntime_1.1.0_arm64.deb" ]]; then
467
display_alert "Downloading deb" "cix-npu-onnxruntime" "info"
468
wget -c -t 5 -P "${EXTER}/cache/sources/component_cix-$BRANCH/debs/" \
469
http://www.iplaystore.cn/upload/debs/cix-npu-onnxruntime_1.1.0_arm64.deb
470
fi
471
else
472
fetch_from_repo "https://github.com/orangepi-xunlong/component_cix-$BRANCH.git" "${EXTER}/cache/sources/component_cix-$BRANCH" "branch:main"
473
474
if [[ ! -f "${EXTER}/cache/sources/component_cix-$BRANCH/debs/cix-npu-onnxruntime_1.1.0_arm64.deb" ]]; then
475
display_alert "Downloading deb" "cix-npu-onnxruntime" "info"
476
wget -c -t 5 -P "${EXTER}/cache/sources/component_cix-$BRANCH/debs/" \
477
https://github.com/orangepi-xunlong/component_cix-${BRANCH}/releases/download/v1.1.0/cix-npu-onnxruntime_1.1.0_arm64.deb
478
fi
479
fi
480
481
fi
482
483
[[ $BUILD_OPT =~ kernel|image ]] && fetch_from_repo "$KERNELSOURCE" "$KERNELDIR" "$KERNELBRANCH" "yes"
484
485
if [[ -n ${ATFSOURCE} ]]; then
486
487
[[ ${BUILD_OPT} =~ u-boot|image ]] && fetch_from_repo "$ATFSOURCE" "${EXTER}/cache/sources/$ATFDIR" "$ATFBRANCH" "yes"
488
489
fi
490
491
if [[ ${BOARD} =~ orangepi4|orangepi4-lts|orangepi800 && $BRANCH == legacy ]]; then
492
493
[[ $BUILD_OPT =~ image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk3399_gst_xserver_libs.git" "${EXTER}/cache/sources/rk3399_gst_xserver_libs" "branch:main"
494
495
fi
496
497
if [[ ${BOARD} =~ orangepiaimax ]]; then
498
499
[[ $BUILD_OPT =~ image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/ascend-driver.git" "${EXTER}/cache/sources/ascend-driver" "branch:main"
500
501
fi
502
503
if [[ "${BOARD}x" =~ orangepi4x|orangepi4-ltsx|orangepi800x && $RELEASE =~ focal|buster|bullseye|bookworm ]]; then
504
505
[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/rk-rootfs-build-${RELEASE}" "branch:rk-rootfs-build-${RELEASE}"
506
[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/rk35xx_packages" "branch:rk35xx_packages"
507
508
fi
509
510
if [[ ${BOARDFAMILY} == "rockchip-rk3588" && $RELEASE =~ bullseye|bookworm|focal|jammy|raspi ]]; then
511
512
[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/rk35xx_packages" "branch:rk35xx_packages"
513
514
fi
515
516
if [[ ${BOARDFAMILY} == "rockchip-rk356x" && $RELEASE =~ bullseye|focal|jammy|raspi ]]; then
517
518
[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/rk35xx_packages" "branch:rk35xx_packages"
519
520
fi
521
522
if [[ ${BOARDFAMILY} == "ky" && $RELEASE =~ noble ]]; then
523
524
[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/ky_packages" "branch:ky_packages"
525
526
fi
527
528
if [[ ${BOARDFAMILY} == "sun55iw3" && $RELEASE =~ bookworm|jammy ]]; then
529
530
[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/t527_packages" "branch:t527_packages"
531
532
fi
533
534
if [[ ${BOARDFAMILY} == "sun60iw2" && $RELEASE =~ bullseye ]]; then
535
if [[ ${GITEE_SERVER} == yes ]]; then
536
[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://gitee.com/orangepi-xunlong/sun60iw2_packages.git" "${EXTER}/cache/sources/sun60iw2_packages" "branch:sun60iw2_packages"
537
else
538
[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/sun60iw2_packages" "branch:sun60iw2_packages"
539
fi
540
fi
541
542
if [[ ${BOARD} =~ orangepi3|orangepi3-lts && $RELEASE =~ bullseye && $BRANCH == current ]]; then
543
544
[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/ffmpeg_kodi_${RELEASE}" "branch:ffmpeg_kodi_${RELEASE}"
545
546
fi
547
548
if [[ "${BOARD}x" =~ orangepi4x|orangepi4-ltsx|orangepi800x && $RELEASE =~ jammy && $BRANCH == next ]]; then
549
550
[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/ffmpeg_kodi_${RELEASE}" "branch:ffmpeg_kodi_${RELEASE}"
551
552
fi
553
554
call_extension_method "fetch_sources_tools" <<- 'FETCH_SOURCES_TOOLS'
555
*fetch host-side sources needed for tools and build*
556
Run early to fetch_from_repo or otherwise obtain sources for needed tools.
557
FETCH_SOURCES_TOOLS
558
559
call_extension_method "build_host_tools" <<- 'BUILD_HOST_TOOLS'
560
*build needed tools for the build, host-side*
561
After sources are fetched, build host-side tools needed for the build.
562
BUILD_HOST_TOOLS
563
fi
564
565
for option in $(tr ',' ' ' <<< "$CLEAN_LEVEL"); do
566
[[ $option != sources ]] && cleaning "$option"
567
done
568
569
# Compile u-boot if packed .deb does not exist or use the one from Orange Pi
570
if [[ $BUILD_OPT == u-boot || $BUILD_OPT == image ]]; then
571
572
if [[ $BOARDFAMILY != "cix" ]]; then
573
if [[ ! -f "${DEB_STORAGE}"/u-boot/${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb ]]; then
574
575
[[ -n "${ATFSOURCE}" && "${REPOSITORY_INSTALL}" != *u-boot* ]] && compile_atf
576
577
[[ ${REPOSITORY_INSTALL} != *u-boot* ]] && compile_uboot
578
fi
579
580
if [[ $BUILD_OPT == "u-boot" ]]; then
581
unset BUILD_MINIMAL BUILD_DESKTOP COMPRESS_OUTPUTIMAGE
582
display_alert "U-boot build done" "@host" "info"
583
display_alert "Target directory" "${DEB_STORAGE}/u-boot" "info"
584
display_alert "File name" "${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb" "info"
585
fi
586
fi
587
fi
588
589
# Compile kernel if packed .deb does not exist or use the one from Orange Pi
590
if [[ $BUILD_OPT == kernel || $BUILD_OPT == image ]]; then
591
592
if [[ ! -f ${DEB_STORAGE}/${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb ]]; then
593
594
KDEB_CHANGELOG_DIST=$RELEASE
595
[[ "${REPOSITORY_INSTALL}" != *kernel* ]] && compile_kernel
596
fi
597
598
if [[ $BUILD_OPT == "kernel" ]]; then
599
unset BUILD_MINIMAL BUILD_DESKTOP COMPRESS_OUTPUTIMAGE
600
display_alert "Kernel build done" "@host" "info"
601
display_alert "Target directory" "${DEB_STORAGE}/" "info"
602
display_alert "File name" "${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb" "info"
603
fi
604
fi
605
606
if [[ $BUILD_OPT == rootfs || $BUILD_OPT == image ]]; then
607
608
# Compile orangepi-config if packed .deb does not exist or use the one from Orange Pi
609
if [[ ! -f ${DEB_STORAGE}/orangepi-config_${REVISION}_all.deb ]]; then
610
611
[[ "${REPOSITORY_INSTALL}" != *orangepi-config* ]] && compile_orangepi-config
612
fi
613
614
# Compile orangepi-zsh if packed .deb does not exist or use the one from repository
615
if [[ ! -f ${DEB_STORAGE}/orangepi-zsh_${REVISION}_all.deb ]]; then
616
617
[[ "${REPOSITORY_INSTALL}" != *orangepi-zsh* ]] && compile_orangepi-zsh
618
fi
619
620
# Compile plymouth-theme-orangepi if packed .deb does not exist or use the one from repository
621
if [[ ! -f ${DEB_STORAGE}/plymouth-theme-orangepi_${REVISION}_all.deb && $PLYMOUTH == yes ]]; then
622
623
[[ "${REPOSITORY_INSTALL}" != *plymouth-theme-orangepi* ]] && compile_plymouth-theme-orangepi
624
fi
625
626
# Compile orangepi-firmware if packed .deb does not exist or use the one from repository
627
if [[ "${REPOSITORY_INSTALL}" != *orangepi-firmware* ]]; then
628
629
if ! ls "${DEB_STORAGE}/orangepi-firmware_${REVISION}_all.deb" 1> /dev/null 2>&1; then
630
631
FULL=""
632
REPLACE="-full"
633
compile_firmware
634
635
fi
636
637
#if ! ls "${DEB_STORAGE}/orangepi-firmware-full_${REVISION}_all.deb" 1> /dev/null 2>&1; then
638
639
#FULL="-full"
640
#REPLACE=""
641
#compile_firmware
642
643
#fi
644
645
fi
646
647
overlayfs_wrapper "cleanup"
648
649
# create board support package
650
[[ -n $RELEASE && ! -f ${DEB_STORAGE}/$RELEASE/${BSP_CLI_PACKAGE_FULLNAME}.deb ]] && create_board_package
651
652
# create desktop package
653
#[[ -n $RELEASE && $DESKTOP_ENVIRONMENT && ! -f ${DEB_STORAGE}/$RELEASE/${CHOSEN_DESKTOP}_${REVISION}_all.deb ]] && create_desktop_package
654
#[[ -n $RELEASE && $DESKTOP_ENVIRONMENT && ! -f ${DEB_STORAGE}/${RELEASE}/${BSP_DESKTOP_PACKAGE_FULLNAME}.deb ]] && create_bsp_desktop_package
655
[[ -n $RELEASE && $DESKTOP_ENVIRONMENT ]] && create_desktop_package
656
[[ -n $RELEASE && $DESKTOP_ENVIRONMENT ]] && create_bsp_desktop_package
657
658
# build additional packages
659
[[ $EXTERNAL_NEW == compile ]] && chroot_build_packages
660
661
[[ $BSP_BUILD != yes ]] && debootstrap_ng
662
663
fi
664
665
# hook for function to run after build, i.e. to change owner of $SRC
666
# NOTE: this will run only if there were no errors during build process
667
[[ $(type -t run_after_build) == function ]] && run_after_build || true
668
669
end=$(date +%s)
670
runtime=$(((end-start)/60))
671
display_alert "Runtime" "$runtime min" "info"
672
673
# Make it easy to repeat build by displaying build options used
674
[ "$(systemd-detect-virt)" == 'docker' ] && BUILD_CONFIG='docker'
675
676
display_alert "Repeat Build Options" "sudo ./build.sh ${BUILD_CONFIG} BOARD=${BOARD} BRANCH=${BRANCH} \
677
$([[ -n $BUILD_OPT ]] && echo "BUILD_OPT=${BUILD_OPT} ")\
678
$([[ -n $RELEASE ]] && echo "RELEASE=${RELEASE} ")\
679
$([[ -n $BUILD_MINIMAL ]] && echo "BUILD_MINIMAL=${BUILD_MINIMAL} ")\
680
$([[ -n $BUILD_DESKTOP ]] && echo "BUILD_DESKTOP=${BUILD_DESKTOP} ")\
681
$([[ -n $KERNEL_CONFIGURE ]] && echo "KERNEL_CONFIGURE=${KERNEL_CONFIGURE} ")\
682
$([[ -n $DESKTOP_ENVIRONMENT ]] && echo "DESKTOP_ENVIRONMENT=${DESKTOP_ENVIRONMENT} ")\
683
$([[ -n $DESKTOP_ENVIRONMENT_CONFIG_NAME ]] && echo "DESKTOP_ENVIRONMENT_CONFIG_NAME=${DESKTOP_ENVIRONMENT_CONFIG_NAME} ")\
684
$([[ -n $DESKTOP_APPGROUPS_SELECTED ]] && echo "DESKTOP_APPGROUPS_SELECTED=\"${DESKTOP_APPGROUPS_SELECTED}\" ")\
685
$([[ -n $DESKTOP_APT_FLAGS_SELECTED ]] && echo "DESKTOP_APT_FLAGS_SELECTED=\"${DESKTOP_APT_FLAGS_SELECTED}\" ")\
686
$([[ -n $COMPRESS_OUTPUTIMAGE ]] && echo "COMPRESS_OUTPUTIMAGE=${COMPRESS_OUTPUTIMAGE} ")\
687
" "ext"
688
689
} # end of do_default()
690
691
if [[ -z $1 ]]; then
692
do_default
693
else
694
eval "$@"
695
fi
696
697