]> git.decadent.org.uk Git - dak.git/commitdiff
Split out logic to parse Built-Using field.
authorAnsgar Burchardt <ansgar@debian.org>
Thu, 13 Aug 2015 11:30:09 +0000 (13:30 +0200)
committerAnsgar Burchardt <ansgar@debian.org>
Fri, 14 Aug 2015 11:04:21 +0000 (13:04 +0200)
daklib/archive.py
daklib/utils.py

index 99167af55ab744ff552679e07ebf766cacabe76c..9f38d4437ea9048a4e89f443ae6cdbdad6a0ebcb 100644 (file)
@@ -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
index efae7756527161b35cd377670fa6d4c3a4c8461f..401712381674a2fb83c9ec71e6b3a7e3336972fe 100644 (file)
@@ -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