]> git.donarmstrong.com Git - dak.git/blobdiff - daklib/archive.py
daklib/archive.py, daklib/checks.py: implement transition blocks
[dak.git] / daklib / archive.py
index 914bc0f33c0c43851ad0d9734d10a492eec9342c..7f6895ad760aa7e69916a701efd56f32e1b6bcc1 100644 (file)
@@ -382,8 +382,14 @@ class ArchiveTransaction(object):
         if archive.tainted:
             allow_tainted = True
 
-        # make sure built-using packages are present in target archive
         filename = db_binary.poolfile.filename
+
+        # make sure source is present in target archive
+        db_source = db_binary.source
+        if session.query(ArchiveFile).filter_by(archive=archive, file=db_source.poolfile).first() is None:
+            raise ArchiveException('{0}: cannot copy to {1}: source is not present in target archive'.format(filename, suite.suite_name))
+
+        # make sure built-using packages are present in target archive
         for db_source in db_binary.extra_sources:
             self._ensure_extra_source_exists(filename, db_source, archive, extra_archives=extra_archives)
 
@@ -789,6 +795,8 @@ class ArchiveUpload(object):
             for chk in (
                     checks.SignatureCheck,
                     checks.ChangesCheck,
+                    checks.TransitionCheck,
+                    checks.UploadBlockCheck,
                     checks.HashesCheck,
                     checks.SourceCheck,
                     checks.BinaryCheck,
@@ -1025,6 +1033,11 @@ class ArchiveUpload(object):
             print >>debinfo, line
         debinfo.close()
 
+    def _policy_queue(self, suite):
+        if suite.policy_queue is not None:
+            return suite.policy_queue
+        return None
+
     def install(self):
         """install upload
 
@@ -1045,20 +1058,22 @@ class ArchiveUpload(object):
             if suite.overridesuite is not None:
                 overridesuite = self.session.query(Suite).filter_by(suite_name=suite.overridesuite).one()
 
+            policy_queue = self._policy_queue(suite)
+
             redirected_suite = suite
-            if suite.policy_queue is not None:
-                redirected_suite = suite.policy_queue.suite
+            if policy_queue is not None:
+                redirected_suite = policy_queue.suite
 
             source_component_func = lambda source: self._source_override(overridesuite, source).component
             binary_component_func = lambda binary: self._binary_component(overridesuite, binary)
 
             (db_source, db_binaries) = self._install_to_suite(redirected_suite, source_component_func, binary_component_func, extra_source_archives=[suite.archive])
 
-            if suite.policy_queue is not None:
-                self._install_policy(suite.policy_queue, suite, db_changes, db_source, db_binaries)
+            if policy_queue is not None:
+                self._install_policy(policy_queue, suite, db_changes, db_source, db_binaries)
 
             # copy to build queues
-            if suite.policy_queue is None or suite.policy_queue.send_to_build_queues:
+            if policy_queue is None or policy_queue.send_to_build_queues:
                 for build_queue in suite.copy_queues:
                     self._install_to_suite(build_queue.suite, source_component_func, binary_component_func, extra_source_archives=[suite.archive])
 
@@ -1101,7 +1116,8 @@ class ArchiveUpload(object):
             component = binary_component_func(binary)
             binary_component_names.add(component.component_name)
         source_component_name = None
-        for guess in ('main', 'contrib', 'non-free'):
+        for c in self.session.query(Component).order_by(Component.component_id):
+            guess = c.component_name
             if guess in binary_component_names:
                 source_component_name = guess
                 break