[linux-signed] 01/03: debian/bin/sign.py: Introduce specific exception classes
debian-kernel at lists.debian.org
debian-kernel at lists.debian.org
Fri Jan 6 02:24:17 UTC 2017
This is an automated email from the git hooks/post-receive script.
benh pushed a commit to branch sid
in repository linux-signed.
commit e7c575e0a766f5416db8c83faa616e921130900c
Author: Ben Hutchings <ben at decadent.org.uk>
Date: Fri Jan 6 01:54:53 2017 +0000
debian/bin/sign.py: Introduce specific exception classes
---
debian/bin/sign.py | 23 +++++++++++++++--------
debian/changelog | 1 +
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/debian/bin/sign.py b/debian/bin/sign.py
index b5c201b..32aeeb0 100755
--- a/debian/bin/sign.py
+++ b/debian/bin/sign.py
@@ -10,6 +10,12 @@ import gc
from debian_linux.config import ConfigCoreDump
from debian_linux.debian import VersionLinux
+class ArchiveMetadataError(Exception):
+ pass
+
+class MissingPackageError(Exception):
+ pass
+
_release_data = {}
def get_release_data(mirror, suite):
@@ -43,7 +49,7 @@ def get_release_data(mirror, suite):
if not re.search(r'^\[GNUPG:\]\s+VALIDSIG\s', codecs.decode(output),
re.MULTILINE):
os.write(2, output) # bytes not str!
- raise Exception('gpgv rejected %s' % url)
+ raise ArchiveMetadataError('gpgv rejected %s' % url)
release_stream = io.TextIOWrapper(io.BytesIO(release_raw), 'utf-8')
@@ -68,11 +74,11 @@ def get_packages_data(mirror, suite, arch):
# Validate against Release file
if len(packages_raw) != int(file_data['size']):
- raise Exception('%s has wrong size' % url)
+ raise ArchiveMetadataError('%s has wrong size' % url)
h = hashlib.sha256()
h.update(packages_raw)
if h.digest() != bytes.fromhex(file_data['sha256']):
- raise Exception('%s has wrong checksum' % url)
+ raise ArchiveMetadataError('%s has wrong checksum' % url)
packages_stream = io.TextIOWrapper(
io.BytesIO(lzma.decompress(packages_raw)), 'utf-8')
@@ -97,11 +103,12 @@ def get_package(mirror, suite, name, version, arch):
if not os.path.isfile(package_file):
packages_data = get_packages_data(mirror, suite, arch)
if name not in packages_data:
- raise Exception('package %s is not available' % name)
+ raise MissingPackageError('package %s is not available' % name)
package_data = packages_data[name]
if package_data['Version'] != version:
- raise Exception('package %s version %s is not available; only version %s' %
- (name, version, package_data['Version']))
+ raise MissingPackageError(
+ 'package %s version %s is not available; only version %s' %
+ (name, version, package_data['Version']))
url = urllib.parse.urljoin(mirror, package_data['Filename'])
print('I: Fetching %s' % url)
with urllib.request.urlopen(url) as req:
@@ -109,11 +116,11 @@ def get_package(mirror, suite, name, version, arch):
# Validate against Packages file
if len(package) != int(package_data['Size']):
- raise Exception('%s has wrong size' % url)
+ raise ArchiveMetadataError('%s has wrong size' % url)
h = hashlib.sha256()
h.update(package)
if h.digest() != bytes.fromhex(package_data['SHA256']):
- raise Exception('%s has wrong checksum' % url)
+ raise ArchiveMetadataError('%s has wrong checksum' % url)
with open(package_file, 'wb') as f:
f.write(package)
diff --git a/debian/changelog b/debian/changelog
index 1d26b91..3347266 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ linux-signed (3.4) UNRELEASED; urgency=medium
* debian/control: Correct syntax of Built-Using field (Closes: #846488)
* debian/rules: Use dpkg-parsechangelog -S option to select fields
+ * debian/bin/sign.py: Introduce specific exception classes
-- Ben Hutchings <ben at decadent.org.uk> Fri, 09 Dec 2016 12:48:17 +0000
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/linux-signed.git
More information about the Kernel-svn-changes
mailing list