mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
* extensions framework (née "fragments")
- this should actually change nothing at this point, just add capabilities
- the framework is implemented in lib/extensions.sh
- the "if function x exists then call x" replaced with call_extension_method()
- +inline documentation
- +compatibility names
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* extensions framework; meta-extensions: auto-docs and sample extension gen
- 2 extensions dealing with extensibility itself
- detect-unused-extensions: shows which extensions are enabled, but never called.
- gen-sample-extension-docs: generates a sample empty extension & Markdown documentation for extensions
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* new extension methods and features via config variables in core Armbian
- `SKIP_EXTERNAL_TOOLCHAINS=yes` - does not download or use any linaro toolchains, only build host-installed ones
- `SKIP_BOOTSPLASH=yes` - does not patch kernel for splash file
- `EXTRA_BSP_NAME=xyz` - allows for BSP variants, useful for when extensions modify the BSP
- `EXTRA_ROOTFS_MIB_SIZE=x` - add x mib's to rootfs size, for use with very small images
- `KERNEL_EXTRA_TARGETS` - what extra targets to make kernel for, default to "modules dtbs"
- `BOOTCONFIG=none` - does not build nor install u-boot; also doesn't handle bootscripts et al
- `unset KERNELSOURCE` - does not build nor install kernel, nor build initrd, nor build nor install firmware
- `ARMHF_ARCH=skip` - does not add armhf to apt/dpkg, thus pure arm64
- `SKIP_ARMBIAN_REPO=yes` - results in armbian.list.disabled in the final image
- define `APT_EXTRA_DIST_PARAMS` with apt-cacher-ng options and use it for `PACKAGE_LIST_INSTALL/REMOVE` et al
- initial support for targeting x86/amd64 UEFI and BIOS
- some do's/don'ts for x86/amd64, like a different `UBUNTU_MIRROR` default
- GPT/EFI(ESP) partitions (fat, `UEFISIZE=256` to enable, mount `UEFI_MOUNT_POINT=/boot/efi`, first on disk but ends
up at `$uefipart`=15)
- GPT/BIOS partitions (fat, `BIOSSIZE=1` to enable, second on disk but ends up at partition 14)
- `UEFI_FS_LABEL="armbiefi"` - to set the FAT label for the EFI partition, visible in Win/Mac
- hard-requires gdisk package host-side
- add add_host_dependencies() extension method; fill `EXTRA_BUILD_DEPS="pkg pkg2"` to install to host before toolchains
download
- add pre_prepare_partitions() extension method, for custom partition size calculations
- add create_partition_table() extension method, used to do full-custom partitioning if `USE_HOOK_FOR_PARTITION=yes`
- add post_create_partitions() extension method, mostly for easy debugging
- add post_write_sdcard() extension method, where you can also set `SKIP_VERIFY=yes` to skip sdcard verification
- add post_install_kernel_debs() extension method.
- multiple fixes to bsp to avoid spurious errors when files are not where it expects
- v4: detect `update-initramfs` failure and abort build with useful message if it does
- v4: show useful stacktrace in `exit_with_error`
- if `ERROR_DEBUG_SHELL=yes`, drop into a shell before unmounting/deleting everything, so we can inspect what went wrong
- v4: display a message before `apt-get remove PACKAGE_LIST_BOARD_REMOVE` packages, so any errors while removing are easy to understand
- v4: preserve kernel .config's dates when copying
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* extensions framework; refactor tool fetching/building into extensions
- a few examples of core refactoring using extensions
- sunxi-tools extension, enabled by 2 different sunxi family includes ("reuse" example)
- marvel-tools extension, enabled by 2 different mvebu family includes
- rkbin-tools extension, enabled by rockship64_common family include
- amlogic-fip/c2-blobs stuff refactored directly into meson64_common.inc ("single-use" example)
- removed the 'testings' fetch_from_repo completely since not used anywhere.
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* .wip's for UEFI arm64 and UEFI/BIOS x86 via new GRUB extension
- v3: added `growroot`-awareness to `armbian-resize-filesystem`
- the partition-growing part of `armbian-resize-filesystem` does not deal correctly with the UEFI layout
- `growroot` is installed on UEFI images by default, that handles growing partition during initramfs
- now `armbian-resize-filesystem` handles `resize2fs` only, and works.
- v4: reworked UEFI board/family/include structure:
- use Distro's `linux-generic` kernel only for `current`
- `edge` now builds it's own pure-mainline `5.15.y` kernel, for both x86 and arm64
- `.config` taken from Ubuntu, probably needs tuning for EXTRAWIFI=yes et al
- v4: introduce `SKIP_KERNEL_SYMLINK=yes`, tested in `builddeb`
- to avoid symlinking kernel; u-boot likes it, but grub and flash-kernel hates it
- v5: many fixes
- v7: more small fixes.
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* .wip for the RaspberryPi 4B via new flash-kernel extension
- this does not build it's own kernel "yet", but uses default linux-raspi kernel from Ubuntu
- flash-kernel is not really a bootloader
- it just prepares kernel et al a FAT partition for booting by the RPi4b bootloader
- flash-kernel is standard Debian package, but has only been tested on Ubuntu releases
- it is really only known-working since Hirsute release.
- Debian's rpi kernel is armhf only, so out of scope here, at least until we add source-built kernels.
- v3: fixed focal rootfs build. untested.
- v3: better variable names, preparing for source-built kernel.
- v5: new edge build with pure mainline kernel.
- v6: many fixes and some hacks for packaging and layout, also firmware (using Ubuntu's)
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* Added first patch to edge x86 related to wifi drivers
* extensions: leave hostapd alone; remove hackish ext; block reentrancy
- package-list-utils does not belong in this PR
- grub or bcm2711 is not the place to remove hostapd
- block recursive enable_extension() calls, for now.
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* gen-sample-extension-docs: fix: avoid counter in generated sample
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* extensions: dependencies: enable_extension() in extensions with a stack
- and better stacktraces, I hope
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* Remove code from package list since we don't have it in repository
Adjust kernel config to disable driver that needs further polishing.
* Allow amd64 to build the same desktops as aarch64. We only have this limit for armhf, where some desktops don't work
* amd64: allow building amd64 on aarch64 with system toolchain
- conditionally add gcc-x86-64-linux-gnu to hostdeps
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* add libelf-dev directly to hostdeps (and Dockerfile), remove extension
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* packaging: remove SKIP_KERNEL_SYMLINK hack, fix the root cause
- which was the missing $image_name for non-arm64 & non-arm, so: x86 for example
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* grub: really obliterate u-boot stuff from BSP
- for now. soon we'll refactor u-boot so not have to do this
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* flash-kernel: really obliterate u-boot stuff from BSP
- for now. soon we'll refactor u-boot so not have to do this
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* extensions: add host_dependencies_ready() hook
- this passes FINAL_HOST_DEPS containing all hostdeps for the run after they're installed
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* Add verification functions for correct selection.
* If UEFI Skip symlink creation
* Do not create dtb package for amd64
* Skip scripts folder cleaning if build process native.
Skip creating postinst prerm scripts for headers.
* Skip applying headers-debian-byteshift.patch if build native
* Fix architecture syntax as x86_64
* Revert "amd64: allow building amd64 on aarch64 with system toolchain"
This reverts commit 0c5ee20bb1.
* Compare architectures before starting compilation.
Signed-off-by: The-going <48602507+The-going@users.noreply.github.com>
* extensions: cleanups after fixes by the-Going
- packaging:
- there is _no need_ anymore for the symlink hack, CONFIG_EFI or no. But check is great, see below
- it's not `amd64` that has no DTB's, it's all UEFI, thus: `is_enabled CONFIG_EFI`, thanks!
- Explicitly disallow "reverse cross compile" in amd64.conf.
- whitespace-only-deletions: revert. we shall shellfmt the whole thing one day, but not today.
- fix a few syntax warnings in newly introduced code (floating `$ARCH` vs `"${ARCH}`) - blame shellcheck
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* packaging: fix: turns out a lot of boards have CONFIG_EFI=y, can't use that for dtb/no-dtb decision.
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* grub: remove debug
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* firmware: allow installing `armbian-firmware-full`; make it really full
- can now use `BOARD_FIRMWARE_INSTALL="-full"` to install full firmware for the board. enable for UEFI.
- don't rely on KERNELSOURCE for firmware-related decisions. introduce `INSTALL_ARMBIAN_FIRMWARE` which defaults to `yes`
- rpi4b/flash-kernel: disable Armbian firmware; we need linux-firmware-raspi2, which conflicts.
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* extensions: log to /${LOG_SUBPATH}/ instead of fixed /debug/
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* extensions: introduce cleanup_extension_manager() called by build-all-ng's unset_all()
- to reset/unset everything done by the the initializer, so build can run again
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* extensions: remove 'global' logging, for use with build_all_ng
- enable_extensions() will have to live on without logging to file. it's just too early.
- now init EXTENSION_MANAGER_TMP_DIR in initialize_extension_manager()
- now init EXTENSION_MANAGER_LOG_FILE in initialize_extension_manager()
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* extensions: build-all-ng.sh bugfix due to extension's debug to stdout
- extensions (among other things) can produce output to stdout when activated
- fix: check_hash() produced "idential" (sic, now changed to IDENTICAL) to stdout as a trigger
- debugging output got mixed with "idential", rendering hash cache void for families that used extensions
- eg: sunxi, others
- fix is to send stdout to the bitbucket when sourcing the board & arch config files
- proper fix would be stop using stdout in this case and use return code for check_hash()
- one day soon
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
* Add CI build targets
Co-authored-by: Igor Pecovnik <igor.pecovnik@gmail.com>
Co-authored-by: The-going <48602507+The-going@users.noreply.github.com>
491 lines
17 KiB
Bash
491 lines
17 KiB
Bash
#!/bin/bash
|
|
#
|
|
# Copyright (c) 2013-2021 Igor Pecovnik, igor.pecovnik@gma**.com
|
|
#
|
|
# This file is licensed under the terms of the GNU General Public
|
|
# License version 2. This program is licensed "as is" without any
|
|
# warranty of any kind, whether express or implied.
|
|
#
|
|
# This file is a part of the Armbian build script
|
|
# https://github.com/armbian/build/
|
|
|
|
# Functions:
|
|
# unset_all
|
|
# pack_upload
|
|
# build_main
|
|
# array_contains
|
|
# check_hash
|
|
# build_all
|
|
|
|
|
|
|
|
if [[ -z $VENDOR ]]; then VENDOR="Armbian"; fi
|
|
if [[ $BETA == "yes" ]]; then STABILITY="beta"; else STABILITY="stable"; fi
|
|
if [[ $BETA == "yes" ]]; then upload_subdir=nightly; else upload_subdir="archive"; fi
|
|
if [[ $MAKE_ALL_BETA == "yes" ]]; then STABILITY="stable"; fi
|
|
if [[ -z $KERNEL_ONLY ]]; then KERNEL_ONLY="yes"; fi
|
|
if [[ -z $MULTITHREAD ]]; then MULTITHREAD=0; fi
|
|
if [[ -z $START ]]; then START=0; fi
|
|
if [[ -z $KERNEL_CONFIGURE ]]; then KERNEL_CONFIGURE="no"; fi
|
|
if [[ -z $CLEAN_LEVEL ]]; then CLEAN_LEVEL="make,oldcache"; fi
|
|
|
|
MAINLINE_KERNEL_SOURCE='https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable'
|
|
|
|
# cleanup
|
|
rm -f /run/armbian/*.pid
|
|
mkdir -p /run/armbian
|
|
|
|
# read user defined targets if exits
|
|
if [[ -f $USERPATCHES_PATH/targets.conf ]]; then
|
|
|
|
display_alert "Adding user provided targets configuration"
|
|
BUILD_TARGETS="${USERPATCHES_PATH}/targets.conf"
|
|
|
|
else
|
|
|
|
BUILD_TARGETS="${SRC}/config/targets.conf"
|
|
|
|
fi
|
|
|
|
unset_all ()
|
|
{
|
|
cleanup_extension_manager
|
|
unset LINUXFAMILY LINUXCONFIG KERNELDIR KERNELSOURCE KERNELBRANCH BOOTDIR BOOTSOURCE BOOTBRANCH ARCH UBOOT_USE_GCC KERNEL_USE_GCC CPUMIN CPUMAX \
|
|
UBOOT_VER KERNEL_VER GOVERNOR BOOTSIZE BOOTFS_TYPE UBOOT_TOOLCHAIN KERNEL_TOOLCHAIN DEBOOTSTRAP_LIST PACKAGE_LIST_EXCLUDE KERNEL_IMAGE_TYPE \
|
|
write_uboot_platform family_tweaks family_tweaks_bsp setup_write_uboot_platform uboot_custom_postprocess atf_custom_postprocess family_tweaks_s \
|
|
LOCALVERSION UBOOT_COMPILER KERNEL_COMPILER BOOTCONFIG BOOTCONFIG_VAR_NAME INITRD_ARCH BOOTENV_FILE BOOTDELAY ATF_TOOLCHAIN2 MOUNT SDCARD \
|
|
BOOTPATCHDIR KERNELPATCHDIR RELEASE IMAGE_TYPE OVERLAY_PREFIX ASOUND_STATE ATF_COMPILER ATF_USE_GCC ATFSOURCE ATFDIR ATFBRANCH ATFSOURCEDIR \
|
|
PACKAGE_LIST_RM NM_IGNORE_DEVICES DISPLAY_MANAGER family_tweaks_bsp_s CRYPTROOT_ENABLE CRYPTROOT_PASSPHRASE CRYPTROOT_SSH_UNLOCK \
|
|
CRYPTROOT_SSH_UNLOCK_PORT CRYPTROOT_SSH_UNLOCK_KEY_NAME ROOT_MAPPER NETWORK HDMI USB WIRELESS ARMBIANMONITOR FORCE_BOOTSCRIPT_UPDATE \
|
|
UBOOT_TOOLCHAIN2 toolchain2 BUILD_REPOSITORY_URL BUILD_REPOSITORY_COMMIT BUILD_TARGET HOST BUILD_IMAGE DEB_STORAGE REPO_STORAGE REPO_CONFIG \
|
|
REPOSITORY_UPDATE PACKAGE_LIST_RELEASE LOCAL_MIRROR COMPILE_ATF PACKAGE_LIST_BOARD PACKAGE_LIST_FAMILY PACKAGE_LIST_DESKTOP_BOARD \
|
|
PACKAGE_LIST_DESKTOP_FAMILY ATF_COMPILE ATFPATCHDIR OFFSET BOOTSOURCEDIR KERNEL_VERSION_LEVEL KERNELSOURCENAME \
|
|
BOOT_SOC DDR_BLOB MINILOADER_BLOB BL31_BLOB BOOT_SCENARIO BOOT_SUPPORT_SPI OFFLINE_WORK VAR_SHALLOW_ORIGINAL KERNELSWITCHOBJ \
|
|
IMAGE_PARTITION_TABLE BOOT_LOGO UPSTREM_VER FORCED_MONTH_OFFSET PACKAGE_LIST_BOARD_REMOVE PACKAGE_LIST_FAMILY_REMOVE PACKAGE_LIST_DESKTOP \
|
|
PACKAGE_LIST_DESKTOP_BOARD_REMOVE PACKAGE_LIST_DESKTOP_FAMILY_REMOVE BOOTCONFIG_EDGE DESKTOP_ENVIRONMENT DESKTOP_ENVIRONMENT_CONFIG_NAME \
|
|
DESKTOP_APPGROUPS_SELECTED DESKTOP_APT_FLAGS_SELECTED DESKTOP_ENVIRONMENT_DIRPATH DESKTOP_ENVIRONMENT_PACKAGE_LIST_DIRPATH UBOOT_TARGET_MAP \
|
|
DESKTOP_ENVIRONMENT_DIRPATH DESKTOP_ENVIRONMENT_PACKAGE_LIST_DIRPATH DESKTOP_CONFIG_PREFIX DESKTOP_CONFIGS_DIR DESKTOP_APPGROUPS_DIR \
|
|
DEBIAN_RECOMMENDS USE_OVERLAYFS aggregated_content DEBOOTSTRAP_COMPONENTS DEBOOTSTRAP_OPTION DEB_COMPRESS MAINTAINER MAINTAINERMAIL EXTRAWIFI BOOTSCRIPT
|
|
}
|
|
|
|
pack_upload ()
|
|
{
|
|
|
|
# pack and upload to server or just pack
|
|
|
|
display_alert "Signing" "Please wait!" "info"
|
|
local version="${VENDOR}_${REVISION}_${BOARD^}_${RELEASE}_${BRANCH}_${VER/-$LINUXFAMILY/}${DESKTOP_ENVIRONMENT:+_$DESKTOP_ENVIRONMENT}"
|
|
compression_type=""
|
|
|
|
[[ $BUILD_DESKTOP == yes ]] && version=${version}_desktop
|
|
[[ $BUILD_MINIMAL == yes ]] && version=${version}_minimal
|
|
[[ $BETA == yes ]] && local subdir=nightly
|
|
[[ $RC == yes ]] && local subdir=rc
|
|
|
|
cd "${DESTIMG}" || exit
|
|
|
|
if [[ $COMPRESS_OUTPUTIMAGE == yes ]]; then
|
|
COMPRESS_OUTPUTIMAGE="sha,gpg,7z"
|
|
fi
|
|
|
|
if [[ $COMPRESS_OUTPUTIMAGE == *gz* ]]; then
|
|
display_alert "Compressing" "$DEST/images/${version}.img.gz" "info"
|
|
pigz "$DESTIMG/${version}.img"
|
|
rm "${DESTIMG}/${version}.img"
|
|
compression_type=".gz"
|
|
fi
|
|
|
|
if [[ $COMPRESS_OUTPUTIMAGE == *xz* ]]; then
|
|
display_alert "Compressing" "$DEST/images/${version}.img.xz" "info"
|
|
pixz -9 < "$DESTIMG/${version}.img" > "${DESTIMG}/${version}.img.xz"
|
|
rm "${DESTIMG}/${version}.img"
|
|
compression_type=".xz"
|
|
fi
|
|
|
|
if [[ $COMPRESS_OUTPUTIMAGE == *sha* ]]; then
|
|
display_alert "SHA256 calculating" "${version}.img" "info"
|
|
sha256sum -b "${version}.img${compression_type}" > "${version}.img${compression_type}.sha"
|
|
fi
|
|
|
|
if [[ $COMPRESS_OUTPUTIMAGE == *gpg* ]]; then
|
|
if [[ -n "${GPG_PASS}" && "${SUDO_USER}" ]]; then
|
|
display_alert "GPG signing" "${version}.img" "info"
|
|
[[ -n ${SUDO_USER} ]] && sudo chown -R ${SUDO_USER}:${SUDO_USER} "${DEST}"/images/
|
|
echo "${GPG_PASS}" | sudo -H -u ${SUDO_USER} bash -c "gpg --passphrase-fd 0 --armor --detach-sign --pinentry-mode loopback --batch --yes ${version}.img${compression_type}" || exit 1
|
|
else
|
|
display_alert "GPG signing skipped - no GPG_PASS" "${version}.img" "wrn"
|
|
fi
|
|
fi
|
|
|
|
fingerprint_image "${version}.img${compression_type}.txt" "${version}"
|
|
|
|
if [[ $COMPRESS_OUTPUTIMAGE == *7z* ]]; then
|
|
display_alert "Compressing" "${version}.7z" "info"
|
|
7za a -t7z -bd -m0=lzma2 -mx=3 -mfb=64 -md=32m -ms=on "${version}".7z "${version}".img* >/dev/null 2>&1
|
|
find . -type f -not -name '*.7z' -print0 | xargs -0 rm --
|
|
fi
|
|
|
|
if [[ -n "${SEND_TO_SERVER}" ]]; then
|
|
ssh "${SEND_TO_SERVER}" "mkdir -p ${SEND_TO_LOCATION}${BOARD}/{archive,nightly}" &
|
|
display_alert "Uploading" "Please wait!" "info"
|
|
nice -n 19 bash -c "rsync -arP --info=progress2 --prune-empty-dirs $DESTIMG/ -e 'ssh -T -c aes128-ctr -o Compression=no -x -p 22' ${SEND_TO_SERVER}:${SEND_TO_LOCATION}${BOARD}/${subdir}; rm -rf ${DESTIMG}/*" &
|
|
else
|
|
mv "${DESTIMG}"/*.* "${DEST}"/images/
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
build_main ()
|
|
{
|
|
# shellcheck source=/dev/null
|
|
source "$USERPATCHES_PATH"/lib.config
|
|
# build images which we do pack or kernel
|
|
local upload_image
|
|
upload_image="${VENDOR}_$(cat "${SRC}"/VERSION)_${BOARD^}_${RELEASE}_${BRANCH}_*${VER/-$LINUXFAMILY/}"
|
|
|
|
[[ $BUILD_DESKTOP == yes ]] && upload_image=${upload_image}_desktop
|
|
[[ $BUILD_MINIMAL == yes ]] && upload_image=${upload_image}_minimal
|
|
|
|
touch "/run/armbian/${VENDOR}_${BOARD^}_${BRANCH}_${RELEASE}_${DESKTOP_ENVIRONMENT}_${BUILD_DESKTOP}_${BUILD_MINIMAL}.pid";
|
|
LOG_SUBPATH="debug/${VENDOR}/${BOARD^}/${BRANCH}/${RELEASE}/${DESKTOP_ENVIRONMENT}_${BUILD_DESKTOP}_${BUILD_MINIMAL}"
|
|
|
|
|
|
if [[ $KERNEL_ONLY != yes ]]; then
|
|
#if ssh ${SEND_TO_SERVER} stat ${SEND_TO_LOCATION}${BOARD}/${upload_subdir}/${upload_image}* \> /dev/null 2\>\&1; then
|
|
# echo "$n exists $upload_image"
|
|
#else
|
|
#shellcheck source=lib/main.sh
|
|
source "${SRC}"/lib/main.sh
|
|
[[ "$BSP_BUILD" != yes && -n "${SEND_TO_SERVER}" ]] && pack_upload
|
|
#fi
|
|
|
|
else
|
|
#shellcheck source=lib/main.sh
|
|
source "${SRC}"/lib/main.sh
|
|
|
|
fi
|
|
|
|
cd "${SRC}"
|
|
rm "/run/armbian/${VENDOR}_${BOARD^}_${BRANCH}_${RELEASE}_${DESKTOP_ENVIRONMENT}_${BUILD_DESKTOP}_${BUILD_MINIMAL}.pid"
|
|
}
|
|
|
|
|
|
|
|
|
|
array_contains ()
|
|
{
|
|
|
|
# utility snippet
|
|
|
|
local array="$1[@]"
|
|
local seeking=$2
|
|
local in=1
|
|
|
|
for element in "${!array}"; do
|
|
if [[ "${element}" == "${seeking}" ]]; then
|
|
in=0
|
|
break
|
|
fi
|
|
done
|
|
return $in
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function check_hash()
|
|
{
|
|
local BOARDFAMILY ref_type ref_name
|
|
|
|
BOARDFAMILY=$(grep BOARDFAMILY "${SRC}/config/boards/${BOARD}".* | cut -d \" -f2)
|
|
# shellcheck source=/dev/null
|
|
source "${SRC}/config/sources/families/${BOARDFAMILY}.conf" &> /dev/null
|
|
# shellcheck source=/dev/null
|
|
source "${SRC}/config/sources/${ARCH}.conf" &> /dev/null
|
|
ref_type=${KERNELBRANCH%%:*}
|
|
if [[ $ref_type == head ]]; then
|
|
ref_name=HEAD
|
|
else
|
|
ref_name=${KERNELBRANCH##*:}
|
|
fi
|
|
[[ -z $LINUXFAMILY ]] && LINUXFAMILY=$BOARDFAMILY
|
|
[[ -z ${KERNELPATCHDIR} ]] && KERNELPATCHDIR=$LINUXFAMILY-$BRANCH
|
|
[[ -z ${LINUXCONFIG} ]] && LINUXCONFIG=linux-$LINUXFAMILY-$BRANCH
|
|
hash_watch_1=$(LC_COLLATE=C find -L "${SRC}/patch/kernel/${KERNELPATCHDIR}"/ -name '*.patch' -mindepth 1 -maxdepth 1 -printf '%s %P\n' 2> /dev/null | LC_COLLATE=C sort -n)
|
|
hash_watch_2=$(cat "${SRC}/config/kernel/${LINUXCONFIG}.config" 2> /dev/null)
|
|
patch_hash=$(echo "${hash_watch_1}${hash_watch_2}" | improved_git hash-object --stdin)
|
|
|
|
case $ref_type in
|
|
branch) hash=$(improved_git ls-remote "${KERNELSOURCE}" refs/heads/"${ref_name}" 2> /dev/null | awk '{print $1}') ;;
|
|
tag) hash=$(improved_git ls-remote "${KERNELSOURCE}" tags/"${ref_name}" 2> /dev/null | awk '{print $1}') ;;
|
|
head) hash=$(improved_git ls-remote "${KERNELSOURCE}" HEAD 2> /dev/null | awk '{print $1}') ;;
|
|
commit) hash=$ref_name ;;
|
|
esac
|
|
# ignore diff checking in case of network errrors
|
|
local kernel_hash="${SRC}/cache/hash"$([[ ${BETA} == yes ]] && echo "-beta")"/linux-image-${BRANCH}-${LINUXFAMILY}.githash"
|
|
if [[ -f ${kernel_hash} ]]; then
|
|
[[ "$hash" == "$(head -1 "${kernel_hash}")" && "$patch_hash" == "$(tail -1 "${kernel_hash}")" || -z $hash ]] && echo "IDENTICAL"
|
|
fi
|
|
}
|
|
|
|
|
|
|
|
|
|
function build_all()
|
|
{
|
|
|
|
# main routine
|
|
|
|
buildall_start=$(date +%s)
|
|
n=0
|
|
ARRAY=()
|
|
buildlist="cat "
|
|
|
|
# building selected ones
|
|
if [[ -n ${REBUILD_IMAGES} ]]; then
|
|
|
|
buildlist="grep -w '"
|
|
filter="'"
|
|
for build in $(tr ',' ' ' <<< "${REBUILD_IMAGES}"); do
|
|
buildlist=$buildlist"$build\|"
|
|
filter=$filter"$build\|"
|
|
done
|
|
buildlist=${buildlist::-2}"'"
|
|
filter=${filter::-2}"'"
|
|
|
|
fi
|
|
|
|
# find unique boards - we will build debs for all variants
|
|
sorted_unique_ids=($(echo "${ids[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
|
|
unique_boards=$(eval "${buildlist}" "${SRC}"/config/targets.conf | sed '/^#/ d' | awk '{print $1}')
|
|
read -r -a unique_boards <<< "$(echo "${unique_boards[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')"
|
|
|
|
while read -r line; do
|
|
|
|
[[ "${line}" =~ ^#.*$ ]] && continue
|
|
[[ -n "${REBUILD_IMAGES}" ]] && [[ -z $(echo "${line}" | eval grep -w "${filter}") ]] && continue
|
|
#[[ $n -lt $START ]] && ((n+=1)) && continue
|
|
|
|
unset_all
|
|
# unset also board related variables
|
|
unset BOARDFAMILY DESKTOP_AUTOLOGIN DEFAULT_CONSOLE FULL_DESKTOP MODULES MODULES_CURRENT MODULES_LEGACY MODULES_EDGE \
|
|
BOOTCONFIG MODULES_BLACKLIST MODULES_BLACKLIST_LEGACY MODULES_BLACKLIST_CURRENT MODULES_BLACKLIST_EDGE DEFAULT_OVERLAYS SERIALCON \
|
|
BUILD_MINIMAL RELEASE ATFBRANCH BOOT_FDT_FILE BOOTCONFIG_EDGE BOOTSOURCEDIR SRC_CMDLINE SRC_EXTLINUX INITRD_ARCH
|
|
|
|
read -r BOARD BRANCH RELEASE BUILD_TARGET BUILD_STABILITY BUILD_IMAGE DESKTOP_ENVIRONMENT DESKTOP_ENVIRONMENT_CONFIG_NAME DESKTOP_APPGROUPS_SELECTED<<< "${line}"
|
|
DESKTOP_APPGROUPS_SELECTED="${DESKTOP_APPGROUPS_SELECTED//,/ }"
|
|
# read all possible configurations
|
|
# shellcheck source=/dev/null
|
|
source "${SRC}/config/boards/${BOARD}".eos 2> /dev/null
|
|
# shellcheck source=/dev/null
|
|
source "${SRC}/config/boards/${BOARD}".tvb 2> /dev/null
|
|
# shellcheck source=/dev/null
|
|
source "${SRC}/config/boards/${BOARD}".csc 2> /dev/null
|
|
# shellcheck source=/dev/null
|
|
source "${SRC}/config/boards/${BOARD}".wip 2> /dev/null
|
|
# shellcheck source=/dev/null
|
|
source "${SRC}/config/boards/${BOARD}".conf 2> /dev/null
|
|
|
|
# override branch to build selected branches if defined
|
|
if [[ -n "${BROVER}" ]]; then
|
|
if [[ "${KERNEL_TARGET}" == *${BROVER}* ]]; then
|
|
BRANCH=${BROVER}
|
|
else
|
|
continue
|
|
fi
|
|
fi
|
|
|
|
# exceptions handling
|
|
[[ ${BOARDFAMILY} == sun*i ]] && BOARDFAMILY=sunxi
|
|
[[ ${BOARDFAMILY} == sun8i-v3s ]] && BOARDFAMILY=sunxi
|
|
[[ ${BOARDFAMILY} == sun*iw* ]] && BOARDFAMILY=sunxi64
|
|
[[ ${BOARDFAMILY} == meson8b ]] && BOARDFAMILY=meson
|
|
[[ ${BOARDFAMILY} == meson-* ]] && BOARDFAMILY=meson64
|
|
# small optimisation. we only (try to) build needed kernels
|
|
if [[ $KERNEL_ONLY == yes ]]; then
|
|
LINUXFAMILY="${BOARDFAMILY}"
|
|
array_contains ARRAY "${LINUXFAMILY}${BRANCH}${BUILD_STABILITY}" && continue
|
|
|
|
elif [[ $BUILD_IMAGE == no ]] ; then
|
|
|
|
continue
|
|
|
|
fi
|
|
ARRAY+=("${LINUXFAMILY}${BRANCH}${BUILD_STABILITY}")
|
|
|
|
BUILD_DESKTOP="no"
|
|
BUILD_MINIMAL="no"
|
|
|
|
[[ ${BUILD_TARGET} == "desktop" && ${BSP_BUILD} != "yes" ]] && BUILD_DESKTOP="yes"
|
|
[[ ${BUILD_TARGET} == "minimal" ]] && BUILD_MINIMAL="yes"
|
|
[[ ${BSP_BUILD} == yes ]] && BUILD_STABILITY=$STABILITY
|
|
|
|
# create a file and put grep style list of the one that must be skipped: sunxi\|sunxi64
|
|
[[ -f userpatches/family.skip ]] && grep -qw "$BOARDFAMILY" userpatches/family.skip && continue
|
|
|
|
# create beta or stable
|
|
if [[ "${BUILD_STABILITY}" == "${STABILITY}" ]]; then
|
|
# check if currnt hash is the same as upstream
|
|
if [[ "$IGNORE_HASH" != yes ]]; then
|
|
local store_hash
|
|
store_hash=$(check_hash)
|
|
fi
|
|
if [[ "$store_hash" != IDENTICAL ]]; then
|
|
|
|
if [[ $1 != "dryrun" ]] && [[ $n -ge $START ]]; then
|
|
((n+=1))
|
|
while :
|
|
do
|
|
if [[ $(find /run/armbian/*.pid 2>/dev/null | wc -l) -le ${MULTITHREAD} || ${MULTITHREAD} -eq 0 ]]; then
|
|
break
|
|
fi
|
|
sleep 5
|
|
done
|
|
|
|
display_alert "Building ${n}."
|
|
if [[ "$KERNEL_ONLY" == "no" && "${MULTITHREAD}" -gt 0 ]]; then
|
|
build_main &
|
|
sleep $((RANDOM % 25))
|
|
elif [[ "${MULTITHREAD}" -gt 0 ]]; then
|
|
build_main &
|
|
sleep $((RANDOM % 5))
|
|
else
|
|
build_main
|
|
fi
|
|
|
|
# create BSP for all boards
|
|
elif [[ "${BSP_BUILD}" == yes ]]; then
|
|
((n+=1))
|
|
for BOARD in "${unique_boards[@]}"
|
|
do
|
|
# shellcheck source=/dev/null
|
|
source "${SRC}/config/boards/${BOARD}".eos 2> /dev/null
|
|
# shellcheck source=/dev/null
|
|
source "${SRC}/config/boards/${BOARD}".tvb 2> /dev/null
|
|
# shellcheck source=/dev/null
|
|
source "${SRC}/config/boards/${BOARD}".csc 2> /dev/null
|
|
# shellcheck source=/dev/null
|
|
source "${SRC}/config/boards/${BOARD}".wip 2> /dev/null
|
|
# shellcheck source=/dev/null
|
|
source "${SRC}/config/boards/${BOARD}".conf 2> /dev/null
|
|
IFS=',' read -r -a RELBRANCH <<< "${KERNEL_TARGET}"
|
|
for BRANCH in "${RELBRANCH[@]}"
|
|
do
|
|
RELTARGETS=($(ls -1d config/distributions/*/ | cut -d"/" -f3))
|
|
# we don't need to cycle all distributions when making u-boot package
|
|
[[ $BOOTONLY == "yes" ]] && RELTARGETS=(focal)
|
|
for RELEASE in "${RELTARGETS[@]}"
|
|
do
|
|
display_alert "BSP for ${BOARD} ${BRANCH} ${RELEASE}."
|
|
if [[ "$IGNORE_HASH" == yes && "$KERNEL_ONLY" != "yes" && "${MULTITHREAD}" -gt 0 ]]; then
|
|
build_main &
|
|
sleep 0.02
|
|
elif [[ "${MULTITHREAD}" -gt 0 ]]; then
|
|
build_main &
|
|
sleep $((RANDOM % 5))
|
|
else
|
|
build_main
|
|
fi
|
|
# unset non board related stuff
|
|
unset_all
|
|
done
|
|
done
|
|
done
|
|
display_alert "Done building all BSP images"
|
|
exit
|
|
else
|
|
((n+=1))
|
|
# In dryrun it only prints out what will be build but also color green if file already exists
|
|
FIND="$SRC/output/images/$BOARD/$upload_subdir/Armbian_$(cat "${SRC}"/VERSION)_${BOARD^}_${RELEASE}_${BRANCH}"
|
|
if ls $FIND* 1> /dev/null 2>&1; then
|
|
echo -ne "\e[0;92m"
|
|
else
|
|
echo -ne "\x1B[0m"
|
|
fi
|
|
printf "%s\t%-32s\t%-8s\t%-14s\t%-6s\t%-6s\t%-6s\t%-6s\n" "${n}." \
|
|
"$BOARD (${BOARDFAMILY})" "${BRANCH}" "${RELEASE}" "${DESKTOP_ENVIRONMENT}" "${BUILD_DESKTOP}" "${BUILD_MINIMAL}" "${DESKTOP_APPGROUPS_SELECTED}"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# at which image to stop
|
|
[[ "$STOP" == "$n" ]] && [[ $1 != "dryrun" ]] && exit
|
|
done < "${BUILD_TARGETS}"
|
|
|
|
}
|
|
|
|
# bump version in case there was a change
|
|
if [[ ${BUMP_VERSION} == yes ]]; then
|
|
|
|
cd "${SRC}" || exit
|
|
CURRENT_VERSION=$(cat VERSION)
|
|
NEW_VERSION="${CURRENT_VERSION%%-trunk}"
|
|
if [[ $CURRENT_VERSION == *trunk* ]]; then
|
|
NEW_VERSION=$(echo "${CURRENT_VERSION}" | cut -d. -f1-3)"."$((${NEW_VERSION##*.} + 1))
|
|
else
|
|
NEW_VERSION=$(echo "${CURRENT_VERSION}" | cut -d. -f1-2)"."$((${NEW_VERSION##*.} + 1))
|
|
fi
|
|
|
|
echo "${NEW_VERSION}" > VERSION
|
|
improved_git add "${SRC}"/VERSION
|
|
improved_git commit -m "Bumping to new version" -m "" -m "Adding following kernels:" -m "$(find output/debs-beta/ -type f -name "linux-image*${CURRENT_VERSION}*.deb" -printf "%f\n" | sort)"
|
|
improved_git push
|
|
display_alert "Bumping to new version" "${NEW_VERSION}" "info"
|
|
|
|
else
|
|
|
|
# display what will be build
|
|
echo ""
|
|
[[ -f userpatches/family.skip ]] && display_alert "userpatches/family.skip exists and familes noted there will be skipped" "" "wrn"
|
|
display_alert "Building all targets" "$STABILITY $(if [[ $KERNEL_ONLY == "yes" ]] ; then echo "kernels"; \
|
|
else echo "images"; fi)" "info"
|
|
|
|
printf "\n%s\t%-32s\t%-8s\t%-14s\t%-6s\t%-6s\t%-6s\t%-6s\n\n" "" "board" "branch" "release" "DE" "desktop" "minimal" "DE app groups"
|
|
|
|
# display what we will build
|
|
build_all "dryrun"
|
|
|
|
if [[ $BUILD_ALL != demo ]] ; then
|
|
|
|
echo ""
|
|
# build
|
|
build_all
|
|
|
|
fi
|
|
|
|
# wait until they are not finshed
|
|
sleep 5
|
|
while :
|
|
do
|
|
if [[ $(df | grep -c /.tmp) -lt 1 ]]; then
|
|
break
|
|
fi
|
|
sleep 5
|
|
done
|
|
|
|
while :
|
|
do
|
|
if [[ -z $(ps -uax | grep 7z | grep Armbian) ]]; then
|
|
break
|
|
fi
|
|
sleep 5
|
|
done
|
|
|
|
fi
|
|
|
|
[[ $n -eq 0 ]] && display_alert "No changes in upstream sources, patches or configs found. Exiting." "info"
|
|
|
|
buildall_end=$(date +%s)
|
|
buildall_runtime=$(((buildall_end - buildall_start) / 60))
|
|
display_alert "Runtime in total" "${buildall_runtime} min" "info"
|
|
mkdir -p .tmp
|
|
echo "${n}" > "${SRC}"/.tmp/n
|
|
|
|
# display what we will build
|
|
build_all "dryrun"
|
|
display_alert "Done"
|