]> git.decadent.org.uk Git - dak.git/commitdiff
process-new: Make again use of Package-List field.
authorAnsgar Burchardt <ansgar@debian.org>
Fri, 1 Aug 2014 17:03:01 +0000 (19:03 +0200)
committerAnsgar Burchardt <ansgar@debian.org>
Fri, 1 Aug 2014 17:03:01 +0000 (19:03 +0200)
dak/process_new.py
daklib/policy.py

index 9f9a39cf2154e4465dddb688798778721c7f235e..cd53dbab369ec74d083b072a402f9502222490c3 100755 (executable)
@@ -125,7 +125,7 @@ def takenover_binaries(upload, missing, session):
     binaries = set([x.package for x in upload.binaries])
     for m in missing:
         if m['type'] != 'dsc':
-            binaries.remove(m['package'])
+            binaries.discard(m['package'])
     if binaries:
         source = upload.binaries[0].source.source
         suite = upload.target_suite.overridesuite or \
index aeed9a2c19cbfb679274520e3418a73f42dc3722..1c6327695766b75ca1297c9a173f90bacc898507 100644 (file)
@@ -20,6 +20,7 @@ from .config import Config
 from .dbconn import BinaryMetadata, Component, MetadataKey, Override, OverrideType, Suite, get_mapped_component
 from .fstransactions import FilesystemTransaction
 from .regexes import re_file_changes, re_file_safe
+from .packagelist import PackageList
 import daklib.utils as utils
 
 import errno
@@ -150,25 +151,14 @@ class PolicyQueueUploadHandler(object):
             .filter(Override.component == component)
         return query.first()
 
-    def _binary_override(self, binary, component_name):
-        package = binary.package
+    def _binary_override(self, name, binarytype, component_name):
         suite = self._overridesuite
-        overridetype = binary.binarytype
         component = get_mapped_component(component_name, self.session)
-        query = self.session.query(Override).filter_by(package=package, suite=suite) \
-            .join(OverrideType).filter(OverrideType.overridetype == overridetype) \
+        query = self.session.query(Override).filter_by(package=name, suite=suite) \
+            .join(OverrideType).filter(OverrideType.overridetype == binarytype) \
             .filter(Override.component == component)
         return query.first()
 
-    def _binary_metadata(self, binary, key):
-        metadata_key = self.session.query(MetadataKey).filter_by(key=key).first()
-        if metadata_key is None:
-            return None
-        metadata = self.session.query(BinaryMetadata).filter_by(binary=binary, key=metadata_key).first()
-        if metadata is None:
-            return None
-        return metadata.value
-
     @property
     def _changes_prefix(self):
         changesname = self.upload.changes.changesname
@@ -253,33 +243,46 @@ class PolicyQueueUploadHandler(object):
         missing = []
         components = set()
 
+        source = self.upload.source
+
         if hints is None:
             hints = []
         hints_map = dict([ ((o['type'], o['package']), o) for o in hints ])
 
-        for binary in self.upload.binaries:
-            priority = self._binary_metadata(binary, 'Priority')
-            section = self._binary_metadata(binary, 'Section')
+        def check_override(name, type, priority, section):
             component = 'main'
             if section.find('/') != -1:
                 component = section.split('/', 1)[0]
-            override = self._binary_override(binary, component)
-            if override is None and not any(o['package'] == binary.package and o['type'] == binary.binarytype for o in missing):
-                hint = hints_map.get((binary.binarytype, binary.package))
+            override = self._binary_override(name, type, component)
+            if override is None and not any(o['package'] == name and o['type'] == type for o in missing):
+                hint = hints_map.get((type, name))
                 if hint is not None:
                     missing.append(hint)
                     component = hint['component']
                 else:
                     missing.append(dict(
-                            package = binary.package,
+                            package = name,
                             priority = priority,
                             section = section,
                             component = component,
-                            type = binary.binarytype,
+                            type = type,
                             ))
             components.add(component)
 
-        source = self.upload.source
+        for binary in self.upload.binaries:
+            binary_proxy = binary.proxy
+            priority = binary_proxy['Priority']
+            section = binary_proxy['Section']
+            check_override(binary.package, binary.binarytype, priority, section)
+
+        if source is not None:
+            source_proxy = source.proxy
+            package_list = PackageList(source_proxy)
+            if not package_list.fallback:
+                packages = package_list.packages_for_suite(self.upload.target_suite)
+                for p in packages:
+                    check_override(p.name, p.type, p.priority, p.section)
+
         source_component = '(unknown)'
         for component, in self.session.query(Component.component_name).order_by(Component.ordering):
             if component in components: