tests/as-debootstrap-unshare-wrapper: allow disabling auto-apt-proxy by setting an empty http_proxy environment variable

This commit is contained in:
Johannes Schauer Marin Rodrigues 2025-03-09 12:56:05 +01:00
parent bf6aaa30ac
commit b04758b133
Signed by: josch
GPG key ID: F2CBA5C78FBD83E1
2 changed files with 10 additions and 6 deletions

View file

@ -7,7 +7,7 @@ while [ "$#" -gt 0 ]; do
key="$1"
case "$key" in
SUDO)
SUDO=sudo
SUDO="sudo --preserve-env"
;;
*)
echo "Unknown argument: $key"
@ -33,6 +33,7 @@ ret=0
ret=0
(
exec 3>&- 4>&-
# shellcheck disable=SC2086
env --chdir=./shared $SUDO sh -x ./test.sh 2>&1
) || ret=$?
echo $ret >&3

View file

@ -28,11 +28,14 @@ fi
# https://bugs.debian.org/1031105
# https://salsa.debian.org/installer-team/debootstrap/-/merge_requests/90
AUTOPROXY=
eval "$(apt-config shell AUTOPROXY Acquire::http::Proxy-Auto-Detect)"
if [ -n "$AUTOPROXY" ] && [ -x "$AUTOPROXY" ] && [ -e /tmp/.auto-apt-proxy-0 ]; then
TMP_APT_CONFIG=$(mktemp)
echo 'Dir "/dev/null";' >"$TMP_APT_CONFIG"
chmod 644 "$TMP_APT_CONFIG"
# allow an empty http_proxy variable to disable this
if [ -n "${http_proxy-}" ]; then
eval "$(apt-config shell AUTOPROXY Acquire::http::Proxy-Auto-Detect)"
if [ -n "$AUTOPROXY" ] && [ -x "$AUTOPROXY" ] && [ -e /tmp/.auto-apt-proxy-0 ]; then
TMP_APT_CONFIG=$(mktemp)
echo 'Dir "/dev/null";' >"$TMP_APT_CONFIG"
chmod 644 "$TMP_APT_CONFIG"
fi
fi
$prefix {{ CMD }} --variant=custom --mode={{ MODE }} \