From 4c66fba4d963436572514905e30f7a631f895cf0 Mon Sep 17 00:00:00 2001 From: Robie Basak Date: Fri, 30 Jun 2017 15:44:52 +0100 Subject: [PATCH 1/3] pull-debian-source: --no-verify-signature option Using pull-debian-source fails on some very old packages such as on texinfo 4.8.dfsg.1-4. I have hand-verified that the signature is good (though with no trust path), so presumably this is because the signature has rotated out of debian-keyring. Add a --no-verify-signature option so that developers can still make use of the find-and-download functionality of this tool, albeit without signture verification. --- pull-debian-source | 4 ++++ ubuntutools/archive.py | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pull-debian-source b/pull-debian-source index d4e0519..e323376 100755 --- a/pull-debian-source +++ b/pull-debian-source @@ -89,6 +89,10 @@ def main(): parser.add_option('--no-conf', dest='no_conf', default=False, action='store_true', help="Don't read config files or environment variables") + parser.add_option('--no-verify-signature', + dest='verify_signature', default=True, + action='store_false', + help="Allow signature verification failure") (options, args) = parser.parse_args() if not args: parser.error('Must specify package name') diff --git a/ubuntutools/archive.py b/ubuntutools/archive.py index 9324313..b3f5b79 100644 --- a/ubuntutools/archive.py +++ b/ubuntutools/archive.py @@ -303,10 +303,10 @@ class SourcePackage(object): else: Logger.info(message) - def _write_dsc(self): + def _write_dsc(self, verify_signature=True): "Write dsc file to workdir" if self._dsc is None: - self.pull_dsc() + self.pull_dsc(verify_signature=verify_signature) with open(self.dsc_pathname, 'wb') as f: f.write(self.dsc.raw_text) @@ -359,9 +359,9 @@ class SourcePackage(object): return False return True - def pull(self): + def pull(self, verify_signature=True): "Pull into workdir" - self._write_dsc() + self._write_dsc(verify_signature=verify_signature) for entry in self.dsc['Files']: name = entry['name'] for url in self._source_urls(name): @@ -471,7 +471,7 @@ class DebianSourcePackage(SourcePackage): if self.snapshot_list: yield self._snapshot_url(name) - def pull_dsc(self): + def pull_dsc(self, verify_signature=True): "Retrieve dscfile and parse" try: super(DebianSourcePackage, self).pull_dsc() @@ -489,7 +489,7 @@ class DebianSourcePackage(SourcePackage): break else: raise DownloadError('dsc could not be found anywhere') - self._check_dsc(verify_signature=True) + self._check_dsc(verify_signature=verify_signature) # Local methods: @property From a761ccfc72b5d0ca7b8716a94f66994b08d9c708 Mon Sep 17 00:00:00 2001 From: Robie Basak Date: Fri, 30 Jun 2017 15:43:46 +0100 Subject: [PATCH 2/3] Fix rmadison parsing for Python 3 In Python 3, it matters that the output of rmadison must be decoded before it can be parsed. --- ubuntutools/archive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubuntutools/archive.py b/ubuntutools/archive.py index b3f5b79..0e6e219 100644 --- a/ubuntutools/archive.py +++ b/ubuntutools/archive.py @@ -636,7 +636,7 @@ def rmadison(url, package, suite=None, arch=None): # pylint bug: http://www.logilab.org/ticket/46273 # pylint: disable=E1103 - for line in output.strip().splitlines(): + for line in output.decode().strip().splitlines(): # pylint: enable=E1103 pkg, ver, dist, archs = [x.strip() for x in line.split('|')] comp = 'main' From 0291ad07b079134dd7627eaa255a34c599ba1c6c Mon Sep 17 00:00:00 2001 From: Robie Basak Date: Fri, 30 Jun 2017 15:42:04 +0100 Subject: [PATCH 3/3] pull-debian-source: convert to Python 3 This has the (desired) side effect of fixing the guessing of the correct encoding in dsc files when not UTF-8. Presumably this is because Python 3 has some improvements in that area. Since it's what we want, I see no need to dig further. LP: #1700846 --- pull-debian-source | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pull-debian-source b/pull-debian-source index e323376..6bfc5fb 100755 --- a/pull-debian-source +++ b/pull-debian-source @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # pull-debian-source -- pull a source package from Launchpad # Copyright (C) 2011, Stefano Rivera @@ -19,7 +19,8 @@ import json import optparse import sys -import urllib2 +import urllib.request +import urllib.error from distro_info import DebianDistroInfo, DistroDataOutdated @@ -54,17 +55,17 @@ def source_package_for(binary, release): """Query DDE to find the source package for a particular binary""" try: release = DebianDistroInfo().codename(release, default=release) - except DistroDataOutdated, e: + except DistroDataOutdated as e: Logger.warn(e) url = ('http://dde.debian.net/dde/q/udd/dist/d:debian/r:%s/p:%s/?t=json' % (release, binary)) data = None try: - data = json.load(urllib2.urlopen(url))['r'] - except urllib2.URLError, e: + data = json.load(urllib.request.urlopen(url))['r'] + except urllib.error.URLError as e: Logger.error('Unable to retrieve package information from DDE: ' '%s (%s)', url, str(e)) - except ValueError, e: + except ValueError as e: Logger.error('Unable to parse JSON response from DDE: ' '%s (%s)', url, str(e)) if not data: @@ -132,8 +133,8 @@ def main(): mirrors=[options.debian_mirror, options.debsec_mirror]) try: - srcpkg.pull() - except DownloadError, e: + srcpkg.pull(verify_signature=options.verify_signature) + except DownloadError as e: Logger.error('Failed to download: %s', str(e)) sys.exit(1) if not options.download_only: