armbian-next: apt-cacher-ng is now optional and activated via MANAGE_ACNG=yes; drop NO_APT_CACHER

- acng is constant source of headaches
- we don't need it anymore, since we have local caching now
- You can also have acng running on a different machine/container and set `APT_PROXY_ADDR=xxx:3142` if you're running a build farm
This commit is contained in:
Ricardo Pardini
2023-01-11 15:08:16 +01:00
parent d4d3c1346c
commit 93c8ce99af
5 changed files with 29 additions and 17 deletions

View File

@@ -362,7 +362,7 @@ function do_extra_configuration() {
APT_MIRROR=$UBUNTU_MIRROR APT_MIRROR=$UBUNTU_MIRROR
fi 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 # @TODO: allow to run aggregation, for CONFIG_DEFS_ONLY? rootfs_aggregate_packages

View File

@@ -2,8 +2,7 @@
function acng_configure_and_restart_acng() { function acng_configure_and_restart_acng() {
if ! armbian_is_host_running_systemd; then return 0; fi # do nothing if host is not running systemd 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 [[ "${MANAGE_ACNG}" != "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
display_alert "Preparing acng configuration" "apt-cacher-ng" "info" 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() { function acng_check_status_or_restart() {
[[ $NO_APT_CACHER == yes ]] && return 0 # don't if told not to [[ "${MANAGE_ACNG}" != "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
if ! systemctl -q is-active apt-cacher-ng.service; then if ! systemctl -q is-active apt-cacher-ng.service; then
display_alert "ACNG systemd service is not active" "restarting apt-cacher-ng" "warn" display_alert "ACNG systemd service is not active" "restarting apt-cacher-ng" "warn"

View File

@@ -69,7 +69,11 @@ prepare_host() {
if armbian_is_running_in_container; then if armbian_is_running_in_container; then
display_alert "Running in container" "Adding provisions for container building" "info" 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 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 # trying to use nested containers is not a good idea, so don't permit EXTERNAL_NEW=compile
if [[ $EXTERNAL_NEW == compile ]]; then if [[ $EXTERNAL_NEW == compile ]]; then
@@ -279,10 +283,8 @@ function adaptative_prepare_host_dependencies() {
host_dependencies+=("python2" "python2-dev") host_dependencies+=("python2" "python2-dev")
fi fi
# warning: apt-cacher-ng will fail if installed and used both on host and in container/chroot environment with shared network # Only install acng if asked to.
# set NO_APT_CACHER=yes to prevent installation errors in such case if [[ "${MANAGE_ACNG}" == "yes" ]]; then
# @TODO: invert this logic. MANAGE_ACNG=yes
if [[ $NO_APT_CACHER != yes ]]; then
host_dependencies+=("apt-cacher-ng") host_dependencies+=("apt-cacher-ng")
fi fi

View File

@@ -21,10 +21,22 @@ function chroot_sdcard_apt_get() {
acng_check_status_or_restart # make sure apt-cacher-ng is running OK. acng_check_status_or_restart # make sure apt-cacher-ng is running OK.
local -a apt_params=("-y") local -a apt_params=("-y")
[[ $NO_APT_CACHER != yes ]] && apt_params+=( if [[ "${MANAGE_ACNG}" == "yes" ]]; then
-o "Acquire::http::Proxy=\"http://${APT_PROXY_ADDR:-localhost:3142}\"" display_alert "Using managed apt-cacher-ng" "http://localhost:3142" "debug"
-o "Acquire::http::Proxy::localhost=\"DIRECT\"" 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 apt_params+=(-o "Dpkg::Use-Pty=0") # Please be quiet
if [[ "${DONT_MAINTAIN_APT_CACHE:-no}" == "yes" ]]; then if [[ "${DONT_MAINTAIN_APT_CACHE:-no}" == "yes" ]]; then

View File

@@ -98,11 +98,11 @@ get_or_create_rootfs_cache_chroot_sdcard() {
function create_new_rootfs_cache() { 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 # 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}" local debootstrap_apt_mirror="http://${APT_MIRROR}"
if [[ $NO_APT_CACHER != yes ]]; then if [[ "${MANAGE_ACNG}" == "yes" ]]; then
local debootstrap_apt_mirror="http://${APT_PROXY_ADDR:-localhost:3142}/${APT_MIRROR}" local debootstrap_apt_mirror="http://localhost:3142/${APT_MIRROR}"
acng_check_status_or_restart acng_check_status_or_restart
fi fi
# @TODO: one day: https://gitlab.mister-muffin.de/josch/mmdebstrap/src/branch/main/mmdebstrap # @TODO: one day: https://gitlab.mister-muffin.de/josch/mmdebstrap/src/branch/main/mmdebstrap
display_alert "Installing base system" "Stage 1/2" "info" display_alert "Installing base system" "Stage 1/2" "info"