mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
armbian-next: rootfs: build rootfs from CLI, sans-BOARD, sans-FAMILY, etc -- rootfs are meant to be shared
- require ARCH/RELEASE for rootfs cli - disallow BOARD/LINUXFAMILY/BOARDFAMILY being set for rootfs cli - split `prep_conf_main_only_rootfs()` instead of `prep_conf_main_build_single()` for rootfs-only stuff - run both conf and build without stdin for rootfs CLI (no interactive allowed) - don't blindly set `ARCH=armhf` for no reason in main-config - allow skipping family stuff in main-config, via `allow_no_family=yes` (used only in `prep_conf_main_only_rootfs()`) - kill double loading of userpatches family, not needed/old code - allow skipping kernel stuff via `skip_kernel=yes` in `config_pre_main()` (used only in `prep_conf_main_only_rootfs()`)
This commit is contained in:
@@ -6,11 +6,35 @@ function cli_rootfs_pre_run() {
|
||||
}
|
||||
|
||||
function cli_rootfs_run() {
|
||||
# configuration etc - it initializes the extension manager; handles its own logging sections
|
||||
prep_conf_main_build_single
|
||||
declare -a vars_cant_be_set=("BOARD" "LINUXFAMILY" "BOARDFAMILY")
|
||||
# loop through all vars and check if they are set and bomb out
|
||||
for var in "${vars_cant_be_set[@]}"; do
|
||||
if [[ -n ${!var} ]]; then
|
||||
exit_with_error "Param '${var}' is set ('${!var}') but can't be set for rootfs CLI; rootfs's are shared across boards and families."
|
||||
fi
|
||||
done
|
||||
|
||||
declare -a vars_need_to_be_set=("RELEASE" "ARCH") # Maybe the rootfs version?
|
||||
# loop through all vars and check if they are not set and bomb out if so
|
||||
for var in "${vars_need_to_be_set[@]}"; do
|
||||
if [[ -z ${!var} ]]; then
|
||||
exit_with_error "Param '${var}' is not set but needs to be set for rootfs CLI."
|
||||
fi
|
||||
done
|
||||
|
||||
declare -r __wanted_rootfs_arch="${ARCH}"
|
||||
declare -g -r RELEASE="${RELEASE}" # make readonly for finding who tries to change it
|
||||
|
||||
# configuration etc - it initializes the extension manager; handles its own logging sections.
|
||||
prep_conf_main_only_rootfs < /dev/null # no stdin for this, so it bombs if tries to be interactive.
|
||||
|
||||
declare -g -r ARCH="${ARCH}" # make readonly for finding who tries to change it
|
||||
if [[ "${ARCH}" != "${__wanted_rootfs_arch}" ]]; then
|
||||
exit_with_error "Param 'ARCH' is set to '${ARCH}' after config, but different from wanted '${__wanted_rootfs_arch}'"
|
||||
fi
|
||||
|
||||
# default build, but only invoke specific rootfs functions needed. It has its own logging sections.
|
||||
do_with_default_build cli_rootfs_only_in_default_build
|
||||
do_with_default_build cli_rootfs_only_in_default_build < /dev/null # no stdin for this, so it bombs if tries to be interactive.
|
||||
}
|
||||
|
||||
# This is run inside do_with_default_build(), above.
|
||||
|
||||
@@ -200,7 +200,7 @@ function do_main_configuration() {
|
||||
|
||||
# Let's set default data if not defined in board configuration above
|
||||
[[ -z $OFFSET ]] && OFFSET=4 # offset to 1st partition (we use 4MiB boundaries by default)
|
||||
ARCH=armhf
|
||||
[[ -z $ARCH ]] && ARCH=armhf # makes little sense to default to anything...
|
||||
KERNEL_IMAGE_TYPE=zImage
|
||||
ATF_COMPILE=yes
|
||||
[[ -z $WIREGUARD ]] && WIREGUARD="yes"
|
||||
@@ -232,14 +232,11 @@ function do_main_configuration() {
|
||||
family_sourced_ok=$((family_sourced_ok + 1))
|
||||
done
|
||||
|
||||
[[ ${family_sourced_ok} -lt 1 ]] &&
|
||||
exit_with_error "Sources configuration not found" "tried ${family_source_paths[*]}"
|
||||
|
||||
# This is for compatibility only; path above should suffice
|
||||
if [[ -f $USERPATCHES_PATH/sources/families/$LINUXFAMILY.conf ]]; then
|
||||
display_alert "Adding user provided $LINUXFAMILY overrides"
|
||||
# shellcheck source=/dev/null
|
||||
source "$USERPATCHES_PATH/sources/families/${LINUXFAMILY}.conf"
|
||||
# If no families sourced (and not allowed by ext var), bail out
|
||||
if [[ ${family_sourced_ok} -lt 1 ]]; then
|
||||
if [[ "${allow_no_family:-"no"}" != "yes" ]]; then
|
||||
exit_with_error "Sources configuration not found" "tried ${family_source_paths[*]}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# load "all-around common arch defaults" common.conf
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Full version, for building a full image (with BOARD); possibly interactive.
|
||||
function prep_conf_main_build_single() {
|
||||
LOG_SECTION="config_early_init" do_with_conditional_logging config_early_init
|
||||
|
||||
@@ -26,8 +27,27 @@ function prep_conf_main_build_single() {
|
||||
LOG_SECTION="do_extra_configuration" do_with_conditional_logging do_extra_configuration
|
||||
|
||||
LOG_SECTION="config_post_main" do_with_conditional_logging config_post_main
|
||||
|
||||
display_alert "Configuration prepared for build" "${BOARD}.${BOARD_TYPE}" "info"
|
||||
|
||||
display_alert "Configuration prepared for BOARD build" "${BOARD}.${BOARD_TYPE}" "info"
|
||||
}
|
||||
|
||||
# Lean version, for building stuff that doesn't need BOARD/BOARDFAMILY; never interactive.
|
||||
function prep_conf_main_only_rootfs() {
|
||||
LOG_SECTION="config_early_init" do_with_conditional_logging config_early_init
|
||||
|
||||
check_basic_host
|
||||
|
||||
LOG_SECTION="config_pre_main" do_with_conditional_logging config_pre_main
|
||||
|
||||
allow_no_family="yes" \
|
||||
LOG_SECTION="do_main_configuration" do_with_conditional_logging do_main_configuration # This initializes the extension manager among a lot of other things, and call extension_prepare_config() hook
|
||||
|
||||
LOG_SECTION="do_extra_configuration" do_with_conditional_logging do_extra_configuration
|
||||
|
||||
skip_kernel="yes" \
|
||||
LOG_SECTION="config_post_main" do_with_conditional_logging config_post_main
|
||||
|
||||
display_alert "Configuration prepared for non-BOARD build" "prep_conf_main_only_rootfs" "info"
|
||||
}
|
||||
|
||||
function config_source_board_file() {
|
||||
@@ -108,6 +128,7 @@ function config_pre_main() {
|
||||
SELECTED_CONFIGURATION="cli_minimal"
|
||||
fi
|
||||
|
||||
# @TODO: remove this?
|
||||
[[ ${KERNEL_CONFIGURE} == prebuilt ]] && [[ -z ${REPOSITORY_INSTALL} ]] &&
|
||||
REPOSITORY_INSTALL="u-boot,kernel,bsp,armbian-zsh,armbian-config,armbian-bsp-cli,armbian-firmware${BUILD_DESKTOP:+,armbian-desktop,armbian-bsp-desktop}"
|
||||
|
||||
@@ -123,8 +144,12 @@ function config_post_main() {
|
||||
IMAGE_TYPE=user-built
|
||||
fi
|
||||
|
||||
declare -g BOOTSOURCEDIR="u-boot-worktree/${BOOTDIR}/$(branch2dir "${BOOTBRANCH}")"
|
||||
[[ -n $ATFSOURCE ]] && declare -g ATFSOURCEDIR="${ATFDIR}/$(branch2dir "${ATFBRANCH}")"
|
||||
declare -g BOOTSOURCEDIR
|
||||
BOOTSOURCEDIR="u-boot-worktree/${BOOTDIR}/$(branch2dir "${BOOTBRANCH}")"
|
||||
if [[ -n $ATFSOURCE ]]; then
|
||||
declare -g ATFSOURCEDIR
|
||||
ATFSOURCEDIR="${ATFDIR}/$(branch2dir "${ATFBRANCH}")"
|
||||
fi
|
||||
|
||||
declare -g BSP_CLI_PACKAGE_NAME="armbian-bsp-cli-${BOARD}${EXTRA_BSP_NAME}"
|
||||
declare -g BSP_CLI_PACKAGE_FULLNAME="${BSP_CLI_PACKAGE_NAME}_${REVISION}_${ARCH}"
|
||||
@@ -146,43 +171,47 @@ function config_post_main() {
|
||||
# <arch>-<major.minor>[-<family>]
|
||||
# So we gotta explictly know the major.minor to be able to do that scheme.
|
||||
# If we don't know, we could use BRANCH as reference, but that changes over time, and leads to wastage.
|
||||
if [[ -n "${KERNELSOURCE}" ]]; then
|
||||
declare -g ARMBIAN_WILL_BUILD_KERNEL="${CHOSEN_KERNEL}-${ARCH}"
|
||||
if [[ "x${KERNEL_MAJOR_MINOR}x" == "xx" ]]; then
|
||||
exit_with_error "BAD config, missing" "KERNEL_MAJOR_MINOR" "err"
|
||||
fi
|
||||
# assume the worst, and all surprises will be happy ones
|
||||
declare -g KERNEL_HAS_WORKING_HEADERS="no"
|
||||
declare -g KERNEL_HAS_WORKING_HEADERS_FULL_SOURCE="no"
|
||||
if [[ "${skip_kernel:-"no"}" != "yes" ]]; then
|
||||
if [[ -n "${KERNELSOURCE}" ]]; then
|
||||
declare -g ARMBIAN_WILL_BUILD_KERNEL="${CHOSEN_KERNEL}-${ARCH}"
|
||||
if [[ "x${KERNEL_MAJOR_MINOR}x" == "xx" ]]; then
|
||||
exit_with_error "BAD config, missing" "KERNEL_MAJOR_MINOR" "err"
|
||||
fi
|
||||
# assume the worst, and all surprises will be happy ones
|
||||
declare -g KERNEL_HAS_WORKING_HEADERS="no"
|
||||
declare -g KERNEL_HAS_WORKING_HEADERS_FULL_SOURCE="no"
|
||||
|
||||
# Parse/validate the the major, bail if no match
|
||||
declare -i KERNEL_MAJOR_MINOR_MAJOR=${KERNEL_MAJOR_MINOR%%.*}
|
||||
declare -i KERNEL_MAJOR_MINOR_MINOR=${KERNEL_MAJOR_MINOR#*.}
|
||||
# Parse/validate the the major, bail if no match
|
||||
declare -i KERNEL_MAJOR_MINOR_MAJOR=${KERNEL_MAJOR_MINOR%%.*}
|
||||
declare -i KERNEL_MAJOR_MINOR_MINOR=${KERNEL_MAJOR_MINOR#*.}
|
||||
|
||||
if [[ "${KERNEL_MAJOR_MINOR_MAJOR}" -ge 6 ]] || [[ "${KERNEL_MAJOR_MINOR_MAJOR}" -ge 5 && "${KERNEL_MAJOR_MINOR_MINOR}" -ge 4 ]]; then # We support 6.x, and 5.x from 5.4
|
||||
declare -g KERNEL_HAS_WORKING_HEADERS="yes"
|
||||
declare -g KERNEL_MAJOR="${KERNEL_MAJOR_MINOR_MAJOR}"
|
||||
elif [[ "${KERNEL_MAJOR_MINOR_MAJOR}" -eq 4 && "${KERNEL_MAJOR_MINOR_MINOR}" -ge 19 ]]; then
|
||||
declare -g KERNEL_MAJOR=4 # We support 4.19+ (less than 5.0) is supported, and headers via full source
|
||||
declare -g KERNEL_HAS_WORKING_HEADERS_FULL_SOURCE="no" # full-source based headers. experimental. set to yes here to enable
|
||||
elif [[ "${KERNEL_MAJOR_MINOR_MAJOR}" -eq 4 && "${KERNEL_MAJOR_MINOR_MINOR}" -ge 4 ]]; then
|
||||
declare -g KERNEL_MAJOR=4 # We support 4.x from 4.4
|
||||
if [[ "${KERNEL_MAJOR_MINOR_MAJOR}" -ge 6 ]] || [[ "${KERNEL_MAJOR_MINOR_MAJOR}" -ge 5 && "${KERNEL_MAJOR_MINOR_MINOR}" -ge 4 ]]; then # We support 6.x, and 5.x from 5.4
|
||||
declare -g KERNEL_HAS_WORKING_HEADERS="yes"
|
||||
declare -g KERNEL_MAJOR="${KERNEL_MAJOR_MINOR_MAJOR}"
|
||||
elif [[ "${KERNEL_MAJOR_MINOR_MAJOR}" -eq 4 && "${KERNEL_MAJOR_MINOR_MINOR}" -ge 19 ]]; then
|
||||
declare -g KERNEL_MAJOR=4 # We support 4.19+ (less than 5.0) is supported, and headers via full source
|
||||
declare -g KERNEL_HAS_WORKING_HEADERS_FULL_SOURCE="no" # full-source based headers. experimental. set to yes here to enable
|
||||
elif [[ "${KERNEL_MAJOR_MINOR_MAJOR}" -eq 4 && "${KERNEL_MAJOR_MINOR_MINOR}" -ge 4 ]]; then
|
||||
declare -g KERNEL_MAJOR=4 # We support 4.x from 4.4
|
||||
else
|
||||
# If you think you can patch packaging to support this, you're probably right. Is _worth_ it though?
|
||||
exit_with_error "Kernel series unsupported" "'${KERNEL_MAJOR_MINOR}' is unsupported, or bad config"
|
||||
fi
|
||||
|
||||
# Default LINUXSOURCEDIR:
|
||||
declare -g LINUXSOURCEDIR="linux-kernel-worktree/${KERNEL_MAJOR_MINOR}__${LINUXFAMILY}__${ARCH}"
|
||||
|
||||
# Allow adding to it with KERNEL_EXTRA_DIR
|
||||
if [[ "${KERNEL_EXTRA_DIR}" != "" ]]; then
|
||||
declare -g LINUXSOURCEDIR="${LINUXSOURCEDIR}__${KERNEL_EXTRA_DIR}"
|
||||
display_alert "Using kernel extra dir: '${KERNEL_EXTRA_DIR}'" "LINUXSOURCEDIR: ${LINUXSOURCEDIR}" "debug"
|
||||
fi
|
||||
else
|
||||
# If you think you can patch packaging to support this, you're probably right. Is _worth_ it though?
|
||||
exit_with_error "Kernel series unsupported" "'${KERNEL_MAJOR_MINOR}' is unsupported, or bad config"
|
||||
fi
|
||||
|
||||
# Default LINUXSOURCEDIR:
|
||||
declare -g LINUXSOURCEDIR="linux-kernel-worktree/${KERNEL_MAJOR_MINOR}__${LINUXFAMILY}__${ARCH}"
|
||||
|
||||
# Allow adding to it with KERNEL_EXTRA_DIR
|
||||
if [[ "${KERNEL_EXTRA_DIR}" != "" ]]; then
|
||||
declare -g LINUXSOURCEDIR="${LINUXSOURCEDIR}__${KERNEL_EXTRA_DIR}"
|
||||
display_alert "Using kernel extra dir: '${KERNEL_EXTRA_DIR}'" "LINUXSOURCEDIR: ${LINUXSOURCEDIR}" "debug"
|
||||
declare -g KERNEL_HAS_WORKING_HEADERS="yes" # I assume non-Armbian kernels have working headers, eg: Debian/Ubuntu generic do.
|
||||
declare -g ARMBIAN_WILL_BUILD_KERNEL=no
|
||||
fi
|
||||
else
|
||||
declare -g KERNEL_HAS_WORKING_HEADERS="yes" # I assume non-Armbian kernels have working headers, eg: Debian/Ubuntu generic do.
|
||||
declare -g ARMBIAN_WILL_BUILD_KERNEL=no
|
||||
display_alert "Skipping kernel config" "skip_kernel=yes" "warn"
|
||||
fi
|
||||
|
||||
if [[ -n "${BOOTCONFIG}" ]] && [[ "${BOOTCONFIG}" != "none" ]]; then
|
||||
|
||||
@@ -160,7 +160,7 @@ function create_new_rootfs_cache() {
|
||||
declare cache_name=${ARCH}-${RELEASE}-${cache_type}-${packages_hash}-${ROOT_FS_CREATE_VERSION}.tar.zst
|
||||
declare cache_fname=${SRC}/cache/rootfs/${cache_name}
|
||||
|
||||
display_alert "Creating new rootfs cache for" "${RELEASE} ${ROOT_FS_CREATE_VERSION}" "info"
|
||||
display_alert "Creating new rootfs cache for" "'${RELEASE}' '${ARCH}' '${ROOT_FS_CREATE_VERSION}'" "info"
|
||||
|
||||
create_new_rootfs_cache_via_debootstrap # in rootfs-create.sh
|
||||
create_new_rootfs_cache_tarball # in rootfs-create.sh
|
||||
|
||||
Reference in New Issue
Block a user