From: Ansgar Burchardt Date: Thu, 13 Aug 2015 11:30:09 +0000 (+0200) Subject: Split out logic to parse Built-Using field. X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=2919be54694c13575d1ba9b6dc3d1c1ffc50aae7;p=dak.git Split out logic to parse Built-Using field. --- diff --git a/daklib/archive.py b/daklib/archive.py index 99167af5..9f38d443 100644 --- a/daklib/archive.py +++ b/daklib/archive.py @@ -247,21 +247,15 @@ class ArchiveTransaction(object): """Add Built-Using sources to C{db_binary.extra_sources} """ session = self.session - built_using = control.get('Built-Using', None) - if built_using is not None: - for dep in apt_pkg.parse_depends(built_using): - assert len(dep) == 1, 'Alternatives are not allowed in Built-Using field' - bu_source_name, bu_source_version, comp = dep[0] - assert comp == '=', 'Built-Using must contain strict dependencies' + for bu_source_name, bu_source_version in daklib.utils.parse_built_using(control): + bu_source = session.query(DBSource).filter_by(source=bu_source_name, version=bu_source_version).first() + if bu_source is None: + raise ArchiveException('{0}: Built-Using refers to non-existing source package {1} (= {2})'.format(filename, bu_source_name, bu_source_version)) - bu_source = session.query(DBSource).filter_by(source=bu_source_name, version=bu_source_version).first() - if bu_source is None: - raise ArchiveException('{0}: Built-Using refers to non-existing source package {1} (= {2})'.format(filename, bu_source_name, bu_source_version)) + self._ensure_extra_source_exists(filename, bu_source, suite.archive, extra_archives=extra_archives) - self._ensure_extra_source_exists(filename, bu_source, suite.archive, extra_archives=extra_archives) - - db_binary.extra_sources.append(bu_source) + db_binary.extra_sources.append(bu_source) def install_source_to_archive(self, directory, source, archive, component, changed_by, allow_tainted=False, fingerprint=None): session = self.session diff --git a/daklib/utils.py b/daklib/utils.py index efae7756..40171238 100644 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -1301,3 +1301,27 @@ def check_reverse_depends(removals, suite, arches=None, session=None, cruft=Fals print return dep_problem + +################################################################################ + +def parse_built_using(control): + """source packages referenced via Built-Using + + @type control: dict-like + @param control: control file to take Built-Using field from + + @rtype: list of (str, str) + @return: list of (source_name, source_version) pairs + """ + built_using = control.get('Built-Using', None) + if built_using is None: + return [] + + bu = [] + for dep in apt_pkg.parse_depends(built_using): + assert len(dep) == 1, 'Alternatives are not allowed in Built-Using field' + source_name, source_version, comp = dep[0] + assert comp == '=', 'Built-Using must contain strict dependencies' + bu.append((source_name, source_version)) + + return bu