From 86276665cdc767bae2f1632fb26ac7c55dbee272 Mon Sep 17 00:00:00 2001 From: Dan Streetman Date: Mon, 12 Jul 2021 18:16:25 -0400 Subject: [PATCH] archive: Update PersonalPackageArchiveSourcePackage to handle private PPA Unfortunately private PPAs require downloading files from the special server private-ppa.launchpad.net, and all the usual urls provided by the LP api fail. So add code to handle using those custom private URLs, and use authentication when downloading. --- ubuntutools/archive.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ubuntutools/archive.py b/ubuntutools/archive.py index 67af659..c0f9230 100644 --- a/ubuntutools/archive.py +++ b/ubuntutools/archive.py @@ -659,6 +659,27 @@ class PersonalPackageArchiveSourcePackage(UbuntuSourcePackage): Logger.debug(f"Using PPA '{ppa.web_link}'") return ppa + def _private_ppa_url(self, filename): + "Format the URL for a filename using the private PPA server" + url = self.getArchive().getMySubscriptionURL() + pkg = self.source + subdir = pkg[:4] if pkg.startswith('lib') else pkg[:1] + return f'{url}/pool/main/{subdir}/{pkg}/{filename}' + + def _source_urls(self, name): + "Generator of sources for name" + if self.getArchive().private: + yield self._private_ppa_url(name) + else: + yield super()._source_urls(name) + + def _binary_urls(self, name, bpph): + "Generator of URLs for name" + if self.getArchive().private: + yield self._private_ppa_url(name) + else: + yield super()._binary_urls(name, bpph) + class UbuntuCloudArchiveSourcePackage(PersonalPackageArchiveSourcePackage): "Download / unpack an Ubuntu Cloud Archive source package"