X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fprocess_policy.py;h=ddd05b7c65166f18b4011dafe47a5f82053ec7ac;hb=f601bd71e61c6c265b5fa1f296a5258385e6f154;hp=61c4ef395702112020d1b67f6f1520ce10954ca4;hpb=1e945c24f59d3e92ef18f456b60aa10210a3113c;p=dak.git diff --git a/dak/process_policy.py b/dak/process_policy.py index 61c4ef39..ddd05b7c 100755 --- a/dak/process_policy.py +++ b/dak/process_policy.py @@ -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) @@ -77,7 +81,8 @@ def do_comments(dir, srcqueue, opref, npref, line, fn, transaction): if opref != npref: newcomm = npref + comm[len(opref):] - transaction.fs.move(os.path.join(dir, comm), os.path.join(dir, newcomm)) + newcomm = utils.find_next_free(os.path.join(dir, newcomm)) + transaction.fs.move(os.path.join(dir, comm), newcomm) ################################################################################ @@ -138,6 +143,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 +154,29 @@ 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) + if not os.path.exists(dst): + fs.copy(f.fullpath, dst, mode=mode) + + for db_binary in upload.binaries: + f = db_binary.poolfile + dst = os.path.join(copydir, f.basename) + if not os.path.exists(dst): + 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) + if not os.path.exists(dst): + 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'): @@ -157,7 +188,7 @@ def comment_accept(upload, srcqueue, comments, transaction): Logger.log(["Policy Queue ACCEPT", srcqueue.queue_name, changesname]) pu = get_processed_upload(upload) - daklib.announce.announce_accept(upload) + daklib.announce.announce_accept(pu) # TODO: code duplication. Similar code is in process-upload. # Move .changes to done @@ -232,7 +263,9 @@ def real_comment_reject(upload, srcqueue, comments, transaction, notify=True, ma if not Options["No-Action"]: Logger.log(["Policy Queue REJECT", srcqueue.queue_name, upload.changes.changesname]) + changes = upload.changes remove_upload(upload, transaction) + session.delete(changes) ################################################################################ @@ -252,7 +285,6 @@ def remove_upload(upload, transaction): fs.unlink(os.path.join(queuedir, upload.changes.changesname)) session.delete(upload) - session.delete(changes) session.flush() ################################################################################ @@ -264,7 +296,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)