Package: auto-apt-proxy
Version: 3
Severity: wishlist
Tags: patch

With an extra fix added.

-- System Information:
Debian Release: buster/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386, armhf

Kernel: Linux 4.11.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages auto-apt-proxy depends on:
ii  apt  1.5

Versions of packages auto-apt-proxy recommends:
ii  iproute2  4.9.0-2

auto-apt-proxy suggests no packages.

-- no debconf information

-- debsums errors found:
debsums: changed file /usr/bin/auto-apt-proxy (from auto-apt-proxy package)
>From d884e2b204544bf021c442b930eb9a7fa51a30bf Mon Sep 17 00:00:00 2001
From: Thadeu Lima de Souza Cascardo <casca...@cascardo.eti.br>
Date: Thu, 19 Oct 2017 13:56:06 -0200
Subject: [PATCH 1/2] Use better values for apt options.

apt considers DIRECT as a special value for Proxy. The only reason none
is not used is because the URI parser will not set the host part of it.

Just as well, Proxy-Auto-Detect value is the command to run to detect a
proxy. So, it should really be set to the empty value. Older apt
versions required using an extra empty argument to set empty values. But
newer versions interpret such an extra argument as the action, so it
doesn't work. See bug #693092 for details. However, the documentation
claims and the code shows that if there is a proxy set for the given
host, including the DIRECT option, Proxy-Auto-Detect is ignored and not
run at all.

Signed-off-by: Thadeu Lima de Souza Cascardo <casca...@debian.org>
---
 auto-apt-proxy   | 7 +++----
 debian/changelog | 7 +++++++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/auto-apt-proxy b/auto-apt-proxy
index df3632b..cdab044 100755
--- a/auto-apt-proxy
+++ b/auto-apt-proxy
@@ -10,15 +10,14 @@ trap cleanup INT EXIT TERM
 
 hit() {
   /usr/lib/apt/apt-helper \
-    -o Acquire::http::Proxy-Auto-Detect=none \
-    -o Acquire::http::Proxy=none \
+    -o Acquire::http::Proxy=DIRECT \
     download-file "$@" "$tmpfile" 2>&1
 }
 
 detect_apt_cacher_ng() {
   local ip="$1"
   local proxy=http://$ip:3142
-  if hit -o "Acquire::http::Proxy::${ip}=none" "$proxy" | grep -q -i 
'406.*usage.information'; then
+  if hit -o "Acquire::http::Proxy::${ip}=DIRECT" "$proxy" | grep -q -i 
'406.*usage.information'; then
     echo "$proxy"
     exit
   fi
@@ -27,7 +26,7 @@ detect_apt_cacher_ng() {
 detect_approx() {
   local ip="$1"
   local proxy=http://$ip:9999
-  hit -o "Acquire::http::Proxy::${ip}=none" "$proxy" >/dev/null 2>&1 || true;
+  hit -o "Acquire::http::Proxy::${ip}=DIRECT" "$proxy" >/dev/null 2>&1 || true;
   if [ -s "$tmpfile" ] && grep -q -i '<title>approx\s*server</title>' 
"$tmpfile"; then
     echo "$proxy"
     exit
diff --git a/debian/changelog b/debian/changelog
index 3ff3b94..cff9776 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+auto-apt-proxy (4) UNRELEASED; urgency=medium
+
+  * Use DIRECT for proxies values and ignore
+    Acquire::http::Proxy-Auto-Detect.
+
+ -- Thadeu Lima de Souza Cascardo <casca...@siri.cascardo.eti.br>  Thu, 19 Oct 
2017 13:53:41 -0200
+
 auto-apt-proxy (3) unstable; urgency=medium
 
   * Add support for detecting approx
-- 
2.15.0.rc1

>From 7899d42c22c0feb30c95b2dd21ad8b5cd26abd70 Mon Sep 17 00:00:00 2001
From: Thadeu Lima de Souza Cascardo <casca...@cascardo.eti.br>
Date: Thu, 19 Oct 2017 14:05:20 -0200
Subject: [PATCH 2/2] Add support for apt-cacher.

Signed-off-by: Thadeu Lima de Souza Cascardo <casca...@debian.org>
---
 auto-apt-proxy   | 11 +++++++++++
 debian/changelog |  1 +
 debian/control   |  1 +
 3 files changed, 13 insertions(+)

diff --git a/auto-apt-proxy b/auto-apt-proxy
index cdab044..96fa1ca 100755
--- a/auto-apt-proxy
+++ b/auto-apt-proxy
@@ -14,6 +14,16 @@ hit() {
     download-file "$@" "$tmpfile" 2>&1
 }
 
+detect_apt_cacher() {
+  local ip="$1"
+  local proxy=http://$ip:3142
+  hit -o "Acquire::http::Proxy::${ip}=DIRECT" "$proxy" >/dev/null 2>&1 || true;
+  if [ -s "$tmpfile" ] && grep -q -i '<title>Apt-cacher' "$tmpfile"; then
+    echo "$proxy"
+    exit
+  fi
+}
+
 detect_apt_cacher_ng() {
   local ip="$1"
   local proxy=http://$ip:3142
@@ -41,4 +51,5 @@ fi
 for ip in 127.0.0.1 $gateway; do
   detect_apt_cacher_ng "$ip"
   detect_approx "$ip"
+  detect_apt_cacher "$ip"
 done
diff --git a/debian/changelog b/debian/changelog
index cff9776..96be8be 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ auto-apt-proxy (4) UNRELEASED; urgency=medium
 
   * Use DIRECT for proxies values and ignore
     Acquire::http::Proxy-Auto-Detect.
+  * Add support for apt-cacher.
 
  -- Thadeu Lima de Souza Cascardo <casca...@siri.cascardo.eti.br>  Thu, 19 Oct 
2017 13:53:41 -0200
 
diff --git a/debian/control b/debian/control
index dc1f713..2e99706 100644
--- a/debian/control
+++ b/debian/control
@@ -33,6 +33,7 @@ Description: automatic detector of common APT proxy settings
  The following APT proxy servers are supported and automatically detected:
    * apt-cacher-ng
    * approx
+   * apt-cacher
  .
  This package has a minimal set of dependencies in order to minimize the
  influence on systems where it is installed.
-- 
2.15.0.rc1

Reply via email to