diff --git a/britney.py b/britney.py index 98e94e0..bb01c00 100755 --- a/britney.py +++ b/britney.py @@ -563,6 +563,7 @@ class Britney(object): provides, False, pkg_id, + [], ) src_data.binaries.add(pkg_id) @@ -658,6 +659,7 @@ class Britney(object): [], False, pkg_id, + [], ) src_data.binaries.add(pkg_id) target_suite.binaries[arch][pkg_name] = bin_data diff --git a/britney2/__init__.py b/britney2/__init__.py index 46fbef1..9fa3050 100644 --- a/britney2/__init__.py +++ b/britney2/__init__.py @@ -215,4 +215,5 @@ BinaryPackage = namedtuple('BinaryPackage', [ 'provides', 'is_essential', 'pkg_id', + 'builtusing', ]) diff --git a/britney2/inputs/suiteloader.py b/britney2/inputs/suiteloader.py index 1a9dc40..de00563 100644 --- a/britney2/inputs/suiteloader.py +++ b/britney2/inputs/suiteloader.py @@ -6,7 +6,7 @@ import sys from britney2 import SuiteClass, Suite, TargetSuite, Suites, BinaryPackage, BinaryPackageId, SourcePackage from britney2.utils import ( - read_release_file, possibly_compressed, read_sources_file, create_provides_map, parse_provides + read_release_file, possibly_compressed, read_sources_file, create_provides_map, parse_provides, parse_builtusing ) @@ -258,6 +258,12 @@ class DebMirrorLikeSuiteContentLoader(SuiteContentLoader): raise AssertionError("%s has wrong architecture (%s) - should be either %s or all" % ( str(pkg_id), raw_arch, arch)) + builtusing_raw = get_field('Built-Using') + if builtusing_raw: + builtusing = parse_builtusing(builtusing_raw, pkg_id=pkg_id, logger=self.logger) + else: + builtusing = [] + dpkg = BinaryPackage(version, intern(get_field('Section')), source, @@ -269,6 +275,7 @@ class DebMirrorLikeSuiteContentLoader(SuiteContentLoader): provides, ess, pkg_id, + builtusing, ) # if the source package is available in the distribution, then register this binary package diff --git a/britney2/utils.py b/britney2/utils.py index 6c34c59..6f7d26a 100644 --- a/britney2/utils.py +++ b/britney2/utils.py @@ -880,3 +880,26 @@ def compute_item_name(sources_t, sources_s, source_name, parch): if source_name in sources_t and sources_t[source_name].version == sources_s[source_name].version: return "%s/%s" % (source_name, parch) return source_name + + +def parse_builtusing(builtusing_raw, pkg_id=None, logger=None): + parts = apt_pkg.parse_depends(builtusing_raw, False) + nbu = [] + for or_clause in parts: + if len(or_clause) != 1: # pragma: no cover + if logger is not None: + msg = "Ignoring invalid builtusing in %s: Alternatives [%s]" + logger.warning(msg, str(pkg_id), str(or_clause)) + continue + for part in or_clause: + bu, bu_version, op = part + if op != '=': # pragma: no cover + if logger is not None: + msg = "Ignoring invalid builtusing in %s: %s (%s %s)" + logger.warning(msg, str(pkg_id), bu, op, bu_version) + continue + bu = sys.intern(bu) + bu_version = sys.intern(bu_version) + part = (bu, bu_version) + nbu.append(part) + return nbu diff --git a/tests/test_policy.py b/tests/test_policy.py index 60ee941..1e0408b 100644 --- a/tests/test_policy.py +++ b/tests/test_policy.py @@ -82,6 +82,7 @@ def create_bin_package(pkg_id, source_name=None, depends=None, conflicts=None): None, False, pkg_id, + [], )