From 8056532684372c8b2ffb246d4c0cb63b40537fb3 Mon Sep 17 00:00:00 2001 From: ColorfulRhino <131405023+ColorfulRhino@users.noreply.github.com> Date: Sun, 7 Jul 2024 12:58:47 +0200 Subject: [PATCH] cli: main-config: Move `NETWORKING_STACK` config after family config This allows family configs to change the networking stack. --- lib/functions/configuration/main-config.sh | 53 +++++++++++++--------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/lib/functions/configuration/main-config.sh b/lib/functions/configuration/main-config.sh index 0b59b3c3d..56e13c99b 100644 --- a/lib/functions/configuration/main-config.sh +++ b/lib/functions/configuration/main-config.sh @@ -62,7 +62,9 @@ function do_main_configuration() { declare -g SKIP_EXTERNAL_TOOLCHAINS="${SKIP_EXTERNAL_TOOLCHAINS:-yes}" # don't use any external toolchains, by default. # Network stack to use, default to network-manager; configuration can override this. + # Will be made read-only further down. declare -g NETWORKING_STACK="${NETWORKING_STACK}" + # If empty, default depending on BUILD_MINIMAL; if yes, use systemd-networkd; if no, use network-manager. if [[ -z "${NETWORKING_STACK}" ]]; then display_alert "NETWORKING_STACK not set" "Calculating defaults" "debug" @@ -78,27 +80,6 @@ function do_main_configuration() { else display_alert "NETWORKING_STACK is preset during configuration" "NETWORKING_STACK: ${NETWORKING_STACK}" "debug" fi - # Now make it read-only, as further changes would make the whole thing inconsistent. - # Individual networking extensions should _check_ this to make there's no spurious enablement. - display_alert "Using NETWORKING_STACK" "NETWORKING_STACK: ${NETWORKING_STACK}" "info" - declare -g -r NETWORKING_STACK="${NETWORKING_STACK}" - - # Now enable extensions according to the configuration. - case "${NETWORKING_STACK}" in - "network-manager") - display_alert "Adding networking extensions" "net-network-manager, net-chrony" "info" - enable_extension "net-network-manager" - enable_extension "net-chrony" - ;; - "systemd-networkd") - display_alert "Adding networking extensions" "net-systemd-networkd, net-systemd-timesyncd" "info" - enable_extension "net-systemd-networkd" - enable_extension "net-systemd-timesyncd" - ;; - "none" | *) - display_alert "NETWORKING_STACK=${NETWORKING_STACK}" "Not adding networking extensions" "info" - ;; - esac # Timezone if [[ -f /etc/timezone ]]; then # Timezone for target is taken from host, if it exists. @@ -293,7 +274,9 @@ function do_main_configuration() { # single ext4 partition is the default and preferred configuration #BOOTFS_TYPE='' - ## ------ Sourcing family config --------------------------- + ### + ### ------------------- Sourcing family config ------------------- + ### source_family_config_and_arch if [[ "$HAS_VIDEO_OUTPUT" == "no" ]]; then @@ -301,6 +284,32 @@ function do_main_configuration() { [[ $BUILD_DESKTOP != "no" ]] && exit_with_error "HAS_VIDEO_OUTPUT is set to no. So we shouldn't build desktop environment" fi + # Make NETWORKING_STACK read-only, as further changes would make the whole thing inconsistent. + # But only after family config to allow family to change it (post-family hooks CANNOT change NETWORKING_STACK since the hook is running after this). + # Individual networking extensions should _check_ this to make there's no spurious enablement. + display_alert "Using NETWORKING_STACK" "NETWORKING_STACK: ${NETWORKING_STACK}" "info" + declare -g -r NETWORKING_STACK="${NETWORKING_STACK}" + + # Now enable extensions according to the configuration. + case "${NETWORKING_STACK}" in + "network-manager") + display_alert "Adding networking extensions" "net-network-manager, net-chrony" "info" + enable_extension "net-network-manager" + enable_extension "net-chrony" + ;; + "systemd-networkd") + display_alert "Adding networking extensions" "net-systemd-networkd, net-systemd-timesyncd" "info" + enable_extension "net-systemd-networkd" + enable_extension "net-systemd-timesyncd" + ;; + "none") + display_alert "NETWORKING_STACK=${NETWORKING_STACK}" "Not adding networking extensions" "info" + ;; + *) + display_alert "NETWORKING_STACK=${NETWORKING_STACK}" "Invalid value? Not adding networking extensions" "wrn" + ;; + esac + ## Extensions: at this point we've sourced all the config files that will be used, ## and (hopefully) not yet invoked any extension methods. So this is the perfect ## place to initialize the extension manager. It will create functions