CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
orangepi-xunlong

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

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