From bb5af8d977c37a187eaa1661bfc9f0f2512a0745 Mon Sep 17 00:00:00 2001 From: Ansgar Burchardt Date: Wed, 12 Aug 2015 09:58:02 +0200 Subject: [PATCH] Fix handling of mapped components in process-new I really would like to get rid of mapped components on security-master... --- daklib/dbconn.py | 16 +++++++++++----- daklib/policy.py | 5 +++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/daklib/dbconn.py b/daklib/dbconn.py index a599e5c1..973fa797 100644 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -691,6 +691,16 @@ def get_component(component, session=None): __all__.append('get_component') +def get_mapped_component_name(component_name): + cnf = Config() + for m in cnf.value_list("ComponentMappings"): + (src, dst) = m.split() + if component_name == src: + component_name = dst + return component_name + +__all__.append('get_mapped_component_name') + @session_wrapper def get_mapped_component(component_name, session=None): """get component after mappings @@ -709,11 +719,7 @@ def get_mapped_component(component_name, session=None): @rtype: L{daklib.dbconn.Component} or C{None} @return: component after applying maps or C{None} """ - cnf = Config() - for m in cnf.value_list("ComponentMappings"): - (src, dst) = m.split() - if component_name == src: - component_name = dst + component_name = get_mapped_component_name(component_name) component = session.query(Component).filter_by(component_name=component_name).first() return component diff --git a/daklib/policy.py b/daklib/policy.py index dad9e9d1..3c986c80 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 @@ -287,8 +287,9 @@ class PolicyQueueUploadHandler(object): # 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_(components)) + .filter(Component.component_name.in_(mapped_components)) source_component = query.first().component_name override = self._source_override(source_component) -- 2.39.5