From 189aa90314340e75872a018d1246c8ee70377cee Mon Sep 17 00:00:00 2001 From: Sebastien Bacher Date: Mon, 20 Apr 2026 23:23:13 +0200 Subject: [PATCH 1/3] apt_dpkg: use urllib.request instead of http.client to get contents the urllib API works with standard proxy environments Bug: https://launchpad.net/bugs/2116119 --- apport/packaging_impl/apt_dpkg.py | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/apport/packaging_impl/apt_dpkg.py b/apport/packaging_impl/apt_dpkg.py index 10c189db3..9bed83deb 100644 --- a/apport/packaging_impl/apt_dpkg.py +++ b/apport/packaging_impl/apt_dpkg.py @@ -28,7 +28,6 @@ import glob import gzip import hashlib -import http.client import json import logging import os @@ -1625,22 +1624,19 @@ def _fetch_contents_file( """Returns True on success (including when no update is needed).""" url = f"{self._get_mirror(arch)}/dists/{dist}/Contents-{arch}.gz" if mtime: - # HTTPConnection requires server name e.g. - # archive.ubuntu.com - server = urllib.parse.urlparse(url)[1] - conn = http.client.HTTPConnection(server) - conn.request("HEAD", urllib.parse.urlparse(url)[2]) - res = conn.getresponse() - modified_str = res.getheader("last-modified", None) - if modified_str: - modified = datetime.datetime.strptime( - modified_str, "%a, %d %b %Y %H:%M:%S %Z" - ) - if modified <= datetime.datetime.fromtimestamp(mtime): + req = urllib.request.Request(url, method="HEAD") + with contextlib.suppress(OSError): + with urllib.request.urlopen(req) as res: + modified_str = res.getheader("last-modified", None) + if modified_str: + modified = datetime.datetime.strptime( + modified_str, "%a, %d %b %Y %H:%M:%S %Z" + ) + if modified <= datetime.datetime.fromtimestamp(mtime): + return True + # don't update the file if it is empty + if res.getheader("content-length", None) == "40": return True - # don't update the file if it is empty - if res.getheader("content-length", None) == "40": - return True self._contents_update = True try: From db62bd25d622a7c5570700d5739928f892ddb8cc Mon Sep 17 00:00:00 2001 From: Sebastien Bacher Date: Mon, 20 Apr 2026 23:31:57 +0200 Subject: [PATCH 2/3] apt_dpkg: don't disable proxy use to download deb files The use of direct mode was initially added in #85a9737 it seems to workaround infrastructure issues, it worked on PS5 which had direct access to the archive but not on PS7 which have a mandatory proxy. Bug: https://launchpad.net/bugs/2116119 --- apport/packaging_impl/apt_dpkg.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/apport/packaging_impl/apt_dpkg.py b/apport/packaging_impl/apt_dpkg.py index 9bed83deb..5acb1299a 100644 --- a/apport/packaging_impl/apt_dpkg.py +++ b/apport/packaging_impl/apt_dpkg.py @@ -1183,9 +1183,6 @@ def install_packages( apt_pkg.config.clear("APT::Architectures") apt_pkg.config.set("APT::Architectures::", architecture) apt_pkg.config.set("Acquire::Languages", "none") - # directly connect to Launchpad when downloading deb files - apt_pkg.config.set("Acquire::http::Proxy::api.launchpad.net", "DIRECT") - apt_pkg.config.set("Acquire::http::Proxy::launchpad.net", "DIRECT") if not verbose: fetch_progress = apt.progress.base.AcquireProgress() From b43453833559505a3b88f567f131a6b43d4c0860 Mon Sep 17 00:00:00 2001 From: Sebastien Bacher Date: Mon, 20 Apr 2026 23:38:57 +0200 Subject: [PATCH 3/3] apt_dpkg: don't clear the proxy when fetching sources Bug: https://launchpad.net/bugs/2116119 --- apport/packaging_impl/apt_dpkg.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/apport/packaging_impl/apt_dpkg.py b/apport/packaging_impl/apt_dpkg.py index 5acb1299a..1042b5f6e 100644 --- a/apport/packaging_impl/apt_dpkg.py +++ b/apport/packaging_impl/apt_dpkg.py @@ -932,10 +932,6 @@ def get_source_tree( return None sf_urls = self.get_lp_source_package(srcpackage, version) if sf_urls: - proxy = "" - if apt_pkg.config.find("Acquire::http::Proxy") != "": - proxy = apt_pkg.config.find("Acquire::http::Proxy") - apt_pkg.config.set("Acquire::http::Proxy", "") fetch_progress = apt.progress.base.AcquireProgress() fetcher = apt_pkg.Acquire(fetch_progress) af_queue = [] @@ -949,8 +945,6 @@ def get_source_tree( result = fetcher.run() if result != fetcher.RESULT_CONTINUE: return None - if proxy: - apt_pkg.config.set("Acquire::http::Proxy", proxy) for dsc in glob.glob(os.path.join(output_dir, "*.dsc")): subprocess.call( ["dpkg-source", "-sn", "-x", dsc],