From: Ansgar Burchardt Date: Tue, 18 Sep 2012 21:23:05 +0000 (+0200) Subject: Merge branch 'small-fixes' X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=40f8f2bba7deb4ff9cce6250aeab90c93db4c372;hp=e5394a9508746d2b4f55ca9668fc087da37b8d30;p=dak.git Merge branch 'small-fixes' --- diff --git a/daklib/archive.py b/daklib/archive.py index 677d783c..0f3a316e 100644 --- a/daklib/archive.py +++ b/daklib/archive.py @@ -950,7 +950,7 @@ class ArchiveUpload(object): if suite.copychanges: src = os.path.join(self.directory, self.changes.filename) dst = os.path.join(suite.archive.path, 'dists', suite.suite_name, self.changes.filename) - self.transaction.fs.copy(src, dst) + self.transaction.fs.copy(src, dst, mode=suite.archive.mode) return (db_source, db_binaries) @@ -998,7 +998,7 @@ class ArchiveUpload(object): self.transaction.session.flush() dst = os.path.join(policy_queue.path, self.changes.filename) - self.transaction.fs.copy(self.changes.path, dst) + self.transaction.fs.copy(self.changes.path, dst, mode=policy_queue.change_perms) return u @@ -1075,7 +1075,7 @@ class ArchiveUpload(object): src = os.path.join(self.directory, hashed_file.filename) dst = os.path.join(policy_queue.path, hashed_file.filename) - fs.copy(src, dst) + fs.copy(src, dst, mode=policy_queue.change_perms) return byhand_file diff --git a/daklib/checks.py b/daklib/checks.py index 2e76e783..f073d52f 100644 --- a/daklib/checks.py +++ b/daklib/checks.py @@ -30,10 +30,12 @@ from daklib.regexes import * from daklib.textutils import fix_maintainer, ParseMaintError import daklib.lintian as lintian import daklib.utils as utils +from daklib.upload import InvalidHashException import apt_inst import apt_pkg from apt_pkg import version_compare +import errno import os import time import yaml @@ -165,13 +167,25 @@ class ChangesCheck(Check): class HashesCheck(Check): """Check hashes in .changes and .dsc are valid.""" def check(self, upload): - changes = upload.changes - for f in changes.files.itervalues(): - f.check(upload.directory) - source = changes.source - if source is not None: - for f in source.files.itervalues(): + what = None + try: + changes = upload.changes + what = changes.filename + for f in changes.files.itervalues(): f.check(upload.directory) + source = changes.source + what = source.filename + if source is not None: + for f in source.files.itervalues(): + f.check(upload.directory) + except IOError as e: + if e.errno == errno.ENOENT: + raise Reject('{0} refers to non-existing file: {1}\n' + 'Perhaps you need to include it in your upload?' + .format(what, os.path.basename(e.filename))) + raise + except InvalidHashException as e: + raise Reject('{0}: {1}'.format(what, unicode(e))) class ExternalHashesCheck(Check): """Checks hashes in .changes and .dsc against an external database.""" diff --git a/daklib/upload.py b/daklib/upload.py index c55c4090..dcd008aa 100644 --- a/daklib/upload.py +++ b/daklib/upload.py @@ -439,6 +439,10 @@ class Source(object): raise InvalidSourceException("Multiple .dsc found ({0} and {1})".format(self._dsc_file.filename, f.filename)) else: self._dsc_file = f + + # make sure the hash for the dsc is valid before we use it + self._dsc_file.check(directory) + dsc_file_path = os.path.join(directory, self._dsc_file.filename) data = open(dsc_file_path, 'r').read() self._signed_file = SignedFile(data, keyrings, require_signature) @@ -489,3 +493,10 @@ class Source(object): if len(fields) > 1: return fields[0] return "main" + + @property + def filename(self): + """filename of .dsc file + @type: str + """ + return self._dsc_file.filename