summaryrefslogtreecommitdiff
path: root/build-helpers.sh
diff options
context:
space:
mode:
authorDave Hibberd <hibby@debian.org>2026-11-28 16:30:22 +0000
committerDave Hibberd <hibby@debian.org>2026-11-28 16:30:22 +0000
commit733ad130eec9ed0e5ca26e6be307d59e1a04754d (patch)
tree050cc5943b5c5b66eb87500f09411c9fbcf381e6 /build-helpers.sh
parenteda7adbdb24670ea908cb185c451761d2e9d98a0 (diff)
Redo build helper to use avahi for proxy discoveryHEADmain
Diffstat (limited to 'build-helpers.sh')
-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