[Piuparts-commits] rev 908 - in trunk: . debian
Holger Levsen
holger at alioth.debian.org
Thu Jul 7 13:19:04 UTC 2011
Author: holger
Date: 2011-07-07 13:19:03 +0000 (Thu, 07 Jul 2011)
New Revision: 908
Modified:
trunk/debian/changelog
trunk/piuparts.py
Log:
Make piuparts use proxy settings either from apt configuration or
http_proxy environment variable, the latter overwriting the former (if
present) - Thanks to Scott Schaefer for the patch. (Closes: #632046)
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2011-06-27 07:17:41 UTC (rev 907)
+++ trunk/debian/changelog 2011-07-07 13:19:03 UTC (rev 908)
@@ -3,6 +3,9 @@
* Apply patch by Scott Schaefer to fix (Closes: 526045) ...
needs proper changelog entry...
* piuparts-report.py: correct a typo from the patch for #523950.
+ * Make piuparts use proxy settings either from apt configuration or
+ http_proxy environment variable, the latter overwriting the former (if
+ present) - Thanks to Scott Schaefer for the patch. (Closes: #632046)
-- Holger Levsen <holger at debian.org> Sat, 25 Jun 2011 23:33:49 +0200
Modified: trunk/piuparts.py
===================================================================
--- trunk/piuparts.py 2011-06-27 07:17:41 UTC (rev 907)
+++ trunk/piuparts.py 2011-07-07 13:19:03 UTC (rev 908)
@@ -677,15 +677,33 @@
def create_apt_conf(self):
"""Create /etc/apt/apt.conf inside the chroot."""
- create_file(self.relative("etc/apt/apt.conf"),
- 'APT::Get::AllowUnauthenticated "%s";\n' % settings.apt_unauthenticated +
- 'APT::Get::Assume-Yes "yes";\n' +
- 'APT::Install-Recommends "0";\n' +
- 'APT::Install-Suggests "0";\n')
+ lines = [
+ 'APT::Get::Assume-Yes "yes";\n',
+ 'APT::Install-Recommends "0";\n',
+ 'APT::Install-Suggests "0";\n',
+ ]
+ lines.append('APT::Get::AllowUnauthenticated "%s";\n' % settings.apt_unauthenticated)
+ if "HTTP_PROXY" in os.environ:
+ proxy = os.environ["HTTP_PROXY"]
+ else:
+ proxy = None;
+ pat = re.compile(r"^Acquire::http::Proxy\s+\"([^\"]+)\"", re.I);
+ p = subprocess.Popen(["apt-config", "dump"],
+ stdout=subprocess.PIPE)
+ stdout, _ = p.communicate()
+ if stdout:
+ for line in stdout.split("\n"):
+ m = re.match(pat, line)
+ if proxy is None and m:
+ proxy = m.group(1)
+ if proxy:
+ lines.append('Acquire::http::Proxy "%s";\n' % proxy)
if settings.dpkg_force_confdef:
- append_to_file(self.relative("etc/apt/apt.conf"),
- 'Dpkg::Options {"--force-confdef";};\n')
+ lines.append('Dpkg::Options {"--force-confdef";};\n')
+ create_file(self.relative("etc/apt/apt.conf"),
+ "".join(lines))
+
def create_dpkg_conf(self):
"""Create /etc/dpkg/dpkg.cfg.d/piuparts inside the chroot."""
if settings.dpkg_force_confdef:
More information about the Piuparts-commits
mailing list