diff --git a/lib/functions/configuration/main-config.sh b/lib/functions/configuration/main-config.sh index 670973630d..869f311b60 100644 --- a/lib/functions/configuration/main-config.sh +++ b/lib/functions/configuration/main-config.sh @@ -362,7 +362,7 @@ function do_extra_configuration() { APT_MIRROR=$UBUNTU_MIRROR fi - [[ -n $APT_PROXY_ADDR ]] && display_alert "Using custom apt-cacher-ng address" "$APT_PROXY_ADDR" "info" + [[ -n "${APT_PROXY_ADDR}" ]] && display_alert "Using custom apt proxy address" "APT_PROXY_ADDR=${APT_PROXY_ADDR}" "info" # @TODO: allow to run aggregation, for CONFIG_DEFS_ONLY? rootfs_aggregate_packages diff --git a/lib/functions/host/apt-cacher-ng.sh b/lib/functions/host/apt-cacher-ng.sh index 0f5f74e83f..655e351ffc 100644 --- a/lib/functions/host/apt-cacher-ng.sh +++ b/lib/functions/host/apt-cacher-ng.sh @@ -2,8 +2,7 @@ function acng_configure_and_restart_acng() { if ! armbian_is_host_running_systemd; then return 0; fi # do nothing if host is not running systemd - [[ $NO_APT_CACHER == yes ]] && return 0 # don't if told not to. NO_something=yes is very confusing, but kept for historical reasons - [[ "${APT_PROXY_ADDR:-localhost:3142}" != "localhost:3142" ]] && return 0 # also not if acng not local to builder machine + [[ "${MANAGE_ACNG}" != "yes" ]] && return 0 # don't if told not to. NO_something=yes is very confusing, but kept for historical reasons display_alert "Preparing acng configuration" "apt-cacher-ng" "info" @@ -55,8 +54,7 @@ function acng_configure_and_restart_acng() { } function acng_check_status_or_restart() { - [[ $NO_APT_CACHER == yes ]] && return 0 # don't if told not to - [[ "${APT_PROXY_ADDR:-localhost:3142}" != "localhost:3142" ]] && return 0 # also not if acng not local to builder machine + [[ "${MANAGE_ACNG}" != "yes" ]] && return 0 # don't if told not to if ! systemctl -q is-active apt-cacher-ng.service; then display_alert "ACNG systemd service is not active" "restarting apt-cacher-ng" "warn" diff --git a/lib/functions/host/prepare-host.sh b/lib/functions/host/prepare-host.sh index eba1fd82e7..a160372cf9 100644 --- a/lib/functions/host/prepare-host.sh +++ b/lib/functions/host/prepare-host.sh @@ -69,7 +69,11 @@ prepare_host() { if armbian_is_running_in_container; then display_alert "Running in container" "Adding provisions for container building" "info" declare -g CONTAINER_COMPAT=yes # this controls mknod usage for loop devices. - declare -g NO_APT_CACHER=yes # disable apt-cacher; we use local cache in Docker volumes. + + if [[ "${MANAGE_ACNG}" == "yes" ]]; then + display_alert "Running in container" "Disabling ACNG - MANAGE_ACNG=yes not supported in containers" "warn" + declare -g MANAGE_ACNG=no + fi # trying to use nested containers is not a good idea, so don't permit EXTERNAL_NEW=compile if [[ $EXTERNAL_NEW == compile ]]; then @@ -279,10 +283,8 @@ function adaptative_prepare_host_dependencies() { host_dependencies+=("python2" "python2-dev") fi - # warning: apt-cacher-ng will fail if installed and used both on host and in container/chroot environment with shared network - # set NO_APT_CACHER=yes to prevent installation errors in such case - # @TODO: invert this logic. MANAGE_ACNG=yes - if [[ $NO_APT_CACHER != yes ]]; then + # Only install acng if asked to. + if [[ "${MANAGE_ACNG}" == "yes" ]]; then host_dependencies+=("apt-cacher-ng") fi diff --git a/lib/functions/logging/runners.sh b/lib/functions/logging/runners.sh index 796704cef5..45c3a00fa5 100644 --- a/lib/functions/logging/runners.sh +++ b/lib/functions/logging/runners.sh @@ -21,10 +21,22 @@ function chroot_sdcard_apt_get() { acng_check_status_or_restart # make sure apt-cacher-ng is running OK. local -a apt_params=("-y") - [[ $NO_APT_CACHER != yes ]] && apt_params+=( - -o "Acquire::http::Proxy=\"http://${APT_PROXY_ADDR:-localhost:3142}\"" - -o "Acquire::http::Proxy::localhost=\"DIRECT\"" - ) + if [[ "${MANAGE_ACNG}" == "yes" ]]; then + display_alert "Using managed apt-cacher-ng" "http://localhost:3142" "debug" + apt_params+=( + -o "Acquire::http::Proxy=\"http://${APT_PROXY_ADDR:-"localhost:3142"}\"" + -o "Acquire::http::Proxy::localhost=\"DIRECT\"" + ) + elif [[ -n "${APT_PROXY_ADDR}" ]]; then + display_alert "Using unmanaged apt mirror" "http://${APT_PROXY_ADDR}" "debug" + apt_params+=( + -o "Acquire::http::Proxy=\"http://${APT_PROXY_ADDR}\"" + -o "Acquire::http::Proxy::localhost=\"DIRECT\"" + ) + else + display_alert "Not using apt-cacher-ng, nor proxy" "no proxy/acng" "debug" + fi + apt_params+=(-o "Dpkg::Use-Pty=0") # Please be quiet if [[ "${DONT_MAINTAIN_APT_CACHE:-no}" == "yes" ]]; then diff --git a/lib/functions/rootfs/create-cache.sh b/lib/functions/rootfs/create-cache.sh index 898aff3370..b8445c1264 100644 --- a/lib/functions/rootfs/create-cache.sh +++ b/lib/functions/rootfs/create-cache.sh @@ -98,11 +98,11 @@ get_or_create_rootfs_cache_chroot_sdcard() { function create_new_rootfs_cache() { # this is different between debootstrap and regular apt-get; here we use acng as a prefix to the real repo local debootstrap_apt_mirror="http://${APT_MIRROR}" - if [[ $NO_APT_CACHER != yes ]]; then - local debootstrap_apt_mirror="http://${APT_PROXY_ADDR:-localhost:3142}/${APT_MIRROR}" + if [[ "${MANAGE_ACNG}" == "yes" ]]; then + local debootstrap_apt_mirror="http://localhost:3142/${APT_MIRROR}" acng_check_status_or_restart fi - + # @TODO: one day: https://gitlab.mister-muffin.de/josch/mmdebstrap/src/branch/main/mmdebstrap display_alert "Installing base system" "Stage 1/2" "info"