X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Farchive.py;h=ca58da87a2858917fda4387173f54fde3796d396;hb=1274df1d98f7004042768c9e2650f5ae9dd79e41;hp=c2cc8392777ce9750e501b6a6e01bb308f301f4a;hpb=9eff87cf703b5fe3310570ab30ff922e62f2957a;p=dak.git diff --git a/daklib/archive.py b/daklib/archive.py index c2cc8392..ca58da87 100644 --- a/daklib/archive.py +++ b/daklib/archive.py @@ -33,6 +33,7 @@ import os import shutil import subprocess from sqlalchemy.orm.exc import NoResultFound +import sqlalchemy.exc import tempfile import traceback @@ -85,7 +86,7 @@ class ArchiveTransaction(object): Will not give an error when the file is already present. @rtype: L{daklib.dbconn.PoolFile} - @return: batabase object for the new file + @return: database object for the new file """ session = self.session @@ -335,6 +336,8 @@ class ArchiveTransaction(object): db_source.suites.append(suite) if not created: + for f in db_source.srcfiles: + self._copy_file(f.poolfile, archive, component, allow_tainted=allow_tainted) return db_source ### Now add remaining files and copy them to the archive. @@ -699,7 +702,7 @@ class ArchiveUpload(object): if src == suite_name: suite_name = dst if rtype != "silent-map": - self.warnings.append('Mapping {0} to {0}.'.format(src, dst)) + self.warnings.append('Mapping {0} to {1}.'.format(src, dst)) elif rtype == "ignore": ignored = fields[1] if suite_name == ignored: @@ -740,17 +743,20 @@ class ArchiveUpload(object): @return: C{True} if the upload is NEW, C{False} otherwise """ session = self.session + new = False # Check for missing overrides for b in self.changes.binaries: override = self._binary_override(suite, b) if override is None: - return True + self.warnings.append('binary:{0} is NEW.'.format(b.control['Package'])) + new = True if self.changes.source is not None: override = self._source_override(suite, self.changes.source) if override is None: - return True + self.warnings.append('source:{0} is NEW.'.format(self.changes.source.dsc['Source'])) + new = True # Check if we reference a file only in a tainted archive files = self.changes.files.values() @@ -764,7 +770,10 @@ class ArchiveUpload(object): in_untainted_archive = (query_untainted.first() is not None) if in_archive and not in_untainted_archive: - return True + self.warnings.append('{0} is only available in NEW.'.format(f.filename)) + new = True + + return new def _final_suites(self): session = self.session @@ -797,8 +806,12 @@ class ArchiveUpload(object): if suite.overridesuite is not None: suite = self.session.query(Suite).filter_by(suite_name=suite.overridesuite).one() + mapped_component = get_mapped_component(binary.component) + if mapped_component is None: + return None + query = self.session.query(Override).filter_by(suite=suite, package=binary.control['Package']) \ - .join(Component).filter(Component.component_name == binary.component) \ + .join(Component).filter(Component.component_name == mapped_component.component_name) \ .join(OverrideType).filter(OverrideType.overridetype == binary.type) try: @@ -992,8 +1005,11 @@ class ArchiveUpload(object): db_changes.changelog_id = changelog_id db_changes.closes = self.changes.closed_bugs - self.transaction.session.add(db_changes) - self.transaction.session.flush() + try: + self.transaction.session.add(db_changes) + self.transaction.session.flush() + except sqlalchemy.exc.IntegrityError: + raise ArchiveException('{0} is already known.'.format(self.changes.filename)) return db_changes @@ -1054,7 +1070,7 @@ class ArchiveUpload(object): remaining.append(f) continue - if rule['Source'] != control['Source'] or rule['Section'] != f.section or rule['Extension'] != ext: + if rule['Source'] != self.changes.source_name or rule['Section'] != f.section or rule['Extension'] != ext: remaining.append(f) continue @@ -1151,7 +1167,14 @@ class ArchiveUpload(object): if policy_queue is not None: redirected_suite = policy_queue.suite - source_suites = self.session.query(Suite).filter(Suite.suite_id.in_([suite.suite_id, redirected_suite.suite_id])).subquery() + # source can be in the suite we install to or any suite we enhance + source_suite_ids = set([suite.suite_id, redirected_suite.suite_id]) + for enhanced_suite_id, in self.session.query(VersionCheck.reference_id) \ + .filter(VersionCheck.suite_id.in_(source_suite_ids)) \ + .filter(VersionCheck.check == 'Enhances'): + source_suite_ids.add(enhanced_suite_id) + + source_suites = self.session.query(Suite).filter(Suite.suite_id.in_(source_suite_ids)).subquery() source_component_func = lambda source: self._source_override(overridesuite, source).component binary_component_func = lambda binary: self._binary_component(overridesuite, binary)