Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 12 additions & 25 deletions apport/packaging_impl/apt_dpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import glob
import gzip
import hashlib
import http.client
Comment thread
bdrung marked this conversation as resolved.
import json
import logging
import os
Expand Down Expand Up @@ -933,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 = []
Expand All @@ -950,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],
Expand Down Expand Up @@ -1184,9 +1177,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()
Expand Down Expand Up @@ -1625,22 +1615,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:
Expand Down
Loading