Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
orangepi-xunlong
GitHub Repository: orangepi-xunlong/orangepi-build
Path: blob/next/scripts/main.sh
17896 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+=("orangepizero3plus" "Allwinner H618 quad core 1GB/1.5GB/2GB/4GB RAM WiFi/BT GBE eMMC")
192
#options+=("orangepir1b" "Allwinner H618 quad core 1.5GB/2GB/4GB RAM WiFi/BT GBE SPI")
193
#options+=("orangepi400" "Allwinner H616 quad core 4GB RAM WiFi/BT GBE eMMC VGA")
194
options+=("orangepi4" "Rockchip RK3399 hexa core 4GB RAM GBE eMMC USB3 USB-C WiFi/BT")
195
options+=("orangepi4a" "Allwinner T527 octa core 2-4GB RAM GBE WiFi/BT NVMe eMMC")
196
options+=("orangepi4-lts" "Rockchip RK3399 hexa core 4GB RAM GBE eMMC USB3 USB-C WiFi/BT")
197
#options+=("aipcliteb" "Allwinner T736 octa core 2-4GB RAM GBE WiFi/BT NVMe")
198
options+=("orangepi4pro" "Allwinner A733 octa core 4-16GB RAM GBE USB3 WiFi/BT NVMe eMMC")
199
options+=("orangepi800" "Rockchip RK3399 hexa core 4GB RAM GBE eMMC USB3 USB-C WiFi/BT VGA")
200
options+=("orangepi5" "Rockchip RK3588S octa core 4-16GB RAM GBE USB3 USB-C NVMe")
201
options+=("orangepicm5" "Rockchip RK3588S octa core 4-16GB RAM GBE USB3 USB-C")
202
options+=("orangepicm5-tablet" "Rockchip RK3588S octa core 4-16GB RAM USB3 USB-C WiFi/BT")
203
options+=("orangepi5b" "Rockchip RK3588S octa core 4-16GB RAM GBE USB3 USB-C WiFi/BT eMMC")
204
#options+=("orangepitab" "Rockchip RK3588S octa core 4-16GB RAM USB-C WiFi/BT NVMe")
205
#options+=("orangepi900" "Rockchip RK3588 octa core 4-16GB RAM 2.5GBE USB3 USB-C WiFi/BT NVMe")
206
options+=("orangepi5pro" "Rockchip RK3588S octa core 4-16GB RAM GBE USB3 WiFi/BT NVMe eMMC")
207
options+=("orangepi5max" "Rockchip RK3588 octa core 4-16GB RAM 2.5GBE USB3 WiFi/BT NVMe eMMC")
208
options+=("orangepi5ultra" "Rockchip RK3588 octa core 4-16GB RAM 2.5GBE USB3 WiFi/BT NVMe eMMC")
209
options+=("orangepi5plus" "Rockchip RK3588 octa core 4-32GB RAM 2.5GBE USB3 USB-C WiFi/BT NVMe eMMC")
210
options+=("orangepicm4" "Rockchip RK3566 quad core 2-8GB RAM GBE eMMC USB3 NvMe WiFi/BT")
211
options+=("orangepi3b" "Rockchip RK3566 quad core 2-8GB RAM GBE eMMC USB3 NvMe WiFi/BT")
212
options+=("orangepi6plus" "Cix P1 12-core 16-64GB RAM 5GBE USB3 USB-C WiFi/BT NVMe")
213
options+=("orangepirv" "Starfive JH7110 quad core 2-8GB RAM GBE USB3 NvMe WiFi/BT")
214
options+=("orangepirv2" "Ky X1 octa core 2-8GB RAM GBE USB3 WiFi/BT NVMe eMMC")
215
#options+=("orangepir2s" "Ky X1 octa core 2-8GB RAM 2.5GBE USB3 eMMC")
216
#options+=("orangepir1plus" "Rockchip RK3328 quad core 1GB RAM 2xGBE USB2 SPI")
217
#options+=("orangepi3plus" "Amlogic S905D3 quad core 2/4GB RAM SoC eMMC GBE USB3 SPI WiFi/BT")
218
219
menustr="Please choose a Board."
220
BOARD=$(whiptail --title "${titlestr}" --backtitle "${backtitle}" \
221
--menu "${menustr}" "${TTY_Y}" "${TTY_X}" $((TTY_Y - 8)) \
222
--cancel-button Exit --ok-button Select "${options[@]}" \
223
3>&1 1>&2 2>&3)
224
225
unset options
226
[[ -z $BOARD ]] && exit_with_error "No option selected"
227
fi
228
229
BOARD_TYPE="conf"
230
# shellcheck source=/dev/null
231
source "${EXTER}/config/boards/${BOARD}.${BOARD_TYPE}"
232
LINUXFAMILY="${BOARDFAMILY}"
233
234
[[ -z $KERNEL_TARGET ]] && exit_with_error "Board configuration does not define valid kernel config"
235
236
# if BUILD_OPT, KERNEL_CONFIGURE, BOARD, BRANCH or RELEASE are not set, display selection menu
237
if [[ -z $BUILD_OPT ]]; then
238
239
if [[ $BOARDFAMILY != "cix" ]]; then
240
options+=("u-boot" "U-boot package")
241
fi
242
options+=("kernel" "Kernel package")
243
options+=("rootfs" "Rootfs and all deb packages")
244
options+=("image" "Full OS image for flashing")
245
246
if [[ $BOARDFAMILY != "cix" ]]; then
247
menustr="Compile image | rootfs | kernel | u-boot"
248
else
249
menustr="Compile image | rootfs | kernel"
250
fi
251
BUILD_OPT=$(whiptail --title "${titlestr}" --backtitle "${backtitle}" --notags \
252
--menu "${menustr}" "${TTY_Y}" "${TTY_X}" $((TTY_Y - 8)) \
253
--cancel-button Exit --ok-button Select "${options[@]}" \
254
3>&1 1>&2 2>&3)
255
256
unset options
257
[[ -z $BUILD_OPT ]] && exit_with_error "No option selected"
258
[[ $BUILD_OPT == rootfs ]] && ROOT_FS_CREATE_ONLY="yes"
259
fi
260
261
262
263
264
if [[ ${BUILD_OPT} =~ kernel|image ]]; then
265
266
if [[ -z $KERNEL_CONFIGURE ]]; then
267
268
options+=("no" "Do not change the kernel configuration")
269
options+=("yes" "Show a kernel configuration menu before compilation")
270
271
menustr="Select the kernel configuration."
272
KERNEL_CONFIGURE=$(whiptail --title "${titlestr}" --backtitle "$backtitle" --notags \
273
--menu "${menustr}" $TTY_Y $TTY_X $((TTY_Y - 8)) \
274
--cancel-button Exit --ok-button Select "${options[@]}" \
275
3>&1 1>&2 2>&3)
276
277
unset options
278
[[ -z $KERNEL_CONFIGURE ]] && exit_with_error "No option selected"
279
fi
280
fi
281
282
283
284
285
if [[ -z $BRANCH ]]; then
286
287
options=()
288
[[ $KERNEL_TARGET == *current* ]] && options+=("current" "Recommended. Come with best support")
289
[[ $KERNEL_TARGET == *legacy* ]] && options+=("legacy" "Old stable / Legacy")
290
[[ $KERNEL_TARGET == *next* ]] && options+=("next" "Use the latest kernel")
291
292
menustr="Select the target kernel branch\nExact kernel versions depend on selected board"
293
# do not display selection dialog if only one kernel branch is available
294
if [[ "${#options[@]}" == 2 ]]; then
295
BRANCH="${options[0]}"
296
else
297
BRANCH=$(whiptail --title "${titlestr}" --backtitle "${backtitle}" \
298
--menu "${menustr}" "${TTY_Y}" "${TTY_X}" $((TTY_Y - 8)) \
299
--cancel-button Exit --ok-button Select "${options[@]}" \
300
3>&1 1>&2 2>&3)
301
fi
302
unset options
303
[[ -z $BRANCH ]] && exit_with_error "No kernel branch selected"
304
[[ $BRANCH == dev && $SHOW_WARNING == yes ]] && show_developer_warning
305
306
fi
307
308
if [[ $BUILD_OPT =~ rootfs|image && -z $RELEASE ]]; then
309
310
options=()
311
312
distros_options
313
314
menustr="Select the target OS release package base"
315
RELEASE=$(whiptail --title "Choose a release package base" --backtitle "${backtitle}" \
316
--menu "${menustr}" "${TTY_Y}" "${TTY_X}" $((TTY_Y - 8)) \
317
--cancel-button Exit --ok-button Select "${options[@]}" \
318
3>&1 1>&2 2>&3)
319
#echo "options : ${options}"
320
[[ -z $RELEASE ]] && exit_with_error "No release selected"
321
322
unset options
323
fi
324
325
# don't show desktop option if we choose minimal build
326
[[ $BUILD_MINIMAL == yes ]] && BUILD_DESKTOP=no
327
328
if [[ $BUILD_OPT =~ rootfs|image && -z $BUILD_DESKTOP ]]; then
329
330
# read distribution support status which is written to the orangepi-release file
331
set_distribution_status
332
333
options=()
334
options+=("no" "Image with console interface (server)")
335
options+=("yes" "Image with desktop environment")
336
337
menustr="Select the target image type"
338
BUILD_DESKTOP=$(whiptail --title "Choose image type" --backtitle "${backtitle}" \
339
--menu "${menustr}" "${TTY_Y}" "${TTY_X}" $((TTY_Y - 8)) \
340
--cancel-button Exit --ok-button Select "${options[@]}" \
341
3>&1 1>&2 2>&3)
342
unset options
343
[[ -z $BUILD_DESKTOP ]] && exit_with_error "No option selected"
344
if [[ ${BUILD_DESKTOP} == "yes" ]]; then
345
BUILD_MINIMAL=no
346
SELECTED_CONFIGURATION="desktop"
347
fi
348
349
fi
350
351
if [[ $BUILD_OPT =~ rootfs|image && $BUILD_DESKTOP == no && -z $BUILD_MINIMAL ]]; then
352
353
options=()
354
options+=("no" "Standard image with console interface")
355
options+=("yes" "Minimal image with console interface")
356
menustr="Select the target image type"
357
BUILD_MINIMAL=$(whiptail --title "Choose image type" --backtitle "${backtitle}" \
358
--menu "${menustr}" "${TTY_Y}" "${TTY_X}" $((TTY_Y - 8)) \
359
--cancel-button Exit --ok-button Select "${options[@]}" \
360
3>&1 1>&2 2>&3)
361
unset options
362
[[ -z $BUILD_MINIMAL ]] && exit_with_error "No option selected"
363
if [[ $BUILD_MINIMAL == "yes" ]]; then
364
SELECTED_CONFIGURATION="cli_minimal"
365
else
366
SELECTED_CONFIGURATION="cli_standard"
367
fi
368
369
fi
370
371
#prevent conflicting setup
372
if [[ $BUILD_DESKTOP == "yes" ]]; then
373
BUILD_MINIMAL=no
374
SELECTED_CONFIGURATION="desktop"
375
elif [[ $BUILD_MINIMAL != "yes" || -z "${BUILD_MINIMAL}" ]]; then
376
BUILD_MINIMAL=no # Just in case BUILD_MINIMAL is not defined
377
BUILD_DESKTOP=no
378
SELECTED_CONFIGURATION="cli_standard"
379
elif [[ $BUILD_MINIMAL == "yes" ]]; then
380
BUILD_DESKTOP=no
381
SELECTED_CONFIGURATION="cli_minimal"
382
fi
383
384
#[[ ${KERNEL_CONFIGURE} == prebuilt ]] && [[ -z ${REPOSITORY_INSTALL} ]] && \
385
#REPOSITORY_INSTALL="u-boot,kernel,bsp,orangepi-zsh,orangepi-config,orangepi-firmware${BUILD_DESKTOP:+,orangepi-desktop}"
386
387
388
#shellcheck source=configuration.sh
389
source "${SRC}"/scripts/configuration.sh
390
391
# optimize build time with 100% CPU usage
392
CPUS=$(grep -c 'processor' /proc/cpuinfo)
393
if [[ $USEALLCORES != no ]]; then
394
395
CTHREADS="-j$((CPUS + CPUS/2))"
396
397
else
398
399
CTHREADS="-j1"
400
401
fi
402
403
call_extension_method "post_determine_cthreads" "config_post_determine_cthreads" << 'POST_DETERMINE_CTHREADS'
404
*give config a chance modify CTHREADS programatically. A build server may work better with hyperthreads-1 for example.*
405
Called early, before any compilation work starts.
406
POST_DETERMINE_CTHREADS
407
408
if [[ $BETA == yes ]]; then
409
IMAGE_TYPE=nightly
410
elif [[ $BETA != "yes" && $BUILD_ALL == yes && -n $GPG_PASS ]]; then
411
IMAGE_TYPE=stable
412
else
413
IMAGE_TYPE=user-built
414
fi
415
416
branch2dir() {
417
[[ "${1}" == "head" ]] && echo "HEAD" || echo "${1##*:}"
418
}
419
420
BOOTSOURCEDIR="${BOOTDIR}/$(branch2dir "${BOOTBRANCH}")"
421
LINUXSOURCEDIR="${KERNELDIR}/$(branch2dir "${KERNELBRANCH}")"
422
[[ -n $ATFSOURCE ]] && ATFSOURCEDIR="${ATFDIR}/$(branch2dir "${ATFBRANCH}")"
423
424
BSP_CLI_PACKAGE_NAME="orangepi-bsp-cli-${BOARD}"
425
BSP_CLI_PACKAGE_FULLNAME="${BSP_CLI_PACKAGE_NAME}_${REVISION}_${ARCH}"
426
BSP_DESKTOP_PACKAGE_NAME="orangepi-bsp-desktop-${BOARD}"
427
BSP_DESKTOP_PACKAGE_FULLNAME="${BSP_DESKTOP_PACKAGE_NAME}_${REVISION}_${ARCH}"
428
429
CHOSEN_UBOOT=linux-u-boot-${BRANCH}-${BOARD}
430
CHOSEN_KERNEL=linux-image-${BRANCH}-${LINUXFAMILY}
431
CHOSEN_ROOTFS=${BSP_CLI_PACKAGE_NAME}
432
CHOSEN_DESKTOP=orangepi-${RELEASE}-desktop-${DESKTOP_ENVIRONMENT}
433
CHOSEN_KSRC=linux-source-${BRANCH}-${LINUXFAMILY}
434
435
do_default() {
436
437
start=$(date +%s)
438
439
# Check and install dependencies, directory structure and settings
440
# The OFFLINE_WORK variable inside the function
441
prepare_host
442
443
[[ "${JUST_INIT}" == "yes" ]] && exit 0
444
445
[[ $CLEAN_LEVEL == *sources* ]] && cleaning "sources"
446
447
# fetch_from_repo <url> <dir> <ref> <subdir_flag>
448
449
# ignore updates help on building all images - for internal purposes
450
if [[ ${IGNORE_UPDATES} != yes ]]; then
451
452
display_alert "Downloading sources" "" "info"
453
454
if [[ $BOARDFAMILY != "cix" ]]; then
455
456
[[ $BUILD_OPT =~ u-boot|image ]] && fetch_from_repo "$BOOTSOURCE" "$BOOTDIR" "$BOOTBRANCH" "yes"
457
458
fi
459
460
if [[ $BOARDFAMILY == "cix" ]]; then
461
462
fetch_from_repo "https://github.com/orangepi-xunlong/component_cix-$BRANCH.git" "${EXTER}/cache/sources/component_cix-$BRANCH" "branch:main"
463
464
fi
465
466
[[ $BUILD_OPT =~ kernel|image ]] && fetch_from_repo "$KERNELSOURCE" "$KERNELDIR" "$KERNELBRANCH" "yes"
467
468
if [[ -n ${ATFSOURCE} ]]; then
469
470
[[ ${BUILD_OPT} =~ u-boot|image ]] && fetch_from_repo "$ATFSOURCE" "${EXTER}/cache/sources/$ATFDIR" "$ATFBRANCH" "yes"
471
472
fi
473
474
if [[ ${BOARD} =~ orangepi4|orangepi4-lts|orangepi800 && $BRANCH == legacy ]]; then
475
476
[[ $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"
477
478
fi
479
480
if [[ ${BOARD} =~ orangepiaimax ]]; then
481
482
[[ $BUILD_OPT =~ image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/ascend-driver.git" "${EXTER}/cache/sources/ascend-driver" "branch:main"
483
484
fi
485
486
if [[ "${BOARD}x" =~ orangepi4x|orangepi4-ltsx|orangepi800x && $RELEASE =~ focal|buster|bullseye|bookworm ]]; then
487
488
[[ ${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}"
489
[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/rk35xx_packages" "branch:rk35xx_packages"
490
491
fi
492
493
if [[ ${BOARDFAMILY} == "rockchip-rk3588" && $RELEASE =~ bullseye|bookworm|focal|jammy|raspi ]]; then
494
495
[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/rk35xx_packages" "branch:rk35xx_packages"
496
497
fi
498
499
if [[ ${BOARDFAMILY} == "rockchip-rk356x" && $RELEASE =~ bullseye|focal|jammy|raspi ]]; then
500
501
[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/rk35xx_packages" "branch:rk35xx_packages"
502
503
fi
504
505
if [[ ${BOARDFAMILY} == "ky" && $RELEASE =~ noble ]]; then
506
507
[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/ky_packages" "branch:ky_packages"
508
509
fi
510
511
if [[ ${BOARDFAMILY} == "sun55iw3" && $RELEASE =~ bookworm|jammy ]]; then
512
513
[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/t527_packages" "branch:t527_packages"
514
515
fi
516
517
if [[ ${BOARDFAMILY} == "sun60iw2" && $RELEASE =~ bullseye ]]; then
518
if [[ ${GITEE_SERVER} == yes ]]; then
519
[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://gitee.com/orangepi-xunlong/sun60iw2_packages.git" "${EXTER}/cache/sources/sun60iw2_packages" "branch:sun60iw2_packages"
520
else
521
[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/sun60iw2_packages" "branch:sun60iw2_packages"
522
fi
523
fi
524
525
if [[ ${BOARD} =~ orangepi3|orangepi3-lts && $RELEASE =~ bullseye && $BRANCH == current ]]; then
526
527
[[ ${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}"
528
529
fi
530
531
if [[ "${BOARD}x" =~ orangepi4x|orangepi4-ltsx|orangepi800x && $RELEASE =~ jammy && $BRANCH == next ]]; then
532
533
[[ ${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}"
534
535
fi
536
537
call_extension_method "fetch_sources_tools" <<- 'FETCH_SOURCES_TOOLS'
538
*fetch host-side sources needed for tools and build*
539
Run early to fetch_from_repo or otherwise obtain sources for needed tools.
540
FETCH_SOURCES_TOOLS
541
542
call_extension_method "build_host_tools" <<- 'BUILD_HOST_TOOLS'
543
*build needed tools for the build, host-side*
544
After sources are fetched, build host-side tools needed for the build.
545
BUILD_HOST_TOOLS
546
fi
547
548
for option in $(tr ',' ' ' <<< "$CLEAN_LEVEL"); do
549
[[ $option != sources ]] && cleaning "$option"
550
done
551
552
# Compile u-boot if packed .deb does not exist or use the one from Orange Pi
553
if [[ $BUILD_OPT == u-boot || $BUILD_OPT == image ]]; then
554
555
if [[ $BOARDFAMILY != "cix" ]]; then
556
if [[ ! -f "${DEB_STORAGE}"/u-boot/${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb ]]; then
557
558
[[ -n "${ATFSOURCE}" && "${REPOSITORY_INSTALL}" != *u-boot* ]] && compile_atf
559
560
[[ ${REPOSITORY_INSTALL} != *u-boot* ]] && compile_uboot
561
fi
562
563
if [[ $BUILD_OPT == "u-boot" ]]; then
564
unset BUILD_MINIMAL BUILD_DESKTOP COMPRESS_OUTPUTIMAGE
565
display_alert "U-boot build done" "@host" "info"
566
display_alert "Target directory" "${DEB_STORAGE}/u-boot" "info"
567
display_alert "File name" "${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb" "info"
568
fi
569
fi
570
fi
571
572
# Compile kernel if packed .deb does not exist or use the one from Orange Pi
573
if [[ $BUILD_OPT == kernel || $BUILD_OPT == image ]]; then
574
575
if [[ ! -f ${DEB_STORAGE}/${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb ]]; then
576
577
KDEB_CHANGELOG_DIST=$RELEASE
578
[[ "${REPOSITORY_INSTALL}" != *kernel* ]] && compile_kernel
579
fi
580
581
if [[ $BUILD_OPT == "kernel" ]]; then
582
unset BUILD_MINIMAL BUILD_DESKTOP COMPRESS_OUTPUTIMAGE
583
display_alert "Kernel build done" "@host" "info"
584
display_alert "Target directory" "${DEB_STORAGE}/" "info"
585
display_alert "File name" "${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb" "info"
586
fi
587
fi
588
589
if [[ $BUILD_OPT == rootfs || $BUILD_OPT == image ]]; then
590
591
# Compile orangepi-config if packed .deb does not exist or use the one from Orange Pi
592
if [[ ! -f ${DEB_STORAGE}/orangepi-config_${REVISION}_all.deb ]]; then
593
594
[[ "${REPOSITORY_INSTALL}" != *orangepi-config* ]] && compile_orangepi-config
595
fi
596
597
# Compile orangepi-zsh if packed .deb does not exist or use the one from repository
598
if [[ ! -f ${DEB_STORAGE}/orangepi-zsh_${REVISION}_all.deb ]]; then
599
600
[[ "${REPOSITORY_INSTALL}" != *orangepi-zsh* ]] && compile_orangepi-zsh
601
fi
602
603
# Compile plymouth-theme-orangepi if packed .deb does not exist or use the one from repository
604
if [[ ! -f ${DEB_STORAGE}/plymouth-theme-orangepi_${REVISION}_all.deb && $PLYMOUTH == yes ]]; then
605
606
[[ "${REPOSITORY_INSTALL}" != *plymouth-theme-orangepi* ]] && compile_plymouth-theme-orangepi
607
fi
608
609
# Compile orangepi-firmware if packed .deb does not exist or use the one from repository
610
if [[ "${REPOSITORY_INSTALL}" != *orangepi-firmware* ]]; then
611
612
if ! ls "${DEB_STORAGE}/orangepi-firmware_${REVISION}_all.deb" 1> /dev/null 2>&1; then
613
614
FULL=""
615
REPLACE="-full"
616
compile_firmware
617
618
fi
619
620
#if ! ls "${DEB_STORAGE}/orangepi-firmware-full_${REVISION}_all.deb" 1> /dev/null 2>&1; then
621
622
#FULL="-full"
623
#REPLACE=""
624
#compile_firmware
625
626
#fi
627
628
fi
629
630
overlayfs_wrapper "cleanup"
631
632
# create board support package
633
[[ -n $RELEASE && ! -f ${DEB_STORAGE}/$RELEASE/${BSP_CLI_PACKAGE_FULLNAME}.deb ]] && create_board_package
634
635
# create desktop package
636
#[[ -n $RELEASE && $DESKTOP_ENVIRONMENT && ! -f ${DEB_STORAGE}/$RELEASE/${CHOSEN_DESKTOP}_${REVISION}_all.deb ]] && create_desktop_package
637
#[[ -n $RELEASE && $DESKTOP_ENVIRONMENT && ! -f ${DEB_STORAGE}/${RELEASE}/${BSP_DESKTOP_PACKAGE_FULLNAME}.deb ]] && create_bsp_desktop_package
638
[[ -n $RELEASE && $DESKTOP_ENVIRONMENT ]] && create_desktop_package
639
[[ -n $RELEASE && $DESKTOP_ENVIRONMENT ]] && create_bsp_desktop_package
640
641
# build additional packages
642
[[ $EXTERNAL_NEW == compile ]] && chroot_build_packages
643
644
[[ $BSP_BUILD != yes ]] && debootstrap_ng
645
646
fi
647
648
# hook for function to run after build, i.e. to change owner of $SRC
649
# NOTE: this will run only if there were no errors during build process
650
[[ $(type -t run_after_build) == function ]] && run_after_build || true
651
652
end=$(date +%s)
653
runtime=$(((end-start)/60))
654
display_alert "Runtime" "$runtime min" "info"
655
656
# Make it easy to repeat build by displaying build options used
657
[ "$(systemd-detect-virt)" == 'docker' ] && BUILD_CONFIG='docker'
658
659
display_alert "Repeat Build Options" "sudo ./build.sh ${BUILD_CONFIG} BOARD=${BOARD} BRANCH=${BRANCH} \
660
$([[ -n $BUILD_OPT ]] && echo "BUILD_OPT=${BUILD_OPT} ")\
661
$([[ -n $RELEASE ]] && echo "RELEASE=${RELEASE} ")\
662
$([[ -n $BUILD_MINIMAL ]] && echo "BUILD_MINIMAL=${BUILD_MINIMAL} ")\
663
$([[ -n $BUILD_DESKTOP ]] && echo "BUILD_DESKTOP=${BUILD_DESKTOP} ")\
664
$([[ -n $KERNEL_CONFIGURE ]] && echo "KERNEL_CONFIGURE=${KERNEL_CONFIGURE} ")\
665
$([[ -n $DESKTOP_ENVIRONMENT ]] && echo "DESKTOP_ENVIRONMENT=${DESKTOP_ENVIRONMENT} ")\
666
$([[ -n $DESKTOP_ENVIRONMENT_CONFIG_NAME ]] && echo "DESKTOP_ENVIRONMENT_CONFIG_NAME=${DESKTOP_ENVIRONMENT_CONFIG_NAME} ")\
667
$([[ -n $DESKTOP_APPGROUPS_SELECTED ]] && echo "DESKTOP_APPGROUPS_SELECTED=\"${DESKTOP_APPGROUPS_SELECTED}\" ")\
668
$([[ -n $DESKTOP_APT_FLAGS_SELECTED ]] && echo "DESKTOP_APT_FLAGS_SELECTED=\"${DESKTOP_APT_FLAGS_SELECTED}\" ")\
669
$([[ -n $COMPRESS_OUTPUTIMAGE ]] && echo "COMPRESS_OUTPUTIMAGE=${COMPRESS_OUTPUTIMAGE} ")\
670
" "ext"
671
672
} # end of do_default()
673
674
if [[ -z $1 ]]; then
675
do_default
676
else
677
eval "$@"
678
fi
679
680