diff --git a/lib/functions/cli/cli-build.sh b/lib/functions/cli/cli-build.sh index 2f4ac084bc55..5a57c3b4cf71 100644 --- a/lib/functions/cli/cli-build.sh +++ b/lib/functions/cli/cli-build.sh @@ -10,6 +10,8 @@ function cli_standard_build_pre_run() { declare -g ARMBIAN_COMMAND_REQUIRE_BASIC_DEPS="yes" # Require prepare_host_basic to run before the command. + ensure_loop_exists + # "gimme root on a Linux machine" cli_standard_relaunch_docker_or_sudo } diff --git a/lib/functions/cli/cli-docker.sh b/lib/functions/cli/cli-docker.sh index f4e8be0e7d9b..9ff6ac6b2e62 100644 --- a/lib/functions/cli/cli-docker.sh +++ b/lib/functions/cli/cli-docker.sh @@ -40,6 +40,8 @@ function cli_docker_run() { set_git_build_repo_url_and_commit_vars "docker launcher" fi + ensure_loop_exists + LOG_SECTION="docker_cli_prepare" do_with_logging docker_cli_prepare # @TODO: and can be very well said that in CI, we always want FAST_DOCKER=yes, unless we're building the Docker image itself. diff --git a/lib/functions/host/host-utils.sh b/lib/functions/host/host-utils.sh index 362035dc67e5..2abed9066c09 100644 --- a/lib/functions/host/host-utils.sh +++ b/lib/functions/host/host-utils.sh @@ -99,7 +99,7 @@ function is_root_or_sudo_prefix() { elif [[ -n "$(command -v doas)" ]]; then # doas binary found in path, use it. display_alert "EUID is not 0" "doas binary found, using it" "debug" - __my_sudo_prefix="sudo" + __my_sudo_prefix="doas" else # No root and no sudo binary. Bail out exit_with_error "EUID is not 0 and no sudo binary found - Please install sudo or run as root" diff --git a/lib/functions/image/loop.sh b/lib/functions/image/loop.sh index 446919ef44cb..a00d21a77bae 100644 --- a/lib/functions/image/loop.sh +++ b/lib/functions/image/loop.sh @@ -116,3 +116,9 @@ function free_loop_device_retried() { fi losetup -d "${1}" } + +# Runs losetup -f as root to ensure that there is a /dev/loopX or /dev/loopXY device existing and available +function ensure_loop_exists() { + local sudo_prefix="" && is_root_or_sudo_prefix sudo_prefix + ${sudo_prefix} losetup -f +}