X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fpolicy.py;h=aa5f12f0ac141e10e04552c11449ff842618cea2;hb=7452ea84e72920178f3af1a717e7f034b5164449;hp=1c6327695766b75ca1297c9a173f90bacc898507;hpb=3b13cf984701df7e1167f12ca20394f8891a62ba;p=dak.git diff --git a/daklib/policy.py b/daklib/policy.py index 1c632769..aa5f12f0 100644 --- a/daklib/policy.py +++ b/daklib/policy.py @@ -17,7 +17,7 @@ """module to process policy queue uploads""" from .config import Config -from .dbconn import BinaryMetadata, Component, MetadataKey, Override, OverrideType, Suite, get_mapped_component +from .dbconn import BinaryMetadata, Component, MetadataKey, Override, OverrideType, Suite, get_mapped_component, get_mapped_component_name from .fstransactions import FilesystemTransaction from .regexes import re_file_changes, re_file_safe from .packagelist import PackageList @@ -87,7 +87,7 @@ class UploadCopy(object): for byhand in self.upload.byhand: src = os.path.join(queue.path, byhand.filename) dst = os.path.join(directory, byhand.filename) - if not os.path.exists(dst) or not ignore_existing: + if os.path.exists(src) and (not os.path.exists(dst) or not ignore_existing): fs.copy(src, dst, mode=mode, symlink=symlink) # copy .changes @@ -249,7 +249,7 @@ class PolicyQueueUploadHandler(object): hints = [] hints_map = dict([ ((o['type'], o['package']), o) for o in hints ]) - def check_override(name, type, priority, section): + def check_override(name, type, priority, section, included): component = 'main' if section.find('/') != -1: component = section.split('/', 1)[0] @@ -266,6 +266,7 @@ class PolicyQueueUploadHandler(object): section = section, component = component, type = type, + included = included )) components.add(component) @@ -273,7 +274,7 @@ class PolicyQueueUploadHandler(object): binary_proxy = binary.proxy priority = binary_proxy['Priority'] section = binary_proxy['Section'] - check_override(binary.package, binary.binarytype, priority, section) + check_override(binary.package, binary.binarytype, priority, section, included=True) if source is not None: source_proxy = source.proxy @@ -281,20 +282,16 @@ class PolicyQueueUploadHandler(object): 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) + check_override(p.name, p.type, p.priority, p.section, included=False) - source_component = '(unknown)' - for component, in self.session.query(Component.component_name).order_by(Component.ordering): - if component in components: - source_component = component - break - else: - if source is not None: - if self._source_override(component) is not None: - source_component = component - break + # see daklib.archive.source_component_from_package_list + # which we cannot use here as we might not have a Package-List + # field for old packages + mapped_components = [ get_mapped_component_name(c) for c in components ] + query = self.session.query(Component).order_by(Component.ordering) \ + .filter(Component.component_name.in_(mapped_components)) + source_component = query.first().component_name - if source is not None: override = self._source_override(source_component) if override is None: hint = hints_map.get(('dsc', source.source)) @@ -302,14 +299,15 @@ class PolicyQueueUploadHandler(object): missing.append(hint) else: section = 'misc' - if component != 'main': - section = "{0}/{1}".format(component, section) + if source_component != 'main': + section = "{0}/{1}".format(source_component, section) missing.append(dict( package = source.source, priority = 'extra', section = section, component = source_component, type = 'dsc', + included = True, )) return missing