X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fprocess_upload.py;h=e48b54e26537c6c3b65ed5f59a5fa42834d04d8d;hb=6a04540642478715650bd496d522f42f9f6e7434;hp=cf1594a3098ba0d164e10b10b7cad49290fbeb23;hpb=945c33a367afa0e69f3aa8b4d087deb6356d8931;p=dak.git diff --git a/dak/process_upload.py b/dak/process_upload.py index cf1594a3..e48b54e2 100755 --- a/dak/process_upload.py +++ b/dak/process_upload.py @@ -125,21 +125,53 @@ Checks Debian packages from Incoming ## pu: create files for BTS ## pu: create entry in queue_build ## pu: check overrides -import errno + +# Integrity checks +## GPG +## Parsing changes (check for duplicates) +## Parse dsc +## file list checks + +# New check layout (TODO: Implement) +## Permission checks +### suite mappings +### ACLs +### version checks (suite) +### override checks + +## Source checks +### copy orig +### unpack +### BTS changelog +### src contents +### lintian +### urgency log + +## Binary checks +### timestamps +### control checks +### src relation check +### contents + +## Database insertion (? copy from stuff) +### BYHAND / NEW / Policy queues +### Pool + +## Queue builds + +from errno import EACCES, EAGAIN import fcntl import os import sys -#from datetime import datetime import traceback import apt_pkg +from sqlalchemy.orm.exc import NoResultFound from daklib import daklog from daklib.queue import * from daklib.queue_install import * from daklib import utils from daklib.dbconn import * -#from daklib.dak_exceptions import * -#from daklib.regexes import re_default_answer, re_issource, re_fdnic from daklib.urgencylog import UrgencyLog from daklib.summarystats import SummaryStats from daklib.holding import Holding @@ -164,13 +196,13 @@ def usage (exit_code=0): ############################################################################### -def action(u): +def action(u, session): cnf = Config() holding = Holding() # changes["distribution"] may not exist in corner cases # (e.g. unreadable changes files) - if not u.pkg.changes.has_key("distribution") or not isinstance(u.pkg.changes["distribution"], DictType): + if not u.pkg.changes.has_key("distribution") or not isinstance(u.pkg.changes["distribution"], dict): u.pkg.changes["distribution"] = {} (summary, short_summary) = u.build_summaries() @@ -183,6 +215,11 @@ def action(u): pi = u.package_info() + try: + chg = session.query(DBChange).filter_by(changesname=os.path.basename(u.pkg.changes_file)).one() + except NoResultFound, e: + chg = None + if len(u.rejects) > 0: if u.upload_too_new(): print "SKIP (too new)\n" + pi, @@ -193,6 +230,8 @@ def action(u): if Options["Automatic"]: answer = 'R' else: + # Are we headed for NEW / BYHAND / AUTOBYHAND? + # Note that policy queues are no longer handled here qu = determine_target(u) if qu: print "%s for %s\n%s%s" % ( qu.upper(), ", ".join(u.pkg.changes["distribution"].keys()), pi, summary) @@ -205,10 +244,32 @@ def action(u): if Options["Automatic"]: answer = queuekey else: - print "ACCEPT\n" + pi + summary, - prompt = "[A]ccept, Skip, Quit ?" - if Options["Automatic"]: - answer = 'A' + # Does suite have a policy_queue configured + divert = False + for s in u.pkg.changes["distribution"].keys(): + suite = get_suite(s, session) + if suite.policy_queue: + if not chg or chg.approved_for_id != su.policy_queue.policy_queue_id: + # This routine will check whether the upload is a binary + # upload when the source is already in the target suite. If + # so, we skip the policy queue, otherwise we go there. + divert = package_to_suite(u, suite.suite_name, session=session) + if divert: + print "%s for %s\n%s%s" % ( suite.policy_queue.queue_name.upper(), + ", ".join(u.pkg.changes["distribution"].keys()), + pi, summary) + queuekey = "P" + prompt = "[P]olicy, Skip, Quit ?" + policyqueue = suite.policy_queue + if Options["Automatic"]: + answer = 'P' + break + + if not divert: + print "ACCEPT\n" + pi + summary, + prompt = "[A]ccept, Skip, Quit ?" + if Options["Automatic"]: + answer = 'A' while prompt.find(answer) == -1: answer = utils.our_raw_input(prompt) @@ -217,19 +278,29 @@ def action(u): answer = m.group(1) answer = answer[:1].upper() - session = DBConn().session() - if answer == 'R': os.chdir(u.pkg.directory) u.do_reject(0, pi) elif answer == 'A': - u.pkg.add_known_changes(holding.holding_dir, session) + if not chg: + chg = u.pkg.add_known_changes(holding.holding_dir, session) u.accept(summary, short_summary, session) u.check_override() + session.commit() + u.remove() + elif answer == 'P': + if not chg: + chg = u.pkg.add_known_changes(holding.holding_dir, session) + u.move_to_queue(policyqueue) + chg.in_queue = policyqueue.policy_queue_id + session.add(chg) + session.commit() u.remove() elif answer == queuekey: - u.pkg.add_known_changes(holding.holding_dir, session) - QueueInfo[qu]["process"](u, summary, short_summary, session) + if not chg: + chg = u.pkg.add_known_changes(holding.holding_dir, session) + QueueInfo[qu]["process"](u, summary, short_summary, chg, session) + session.commit() u.remove() elif answer == 'Q': sys.exit(0) @@ -243,7 +314,7 @@ def cleanup(): if not Options["No-Action"]: h.clean() -def process_it(changes_file): +def process_it(changes_file, session): global Logger Logger.log(["Processing changes file", changes_file]) @@ -252,6 +323,9 @@ def process_it(changes_file): holding = Holding() + # TODO: Actually implement using pending* tables so that we don't lose track + # of what is where + u = Upload() u.pkg.changes_file = changes_file u.pkg.directory = os.getcwd() @@ -309,7 +383,7 @@ def process_it(changes_file): u.check_timestamps() u.check_signed_by_key() - action(u) + action(u, session) except (SystemExit, KeyboardInterrupt): cleanup() @@ -398,7 +472,7 @@ def main(): for changes_file in changes_files: print "\n" + changes_file session = DBConn().session() - process_it(changes_file) + process_it(changes_file, session) session.close() if summarystats.accept_count: