From ff94b79e60b932b9efb88ce808476e7dd4b9b48c Mon Sep 17 00:00:00 2001 From: Ricardo Pardini Date: Tue, 17 Jan 2023 01:11:43 +0100 Subject: [PATCH] armbian-next: do basic host checks before config if interactive, or during prepare-host if not - group basic checks at `check_basic_host()` --- lib/functions/host/prepare-host.sh | 18 ++++++++++++------ lib/functions/main/config-prepare.sh | 5 +++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/functions/host/prepare-host.sh b/lib/functions/host/prepare-host.sh index 0ab5570030..829f94d136 100644 --- a/lib/functions/host/prepare-host.sh +++ b/lib/functions/host/prepare-host.sh @@ -6,17 +6,23 @@ # * changes system settings # function prepare_host() { - # Those are not logged, and might be interactive. - display_alert "Checking" "host" "info" - obtain_and_check_host_release_and_arch # sets HOSTRELEASE and validates it for sanity; also HOSTARCH - check_windows_wsl2 # checks if on Windows, on WSL2, (not 1) and exits if not supported - check_host_has_enough_disk_space # Checks disk space and exits if not enough - wait_for_package_manager # wait until dpkg is not locked... + # Now, if NOT interactive, do some basic checks. If interactive, those have already run back in prepare_and_config_main_build_single() + if [[ ! -t 1 ]]; then + LOG_SECTION="ni_check_basic_host" do_with_logging check_basic_host + fi LOG_SECTION="prepare_host_noninteractive" do_with_logging prepare_host_noninteractive return 0 } +function check_basic_host() { + display_alert "Checking" "basic host setup" "info" + obtain_and_check_host_release_and_arch # sets HOSTRELEASE and validates it for sanity; also HOSTARCH + check_host_has_enough_disk_space # Checks disk space and exits if not enough + check_windows_wsl2 # checks if on Windows, on WSL2, (not 1) and exits if not supported + wait_for_package_manager # wait until dpkg is not locked... +} + function prepare_host_noninteractive() { display_alert "Preparing" "host" "info" diff --git a/lib/functions/main/config-prepare.sh b/lib/functions/main/config-prepare.sh index 0898549010..b7be2022ae 100644 --- a/lib/functions/main/config-prepare.sh +++ b/lib/functions/main/config-prepare.sh @@ -3,6 +3,11 @@ function prepare_and_config_main_build_single() { LOG_SECTION="config_early_init" do_with_conditional_logging config_early_init + # if interactive, call prepare-host.sh::check_basic_host() early, to avoid disappointments later. + if [[ -t 1 ]]; then + check_basic_host + fi + # those are possibly interactive. interactive (dialog) and logging don't mix, for obvious reasons. interactive_config_prepare_terminal # init vars used for interactive config_possibly_interactive_kernel_board