Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/next/scripts/main.sh
Views: 3960
#!/bin/bash1#2# Copyright (c) 2013-2021 Igor Pecovnik, igor.pecovnik@gma**.com3#4# This file is licensed under the terms of the GNU General Public5# License version 2. This program is licensed "as is" without any6# warranty of any kind, whether express or implied.7#8# Main program9#101112cleanup_list() {13local varname="${1}"14local list_to_clean="${!varname}"15list_to_clean="${list_to_clean#"${list_to_clean%%[![:space:]]*}"}"16list_to_clean="${list_to_clean%"${list_to_clean##*[![:space:]]}"}"17echo ${list_to_clean}18}1920212223if [[ $(basename "$0") == main.sh ]]; then2425echo "Please use build.sh to start the build process"26exit 2552728fi2930313233# default umask for root is 022 so parent directories won't be group writeable without this34# this is used instead of making the chmod in prepare_host() recursive35umask 0023637# destination38if [ -d "$CONFIG_PATH/output" ]; then39DEST="${CONFIG_PATH}"/output40else41DEST="${SRC}"/output42fi4344[[ -z $REVISION ]] && REVISION="3.0.8"4546[[ $DOWNLOAD_MIRROR == "china" ]] && NTP_SERVER="cn.pool.ntp.org"4748if [[ $BUILD_ALL != "yes" ]]; then49# override stty size50[[ -n $COLUMNS ]] && stty cols $COLUMNS51[[ -n $LINES ]] && stty rows $LINES52TTY_X=$(($(stty size | awk '{print $2}')-6)) # determine terminal width53TTY_Y=$(($(stty size | awk '{print $1}')-6)) # determine terminal height54fi5556# We'll use this title on all menus57backtitle="Orange Pi building script, http://www.orangepi.org"58titlestr="Choose an option"5960# Warnings mitigation61[[ -z $LANGUAGE ]] && export LANGUAGE="en_US:en" # set to english if not set62[[ -z $CONSOLE_CHAR ]] && export CONSOLE_CHAR="UTF-8" # set console to UTF-8 if not set6364# Libraries include6566# shellcheck source=debootstrap.sh67source "${SRC}"/scripts/debootstrap.sh # system specific install68# shellcheck source=image-helpers.sh69source "${SRC}"/scripts/image-helpers.sh # helpers for OS image building70# shellcheck source=distributions.sh71source "${SRC}"/scripts/distributions.sh # system specific install72# shellcheck source=desktop.sh73source "${SRC}"/scripts/desktop.sh # desktop specific install74# shellcheck source=compilation.sh75source "${SRC}"/scripts/compilation.sh # patching and compilation of kernel, uboot, ATF76# shellcheck source=compilation-prepare.sh77#source "${SRC}"/scripts/compilation-prepare.sh # drivers that are not upstreamed78# shellcheck source=makeboarddeb.sh79source "${SRC}"/scripts/makeboarddeb.sh # board support package80# shellcheck source=general.sh81source "${SRC}"/scripts/general.sh # general functions82# shellcheck source=chroot-buildpackages.sh83source "${SRC}"/scripts/chroot-buildpackages.sh # chroot packages building84# shellcheck source=pack.sh85source "${SRC}"/scripts/pack-uboot.sh868788# set log path89LOG_SUBPATH=${LOG_SUBPATH:=debug}9091# compress and remove old logs92mkdir -p "${DEST}"/${LOG_SUBPATH}93(cd "${DEST}"/${LOG_SUBPATH} && tar -czf logs-"$(<timestamp)".tgz ./*.log) > /dev/null 2>&194rm -f "${DEST}"/${LOG_SUBPATH}/*.log > /dev/null 2>&195date +"%d_%m_%Y-%H_%M_%S" > "${DEST}"/${LOG_SUBPATH}/timestamp9697# delete compressed logs older than 7 days98(cd "${DEST}"/${LOG_SUBPATH} && find . -name '*.tgz' -mtime +7 -delete) > /dev/null99100if [[ $PROGRESS_DISPLAY == none ]]; then101102OUTPUT_VERYSILENT=yes103104elif [[ $PROGRESS_DISPLAY == dialog ]]; then105106OUTPUT_DIALOG=yes107108fi109110if [[ $PROGRESS_LOG_TO_FILE != yes ]]; then unset PROGRESS_LOG_TO_FILE; fi111112113114SHOW_WARNING=yes115116117118if [[ $USE_CCACHE != no ]]; then119120CCACHE=ccache121export PATH="/usr/lib/ccache:$PATH"122# private ccache directory to avoid permission issues when using build script with "sudo"123# see https://ccache.samba.org/manual.html#_sharing_a_cache for alternative solution124[[ $PRIVATE_CCACHE == yes ]] && export CCACHE_DIR=$EXTER/cache/ccache125126else127128CCACHE=""129130fi131132133134135if [[ -n $REPOSITORY_UPDATE ]]; then136137# select stable/beta configuration138if [[ $BETA == yes ]]; then139DEB_STORAGE=$DEST/debs-beta140REPO_STORAGE=$DEST/repository-beta141REPO_CONFIG="aptly-beta.conf"142else143DEB_STORAGE=$DEST/debs144REPO_STORAGE=$DEST/repository145REPO_CONFIG="aptly.conf"146fi147148# For user override149if [[ -f "${USERPATCHES_PATH}"/lib.config ]]; then150display_alert "Using user configuration override" "userpatches/lib.config" "info"151source "${USERPATCHES_PATH}"/lib.config152fi153154repo-manipulate "$REPOSITORY_UPDATE"155exit156157fi158159160161# if BUILD_OPT, KERNEL_CONFIGURE, BOARD, BRANCH or RELEASE are not set, display selection menu162if [[ -z $BUILD_OPT ]]; then163164options+=("u-boot" "U-boot package")165options+=("kernel" "Kernel package")166options+=("rootfs" "Rootfs and all deb packages")167options+=("image" "Full OS image for flashing")168169menustr="Compile image | rootfs | kernel | u-boot"170BUILD_OPT=$(whiptail --title "${titlestr}" --backtitle "${backtitle}" --notags \171--menu "${menustr}" "${TTY_Y}" "${TTY_X}" $((TTY_Y - 8)) \172--cancel-button Exit --ok-button Select "${options[@]}" \1733>&1 1>&2 2>&3)174175unset options176[[ -z $BUILD_OPT ]] && exit_with_error "No option selected"177[[ $BUILD_OPT == rootfs ]] && ROOT_FS_CREATE_ONLY="yes"178fi179180181182183if [[ ${BUILD_OPT} =~ kernel|image ]]; then184185if [[ -z $KERNEL_CONFIGURE ]]; then186187options+=("no" "Do not change the kernel configuration")188options+=("yes" "Show a kernel configuration menu before compilation")189190menustr="Select the kernel configuration."191KERNEL_CONFIGURE=$(whiptail --title "${titlestr}" --backtitle "$backtitle" --notags \192--menu "${menustr}" $TTY_Y $TTY_X $((TTY_Y - 8)) \193--cancel-button Exit --ok-button Select "${options[@]}" \1943>&1 1>&2 2>&3)195196unset options197[[ -z $KERNEL_CONFIGURE ]] && exit_with_error "No option selected"198fi199fi200201202203204if [[ -z $BOARD ]]; then205206#options+=("orangepir1" "Allwinner H2+ quad core 256MB RAM WiFi SPI 2xETH")207#options+=("orangepizero" "Allwinner H2+ quad core 256MB/512MB RAM WiFi SPI")208#options+=("orangepipc" "Allwinner H3 quad core 1GB RAM")209#options+=("orangepipcplus" "Allwinner H3 quad core 1GB RAM WiFi eMMC")210#options+=("orangepione" "Allwinner H3 quad core 512MB RAM")211#options+=("orangepilite" "Allwinner H3 quad core 512MB RAM WiFi")212#options+=("orangepiplus" "Allwinner H3 quad core 1GB/2GB RAM WiFi GBE eMMC")213#options+=("orangepiplus2e" "Allwinner H3 quad core 2GB RAM WiFi GBE eMMC")214#options+=("orangepizeroplus2h3" "Allwinner H3 quad core 512MB RAM WiFi/BT eMMC")215#options+=("orangepipch5" "Allwinner H5 quad core 1GB RAM")216#options+=("orangepipc2" "Allwinner H5 quad core 1GB RAM GBE SPI")217#options+=("orangepioneh5" "Allwinner H5 quad core 512MB/1GB RAM")218#options+=("orangepiprime" "Allwinner H5 quad core 2GB RAM GBE WiFi/BT")219#options+=("orangepizeroplus" "Allwinner H5 quad core 512MB RAM GBE WiFi SPI")220#options+=("orangepizeroplus2h5" "Allwinner H5 quad core 512MB RAM WiFi/BT eMMC")221options+=("orangepi3" "Allwinner H6 quad core 1GB/2GB RAM GBE WiFi/BT eMMC USB3")222options+=("orangepi3-lts" "Allwinner H6 quad core 2GB RAM GBE WiFi/BT-AW859A eMMC USB3")223#options+=("orangepilite2" "Allwinner H6 quad core 1GB RAM WiFi/BT USB3")224#options+=("orangepioneplus" "Allwinner H6 quad core 1GB RAM GBE")225options+=("orangepizero2" "Allwinner H616 quad core 512MB/1GB RAM WiFi/BT GBE SPI")226#options+=("orangepizero2-b" "Allwinner H616 quad core 512MB/1GB RAM WiFi/BT GBE SPI")227#options+=("orangepizero2-lts" "Allwinner H616 quad core 1.5GB RAM WiFi/BT GBE SPI")228options+=("orangepizero3" "Allwinner H618 quad core 1GB/1.5GB/2GB/4GB RAM WiFi/BT GBE SPI")229options+=("orangepizero2w" "Allwinner H618 quad core 1GB/1.5GB/2GB/4GB RAM WiFi/BT SPI")230#options+=("orangepir1b" "Allwinner H618 quad core 1.5GB/2GB/4GB RAM WiFi/BT GBE SPI")231#options+=("orangepi400" "Allwinner H616 quad core 4GB RAM WiFi/BT GBE eMMC VGA")232options+=("orangepi4" "Rockchip RK3399 hexa core 4GB RAM GBE eMMC USB3 USB-C WiFi/BT")233options+=("orangepi4a" "Allwinner T527 octa core 2-4GB RAM GBE WiFi/BT NVMe eMMC")234options+=("orangepi4-lts" "Rockchip RK3399 hexa core 4GB RAM GBE eMMC USB3 USB-C WiFi/BT")235options+=("orangepi800" "Rockchip RK3399 hexa core 4GB RAM GBE eMMC USB3 USB-C WiFi/BT VGA")236options+=("orangepi5" "Rockchip RK3588S octa core 4-16GB RAM GBE USB3 USB-C NVMe")237options+=("orangepicm5" "Rockchip RK3588S octa core 4-16GB RAM GBE USB3 USB-C")238options+=("orangepicm5-tablet" "Rockchip RK3588S octa core 4-16GB RAM USB3 USB-C WiFi/BT")239options+=("orangepi5b" "Rockchip RK3588S octa core 4-16GB RAM GBE USB3 USB-C WiFi/BT eMMC")240#options+=("orangepitab" "Rockchip RK3588S octa core 4-16GB RAM USB-C WiFi/BT NVMe")241#options+=("orangepi900" "Rockchip RK3588 octa core 4-16GB RAM 2.5GBE USB3 USB-C WiFi/BT NVMe")242options+=("orangepi5pro" "Rockchip RK3588S octa core 4-16GB RAM GBE USB3 WiFi/BT NVMe eMMC")243options+=("orangepi5max" "Rockchip RK3588 octa core 4-16GB RAM 2.5GBE USB3 WiFi/BT NVMe eMMC")244options+=("orangepi5ultra" "Rockchip RK3588 octa core 4-16GB RAM 2.5GBE USB3 WiFi/BT NVMe eMMC")245options+=("orangepi5plus" "Rockchip RK3588 octa core 4-32GB RAM 2.5GBE USB3 USB-C WiFi/BT NVMe eMMC")246options+=("orangepicm4" "Rockchip RK3566 quad core 2-8GB RAM GBE eMMC USB3 NvMe WiFi/BT")247options+=("orangepi3b" "Rockchip RK3566 quad core 2-8GB RAM GBE eMMC USB3 NvMe WiFi/BT")248options+=("orangepirv" "Starfive JH7110 quad core 2-8GB RAM GBE USB3 NvMe WiFi/BT")249options+=("orangepirv2" "Ky X1 octa core 2-8GB RAM GBE USB3 WiFi/BT NVMe eMMC")250#options+=("orangepir2s" "Ky X1 octa core 2-8GB RAM 2.5GBE USB3 eMMC")251#options+=("orangepir1plus" "Rockchip RK3328 quad core 1GB RAM 2xGBE USB2 SPI")252#options+=("orangepi3plus" "Amlogic S905D3 quad core 2/4GB RAM SoC eMMC GBE USB3 SPI WiFi/BT")253254menustr="Please choose a Board."255BOARD=$(whiptail --title "${titlestr}" --backtitle "${backtitle}" \256--menu "${menustr}" "${TTY_Y}" "${TTY_X}" $((TTY_Y - 8)) \257--cancel-button Exit --ok-button Select "${options[@]}" \2583>&1 1>&2 2>&3)259260unset options261[[ -z $BOARD ]] && exit_with_error "No option selected"262fi263264BOARD_TYPE="conf"265# shellcheck source=/dev/null266source "${EXTER}/config/boards/${BOARD}.${BOARD_TYPE}"267LINUXFAMILY="${BOARDFAMILY}"268269[[ -z $KERNEL_TARGET ]] && exit_with_error "Board configuration does not define valid kernel config"270271if [[ -z $BRANCH ]]; then272273options=()274[[ $KERNEL_TARGET == *current* ]] && options+=("current" "Recommended. Come with best support")275[[ $KERNEL_TARGET == *legacy* ]] && options+=("legacy" "Old stable / Legacy")276[[ $KERNEL_TARGET == *next* ]] && options+=("next" "Use the latest kernel")277278menustr="Select the target kernel branch\nExact kernel versions depend on selected board"279# do not display selection dialog if only one kernel branch is available280if [[ "${#options[@]}" == 2 ]]; then281BRANCH="${options[0]}"282else283BRANCH=$(whiptail --title "${titlestr}" --backtitle "${backtitle}" \284--menu "${menustr}" "${TTY_Y}" "${TTY_X}" $((TTY_Y - 8)) \285--cancel-button Exit --ok-button Select "${options[@]}" \2863>&1 1>&2 2>&3)287fi288unset options289[[ -z $BRANCH ]] && exit_with_error "No kernel branch selected"290[[ $BRANCH == dev && $SHOW_WARNING == yes ]] && show_developer_warning291292fi293294if [[ $BUILD_OPT =~ rootfs|image && -z $RELEASE ]]; then295296options=()297298distros_options299300menustr="Select the target OS release package base"301RELEASE=$(whiptail --title "Choose a release package base" --backtitle "${backtitle}" \302--menu "${menustr}" "${TTY_Y}" "${TTY_X}" $((TTY_Y - 8)) \303--cancel-button Exit --ok-button Select "${options[@]}" \3043>&1 1>&2 2>&3)305#echo "options : ${options}"306[[ -z $RELEASE ]] && exit_with_error "No release selected"307308unset options309fi310311# don't show desktop option if we choose minimal build312[[ $BUILD_MINIMAL == yes ]] && BUILD_DESKTOP=no313314if [[ $BUILD_OPT =~ rootfs|image && -z $BUILD_DESKTOP ]]; then315316# read distribution support status which is written to the orangepi-release file317set_distribution_status318319options=()320options+=("no" "Image with console interface (server)")321options+=("yes" "Image with desktop environment")322323menustr="Select the target image type"324BUILD_DESKTOP=$(whiptail --title "Choose image type" --backtitle "${backtitle}" \325--menu "${menustr}" "${TTY_Y}" "${TTY_X}" $((TTY_Y - 8)) \326--cancel-button Exit --ok-button Select "${options[@]}" \3273>&1 1>&2 2>&3)328unset options329[[ -z $BUILD_DESKTOP ]] && exit_with_error "No option selected"330if [[ ${BUILD_DESKTOP} == "yes" ]]; then331BUILD_MINIMAL=no332SELECTED_CONFIGURATION="desktop"333fi334335fi336337if [[ $BUILD_OPT =~ rootfs|image && $BUILD_DESKTOP == no && -z $BUILD_MINIMAL ]]; then338339options=()340options+=("no" "Standard image with console interface")341options+=("yes" "Minimal image with console interface")342menustr="Select the target image type"343BUILD_MINIMAL=$(whiptail --title "Choose image type" --backtitle "${backtitle}" \344--menu "${menustr}" "${TTY_Y}" "${TTY_X}" $((TTY_Y - 8)) \345--cancel-button Exit --ok-button Select "${options[@]}" \3463>&1 1>&2 2>&3)347unset options348[[ -z $BUILD_MINIMAL ]] && exit_with_error "No option selected"349if [[ $BUILD_MINIMAL == "yes" ]]; then350SELECTED_CONFIGURATION="cli_minimal"351else352SELECTED_CONFIGURATION="cli_standard"353fi354355fi356357#prevent conflicting setup358if [[ $BUILD_DESKTOP == "yes" ]]; then359BUILD_MINIMAL=no360SELECTED_CONFIGURATION="desktop"361elif [[ $BUILD_MINIMAL != "yes" || -z "${BUILD_MINIMAL}" ]]; then362BUILD_MINIMAL=no # Just in case BUILD_MINIMAL is not defined363BUILD_DESKTOP=no364SELECTED_CONFIGURATION="cli_standard"365elif [[ $BUILD_MINIMAL == "yes" ]]; then366BUILD_DESKTOP=no367SELECTED_CONFIGURATION="cli_minimal"368fi369370#[[ ${KERNEL_CONFIGURE} == prebuilt ]] && [[ -z ${REPOSITORY_INSTALL} ]] && \371#REPOSITORY_INSTALL="u-boot,kernel,bsp,orangepi-zsh,orangepi-config,orangepi-firmware${BUILD_DESKTOP:+,orangepi-desktop}"372373374#shellcheck source=configuration.sh375source "${SRC}"/scripts/configuration.sh376377# optimize build time with 100% CPU usage378CPUS=$(grep -c 'processor' /proc/cpuinfo)379if [[ $USEALLCORES != no ]]; then380381CTHREADS="-j$((CPUS + CPUS/2))"382383else384385CTHREADS="-j1"386387fi388389call_extension_method "post_determine_cthreads" "config_post_determine_cthreads" << 'POST_DETERMINE_CTHREADS'390*give config a chance modify CTHREADS programatically. A build server may work better with hyperthreads-1 for example.*391Called early, before any compilation work starts.392POST_DETERMINE_CTHREADS393394if [[ $BETA == yes ]]; then395IMAGE_TYPE=nightly396elif [[ $BETA != "yes" && $BUILD_ALL == yes && -n $GPG_PASS ]]; then397IMAGE_TYPE=stable398else399IMAGE_TYPE=user-built400fi401402branch2dir() {403[[ "${1}" == "head" ]] && echo "HEAD" || echo "${1##*:}"404}405406BOOTSOURCEDIR="${BOOTDIR}/$(branch2dir "${BOOTBRANCH}")"407LINUXSOURCEDIR="${KERNELDIR}/$(branch2dir "${KERNELBRANCH}")"408[[ -n $ATFSOURCE ]] && ATFSOURCEDIR="${ATFDIR}/$(branch2dir "${ATFBRANCH}")"409410BSP_CLI_PACKAGE_NAME="orangepi-bsp-cli-${BOARD}"411BSP_CLI_PACKAGE_FULLNAME="${BSP_CLI_PACKAGE_NAME}_${REVISION}_${ARCH}"412BSP_DESKTOP_PACKAGE_NAME="orangepi-bsp-desktop-${BOARD}"413BSP_DESKTOP_PACKAGE_FULLNAME="${BSP_DESKTOP_PACKAGE_NAME}_${REVISION}_${ARCH}"414415CHOSEN_UBOOT=linux-u-boot-${BRANCH}-${BOARD}416CHOSEN_KERNEL=linux-image-${BRANCH}-${LINUXFAMILY}417CHOSEN_ROOTFS=${BSP_CLI_PACKAGE_NAME}418CHOSEN_DESKTOP=orangepi-${RELEASE}-desktop-${DESKTOP_ENVIRONMENT}419CHOSEN_KSRC=linux-source-${BRANCH}-${LINUXFAMILY}420421do_default() {422423start=$(date +%s)424425# Check and install dependencies, directory structure and settings426# The OFFLINE_WORK variable inside the function427prepare_host428429[[ "${JUST_INIT}" == "yes" ]] && exit 0430431[[ $CLEAN_LEVEL == *sources* ]] && cleaning "sources"432433# fetch_from_repo <url> <dir> <ref> <subdir_flag>434435# ignore updates help on building all images - for internal purposes436if [[ ${IGNORE_UPDATES} != yes ]]; then437438display_alert "Downloading sources" "" "info"439440[[ $BUILD_OPT =~ u-boot|image ]] && fetch_from_repo "$BOOTSOURCE" "$BOOTDIR" "$BOOTBRANCH" "yes"441[[ $BUILD_OPT =~ kernel|image ]] && fetch_from_repo "$KERNELSOURCE" "$KERNELDIR" "$KERNELBRANCH" "yes"442443if [[ -n ${ATFSOURCE} ]]; then444445[[ ${BUILD_OPT} =~ u-boot|image ]] && fetch_from_repo "$ATFSOURCE" "${EXTER}/cache/sources/$ATFDIR" "$ATFBRANCH" "yes"446447fi448449if [[ ${BOARD} =~ orangepi4|orangepi4-lts|orangepi800 && $BRANCH == legacy ]]; then450451[[ $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"452453fi454455if [[ ${BOARD} =~ orangepiaimax ]]; then456457[[ $BUILD_OPT =~ image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/ascend-driver.git" "${EXTER}/cache/sources/ascend-driver" "branch:main"458459fi460461if [[ "${BOARD}x" =~ orangepi4x|orangepi4-ltsx|orangepi800x && $RELEASE =~ focal|buster|bullseye|bookworm ]]; then462463[[ ${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}"464[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/rk35xx_packages" "branch:rk35xx_packages"465466fi467468if [[ ${BOARDFAMILY} == "rockchip-rk3588" && $RELEASE =~ bullseye|bookworm|focal|jammy|raspi ]]; then469470[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/rk35xx_packages" "branch:rk35xx_packages"471472fi473474if [[ ${BOARDFAMILY} == "rockchip-rk356x" && $RELEASE =~ bullseye|focal|jammy|raspi ]]; then475476[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/rk35xx_packages" "branch:rk35xx_packages"477478fi479480if [[ ${BOARDFAMILY} == "ky" && $RELEASE =~ noble ]]; then481482[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/ky_packages" "branch:ky_packages"483484fi485486if [[ ${BOARDFAMILY} == "sun55iw3" && $RELEASE =~ bookworm|jammy ]]; then487488[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/t527_packages" "branch:t527_packages"489490fi491492if [[ ${BOARD} =~ orangepi3|orangepi3-lts && $RELEASE =~ bullseye && $BRANCH == current ]]; then493494[[ ${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}"495496fi497498if [[ "${BOARD}x" =~ orangepi4x|orangepi4-ltsx|orangepi800x && $RELEASE =~ jammy && $BRANCH == next ]]; then499500[[ ${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}"501502fi503504call_extension_method "fetch_sources_tools" <<- 'FETCH_SOURCES_TOOLS'505*fetch host-side sources needed for tools and build*506Run early to fetch_from_repo or otherwise obtain sources for needed tools.507FETCH_SOURCES_TOOLS508509call_extension_method "build_host_tools" <<- 'BUILD_HOST_TOOLS'510*build needed tools for the build, host-side*511After sources are fetched, build host-side tools needed for the build.512BUILD_HOST_TOOLS513fi514515for option in $(tr ',' ' ' <<< "$CLEAN_LEVEL"); do516[[ $option != sources ]] && cleaning "$option"517done518519# Compile u-boot if packed .deb does not exist or use the one from Orange Pi520if [[ $BUILD_OPT == u-boot || $BUILD_OPT == image ]]; then521522if [[ ! -f "${DEB_STORAGE}"/u-boot/${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb ]]; then523524[[ -n "${ATFSOURCE}" && "${REPOSITORY_INSTALL}" != *u-boot* ]] && compile_atf525526[[ ${REPOSITORY_INSTALL} != *u-boot* ]] && compile_uboot527fi528529if [[ $BUILD_OPT == "u-boot" ]]; then530unset BUILD_MINIMAL BUILD_DESKTOP COMPRESS_OUTPUTIMAGE531display_alert "U-boot build done" "@host" "info"532display_alert "Target directory" "${DEB_STORAGE}/u-boot" "info"533display_alert "File name" "${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb" "info"534fi535fi536537# Compile kernel if packed .deb does not exist or use the one from Orange Pi538if [[ $BUILD_OPT == kernel || $BUILD_OPT == image ]]; then539540if [[ ! -f ${DEB_STORAGE}/${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb ]]; then541542KDEB_CHANGELOG_DIST=$RELEASE543[[ "${REPOSITORY_INSTALL}" != *kernel* ]] && compile_kernel544fi545546if [[ $BUILD_OPT == "kernel" ]]; then547unset BUILD_MINIMAL BUILD_DESKTOP COMPRESS_OUTPUTIMAGE548display_alert "Kernel build done" "@host" "info"549display_alert "Target directory" "${DEB_STORAGE}/" "info"550display_alert "File name" "${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb" "info"551fi552fi553554if [[ $BUILD_OPT == rootfs || $BUILD_OPT == image ]]; then555556# Compile orangepi-config if packed .deb does not exist or use the one from Orange Pi557if [[ ! -f ${DEB_STORAGE}/orangepi-config_${REVISION}_all.deb ]]; then558559[[ "${REPOSITORY_INSTALL}" != *orangepi-config* ]] && compile_orangepi-config560fi561562# Compile orangepi-zsh if packed .deb does not exist or use the one from repository563if [[ ! -f ${DEB_STORAGE}/orangepi-zsh_${REVISION}_all.deb ]]; then564565[[ "${REPOSITORY_INSTALL}" != *orangepi-zsh* ]] && compile_orangepi-zsh566fi567568# Compile plymouth-theme-orangepi if packed .deb does not exist or use the one from repository569if [[ ! -f ${DEB_STORAGE}/plymouth-theme-orangepi_${REVISION}_all.deb ]]; then570571[[ "${REPOSITORY_INSTALL}" != *plymouth-theme-orangepi* ]] && compile_plymouth-theme-orangepi572fi573574# Compile orangepi-firmware if packed .deb does not exist or use the one from repository575if [[ "${REPOSITORY_INSTALL}" != *orangepi-firmware* ]]; then576577if ! ls "${DEB_STORAGE}/orangepi-firmware_${REVISION}_all.deb" 1> /dev/null 2>&1; then578579FULL=""580REPLACE="-full"581compile_firmware582583fi584585#if ! ls "${DEB_STORAGE}/orangepi-firmware-full_${REVISION}_all.deb" 1> /dev/null 2>&1; then586587#FULL="-full"588#REPLACE=""589#compile_firmware590591#fi592593fi594595overlayfs_wrapper "cleanup"596597# create board support package598[[ -n $RELEASE && ! -f ${DEB_STORAGE}/$RELEASE/${BSP_CLI_PACKAGE_FULLNAME}.deb ]] && create_board_package599600# create desktop package601#[[ -n $RELEASE && $DESKTOP_ENVIRONMENT && ! -f ${DEB_STORAGE}/$RELEASE/${CHOSEN_DESKTOP}_${REVISION}_all.deb ]] && create_desktop_package602#[[ -n $RELEASE && $DESKTOP_ENVIRONMENT && ! -f ${DEB_STORAGE}/${RELEASE}/${BSP_DESKTOP_PACKAGE_FULLNAME}.deb ]] && create_bsp_desktop_package603[[ -n $RELEASE && $DESKTOP_ENVIRONMENT ]] && create_desktop_package604[[ -n $RELEASE && $DESKTOP_ENVIRONMENT ]] && create_bsp_desktop_package605606# build additional packages607[[ $EXTERNAL_NEW == compile ]] && chroot_build_packages608609[[ $BSP_BUILD != yes ]] && debootstrap_ng610611fi612613# hook for function to run after build, i.e. to change owner of $SRC614# NOTE: this will run only if there were no errors during build process615[[ $(type -t run_after_build) == function ]] && run_after_build || true616617end=$(date +%s)618runtime=$(((end-start)/60))619display_alert "Runtime" "$runtime min" "info"620621# Make it easy to repeat build by displaying build options used622[ "$(systemd-detect-virt)" == 'docker' ] && BUILD_CONFIG='docker'623624display_alert "Repeat Build Options" "sudo ./build.sh ${BUILD_CONFIG} BOARD=${BOARD} BRANCH=${BRANCH} \625$([[ -n $BUILD_OPT ]] && echo "BUILD_OPT=${BUILD_OPT} ")\626$([[ -n $RELEASE ]] && echo "RELEASE=${RELEASE} ")\627$([[ -n $BUILD_MINIMAL ]] && echo "BUILD_MINIMAL=${BUILD_MINIMAL} ")\628$([[ -n $BUILD_DESKTOP ]] && echo "BUILD_DESKTOP=${BUILD_DESKTOP} ")\629$([[ -n $KERNEL_CONFIGURE ]] && echo "KERNEL_CONFIGURE=${KERNEL_CONFIGURE} ")\630$([[ -n $DESKTOP_ENVIRONMENT ]] && echo "DESKTOP_ENVIRONMENT=${DESKTOP_ENVIRONMENT} ")\631$([[ -n $DESKTOP_ENVIRONMENT_CONFIG_NAME ]] && echo "DESKTOP_ENVIRONMENT_CONFIG_NAME=${DESKTOP_ENVIRONMENT_CONFIG_NAME} ")\632$([[ -n $DESKTOP_APPGROUPS_SELECTED ]] && echo "DESKTOP_APPGROUPS_SELECTED=\"${DESKTOP_APPGROUPS_SELECTED}\" ")\633$([[ -n $DESKTOP_APT_FLAGS_SELECTED ]] && echo "DESKTOP_APT_FLAGS_SELECTED=\"${DESKTOP_APT_FLAGS_SELECTED}\" ")\634$([[ -n $COMPRESS_OUTPUTIMAGE ]] && echo "COMPRESS_OUTPUTIMAGE=${COMPRESS_OUTPUTIMAGE} ")\635" "ext"636637} # end of do_default()638639if [[ -z $1 ]]; then640do_default641else642eval "$@"643fi644645646