From dabe475067529f5c3d3bda72591298bdb3414fbd Mon Sep 17 00:00:00 2001 From: Mattia Rizzolo Date: Wed, 28 Sep 2022 16:39:41 +0200 Subject: [PATCH] ubuntutools/archive.py: fix crash in SourcePackage()._source_urls() Fix operation of SourcePackage._source_urls() (as used, for example, in SourcePackage.pull() called by backportpackage) to also work when the class is instantiated with a URL as .dsc. This is a regression caused by 1b12d8b4e3315de3bf417b40a3c66279f309d72c (first in v0.184) that moved from os.path.join() to Pathlib, but os.path.join() was also used to join URLs. Thanks: Unit 193 for the initial patch. Signed-off-by: Mattia Rizzolo --- debian/changelog | 14 +++++++++++--- ubuntutools/archive.py | 13 ++++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index 1178aba..4b56d25 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,7 @@ ubuntu-dev-tools (0.191) UNRELEASED; urgency=medium - [ Mattia Rizzolo ] * WIP. + [ Dan Streetman ] * lpapicache: + Make sure that login() actually logins and doesn't use cached credentials. @@ -10,8 +10,16 @@ ubuntu-dev-tools (0.191) UNRELEASED; urgency=medium operation mode from authenticated to anonymous. LP: #1984113 [ Stefano Rivera ] - * backportpackage: Add support for lsb-release-minimal, which doesn't have a - Python module, thanks Gioele Barabucci. (Closes: 1020901) + * backportpackage: + + Add support for lsb-release-minimal, which doesn't have a Python module. + Thanks to Gioele Barabucci for the patch. Closes: #1020901 + + [ Mattia Rizzolo ] + * ubuntutools/archive.py: + + Fix operation of SourcePackage._source_urls() (as used, for example, in + SourcePackage.pull() called by backportpackage) to also work when the + class is instantiated with a URL as .dsc. Fixes regression from v0.184. + Thanks to Unit 193 for the initial patch. -- Mattia Rizzolo Mon, 22 Aug 2022 17:55:53 +0200 diff --git a/ubuntutools/archive.py b/ubuntutools/archive.py index e04a4a8..f131efc 100644 --- a/ubuntutools/archive.py +++ b/ubuntutools/archive.py @@ -27,7 +27,7 @@ Approach: 3. Verify checksums. """ -from urllib.request import urlopen +from urllib.request import urlopen, urlparse, urljoin import codecs import functools import json @@ -168,7 +168,9 @@ class SourcePackage(ABC): self._series = series self._pocket = pocket self._status = status - self._dsc_source = Path(dscfile) if dscfile else None + # dscfile can be either a path or an URL. misc.py's download() will + # later fiture it out + self._dsc_source = dscfile self._verify_signature = verify_signature # Cached values: @@ -323,7 +325,12 @@ class SourcePackage(ABC): def _source_urls(self, name): "Generator of sources for name" if self._dsc_source: - yield str(self._dsc_source.parent / name) + # we only take "" as file, as regardless if for some reason this + # is a file:// url we still need to handle it with urljoin + if urlparse(str(self._dsc_source)).scheme == "": + yield str(Path(self._dsc_source).parent / name) + else: + yield urljoin(self._dsc_source, name) for server in self._archive_servers(): yield self._mirror_url(server, self.component, name) if self.lp_spph.sourceFileUrl(name):