summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuild-helpers.sh25
1 files changed, 19 insertions, 6 deletions
diff --git a/build-helpers.sh b/build-helpers.sh
index 4b38162..1a55a84 100755
--- a/build-helpers.sh
+++ b/build-helpers.sh
@@ -790,16 +790,29 @@ extract_date() {
return 0
}
+# Discover a local APT caching proxy using Zeroconf.
+# Resolve to IPv4 on the host to avoid mDNS dependencies in chroots.
+# Honour an explicitly supplied APT_PROXY, including an empty value.
-# Discover a local APT caching proxy unless explicitly configured.
if [ -z "${APT_PROXY+x}" ]; then
APT_PROXY=""
- if command -v auto-apt-proxy >/dev/null 2>&1; then
- APT_PROXY="$(AUTO_APT_PROXY_NO_WAIT_ONLINE=1 \
- AUTO_APT_PROXY_NO_CACHE=1 \
- AUTO_APT_PROXY_AVAHI_NAME=1 \
- auto-apt-proxy)" || APT_PROXY=""
+ if command -v avahi-browse >/dev/null 2>&1 &&
+ command -v curl >/dev/null 2>&1; then
+
+ APT_PROXY="$(avahi-browse -prt _apt_proxy._tcp 2>/dev/null |
+ awk -F';' '$1 == "=" && $3 == "IPv4" && !found {
+ print "http://" $8 ":" $9
+ found=1
+ }')" || APT_PROXY=""
+
+ # Verify the discovered cache is reachable.
+ if [ -n "$APT_PROXY" ]; then
+ if ! curl -fsS --connect-timeout 2 --max-time 5 \
+ "$APT_PROXY/acng-report.html" >/dev/null 2>&1; then
+ APT_PROXY=""
+ fi
+ fi
fi
fi