Files
build/lib/functions/cli/cli-rootfs.sh
Ricardo Pardini 6077d40f9b 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()`)
2023-02-18 07:44:26 -03:00

49 lines
2.2 KiB
Bash

function cli_rootfs_pre_run() {
declare -g ARMBIAN_COMMAND_REQUIRE_BASIC_DEPS="yes" # Require prepare_host_basic to run before the command.
# "gimme root on a Linux machine"
cli_standard_relaunch_docker_or_sudo
}
function cli_rootfs_run() {
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 < /dev/null # no stdin for this, so it bombs if tries to be interactive.
}
# This is run inside do_with_default_build(), above.
function cli_rootfs_only_in_default_build() {
LOG_SECTION="prepare_rootfs_build_params_and_trap" do_with_logging prepare_rootfs_build_params_and_trap
LOG_SECTION="calculate_rootfs_cache_id" do_with_logging calculate_rootfs_cache_id
# "rootfs" CLI skips over a lot goes straight to create the rootfs. It doesn't check cache etc.
LOG_SECTION="create_new_rootfs_cache" do_with_logging create_new_rootfs_cache
}