From 497a3a80aba601374fea893a040ad5cc0b316836 Mon Sep 17 00:00:00 2001 From: Ricardo Pardini Date: Thu, 27 Oct 2022 22:26:36 +0200 Subject: [PATCH] armbian-next: `cli`: de-hardcode `build` and `docker`'s interdependence, via `DOCKER_CLI_CMD` - `undecided` now directly sends to `build`, which might send to `docker`, which relaunches `build` in Docker; - the _sending to Docker_ part probably needs refactor --- lib/functions/cli/cli-build.sh | 1 + lib/functions/cli/cli-docker.sh | 6 ++---- lib/functions/cli/cli-undecided.sh | 11 ++--------- lib/functions/cli/entrypoint.sh | 1 + 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/lib/functions/cli/cli-build.sh b/lib/functions/cli/cli-build.sh index 07e8ac134f..7cfbd2394b 100644 --- a/lib/functions/cli/cli-build.sh +++ b/lib/functions/cli/cli-build.sh @@ -15,6 +15,7 @@ function cli_standard_build_pre_run() { if is_docker_ready_to_go; then # add the current user EUID as a parameter when it's relaunched under docker. SET_OWNER_TO_UID="${EUID}" display_alert "Trying to build, not root, but Docker is ready to go" "delegating to Docker" "debug" + ARMBIAN_CLI_RELAUNCH_PARAMS+=(["DOCKER_CLI_CMD"]="build") # add params when relaunched under docker ARMBIAN_CHANGE_COMMAND_TO="docker" return 0 fi diff --git a/lib/functions/cli/cli-docker.sh b/lib/functions/cli/cli-docker.sh index d3dc1a36f0..92b02e3d9a 100644 --- a/lib/functions/cli/cli-docker.sh +++ b/lib/functions/cli/cli-docker.sh @@ -6,11 +6,9 @@ function cli_docker_pre_run() { # make sure we're not _ALREADY_ running under docker... otherwise eternal loop? if [[ "${ARMBIAN_RUNNING_IN_CONTAINER}" == "yes" ]]; then - display_alert "wtf" "asking for docker... inside docker; turning to build command" "warn" - # @TODO: wrong, what if we wanna run other stuff inside Docker? not build? - ARMBIAN_CHANGE_COMMAND_TO="build" + display_alert "DOCKER_CLI_CMD" "asking for docker... inside docker; turning to '${DOCKER_CLI_CMD}' command" "warn" + ARMBIAN_CHANGE_COMMAND_TO="${DOCKER_CLI_CMD}" fi - } function cli_docker_run() { diff --git a/lib/functions/cli/cli-undecided.sh b/lib/functions/cli/cli-undecided.sh index 85eeac4391..38cc533a16 100644 --- a/lib/functions/cli/cli-undecided.sh +++ b/lib/functions/cli/cli-undecided.sh @@ -1,14 +1,7 @@ function cli_undecided_pre_run() { # If undecided, run the 'build' command. - # 'build' will then defer to 'docker' if ran on Darwin. - # so save a trip, check if we're on Darwin right here. - if [[ "$(uname)" == "Linux" ]]; then - display_alert "Linux!" "func cli_undecided_pre_run go to build" "debug" - ARMBIAN_CHANGE_COMMAND_TO="build" - else - display_alert "Not under Linux; use docker..." "func cli_undecided_pre_run go to docker" "debug" - ARMBIAN_CHANGE_COMMAND_TO="docker" - fi + display_alert "cli_undecided_pre_run" "func cli_undecided_pre_run go to build" "debug" + ARMBIAN_CHANGE_COMMAND_TO="build" } function cli_undecided_run() { diff --git a/lib/functions/cli/entrypoint.sh b/lib/functions/cli/entrypoint.sh index e88e320f1c..eafb2a4028 100644 --- a/lib/functions/cli/entrypoint.sh +++ b/lib/functions/cli/entrypoint.sh @@ -58,6 +58,7 @@ function cli_entrypoint() { while [[ "${ARMBIAN_CHANGE_COMMAND_TO}" != "" ]]; do display_alert "Still a command to pre-run, this time:" "${ARMBIAN_CHANGE_COMMAND_TO}" "debug" + declare -g ARMBIAN_COMMAND_REQUIRE_BASIC_DEPS="no" # reset this before every pre_run, so only the last one wins. ARMBIAN_COMMAND="${ARMBIAN_CHANGE_COMMAND_TO}" armbian_prepare_cli_command_to_run "${ARMBIAN_COMMAND}"