]> git.decadent.org.uk Git - dak.git/blobdiff - dak/process_policy.py
dak/export_suite.py: take archive file for the archive we are exporting from
[dak.git] / dak / process_policy.py
index 30e10c4d06679f1b93c934cf003f07463ee6756a..db459607588971ae19c1b80b6dc04dd85b44560a 100755 (executable)
@@ -68,6 +68,10 @@ def do_comments(dir, srcqueue, opref, npref, line, fn, transaction):
         else:
             changes_prefix = changes_prefix + '.changes'
 
+        # We need to escape "_" as we use it with the LIKE operator (via the
+        # SQLA startwith) later.
+        changes_prefix = changes_prefix.replace("_", r"\_")
+
         uploads = session.query(PolicyQueueUpload).filter_by(policy_queue=srcqueue) \
             .join(PolicyQueueUpload.changes).filter(DBChange.changesname.startswith(changes_prefix)) \
             .order_by(PolicyQueueUpload.source_id)
@@ -138,6 +142,9 @@ def comment_accept(upload, srcqueue, comments, transaction):
         if upload.source is not None:
             transaction.copy_source(upload.source, suite, source_component_func(upload.source), allow_tainted=allow_tainted)
         for db_binary in upload.binaries:
+            # build queues may miss the source package if this is a binary-only upload
+            if suite != upload.target_suite:
+                transaction.copy_source(db_binary.source, suite, source_component_func(db_binary.source), allow_tainted=allow_tainted)
             transaction.copy_binary(db_binary, suite, binary_component_func(db_binary), allow_tainted=allow_tainted, extra_archives=[upload.target_suite.archive])
 
     # Copy .changes if needed
@@ -146,6 +153,26 @@ def comment_accept(upload, srcqueue, comments, transaction):
         dst = os.path.join(upload.target_suite.path, upload.changes.changesname)
         fs.copy(src, dst, mode=upload.target_suite.archive.mode)
 
+    # Copy upload to Process-Policy::CopyDir
+    # Used on security.d.o to sync accepted packages to ftp-master, but this
+    # should eventually be replaced by something else.
+    copydir = cnf.get('Process-Policy::CopyDir') or None
+    if copydir is not None:
+        mode = upload.target_suite.archive.mode
+        if upload.source is not None:
+            for f in [ df.poolfile for df in upload.source.srcfiles ]:
+                dst = os.path.join(copydir, f.basename)
+                fs.copy(f.fullpath, dst, mode=mode)
+
+        for db_binary in upload.binaries:
+            f = db_binary.poolfile
+            dst = os.path.join(copydir, f.basename)
+            fs.copy(f.fullpath, dst, mode=mode)
+
+        src = os.path.join(upload.policy_queue.path, upload.changes.changesname)
+        dst = os.path.join(copydir, upload.changes.changesname)
+        fs.copy(src, dst, mode=mode)
+
     if upload.source is not None and not Options['No-Action']:
         urgency = upload.changes.urgency
         if urgency not in cnf.value_list('Urgency::Valid'):
@@ -265,7 +292,7 @@ def get_processed_upload(upload):
     pu.changed_by = upload.changes.changedby
     pu.fingerprint = upload.changes.fingerprint
 
-    pu.suites = []
+    pu.suites = [ upload.target_suite ]
     pu.from_policy_suites = [ upload.target_suite ]
 
     changes_path = os.path.join(upload.policy_queue.path, upload.changes.changesname)