X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fprocess_upload.py;h=bf74baa65be064e356abaa8459b39a6688c85ad9;hb=db2d829cce8f0dd8aadb6af5e6258ab4fced871d;hp=4d1cbc2f6677da8d5ae58fe4c05ea2beef6b97f6;hpb=4c7eee9642e82b6286f807ad92a93e7ef30288e6;p=dak.git diff --git a/dak/process_upload.py b/dak/process_upload.py index 4d1cbc2f..bf74baa6 100755 --- a/dak/process_upload.py +++ b/dak/process_upload.py @@ -176,6 +176,7 @@ from daklib.urgencylog import UrgencyLog from daklib.summarystats import SummaryStats from daklib.holding import Holding from daklib.config import Config +from daklib.regexes import re_match_expired ############################################################################### @@ -206,6 +207,8 @@ def byebye(): def action(u, session): + global Logger + cnf = Config() holding = Holding() @@ -292,7 +295,7 @@ def action(u, session): u.do_reject(0, pi) elif answer == 'A': if not chg: - chg = u.pkg.add_known_changes(holding.holding_dir, session=session) + chg = u.pkg.add_known_changes(holding.holding_dir, session=session, logger=Logger) session.commit() u.accept(summary, short_summary, session) u.check_override() @@ -301,13 +304,13 @@ def action(u, session): u.remove() elif answer == 'P': if not chg: - chg = u.pkg.add_known_changes(holding.holding_dir, session=session) + chg = u.pkg.add_known_changes(holding.holding_dir, session=session, logger=Logger) package_to_queue(u, summary, short_summary, policyqueue, chg, session) session.commit() u.remove() elif answer == queuekey: if not chg: - chg = u.pkg.add_known_changes(holding.holding_dir, session=session) + chg = u.pkg.add_known_changes(holding.holding_dir, session=session, logger=Logger) QueueInfo[qu]["process"](u, summary, short_summary, chg, session) session.commit() u.remove() @@ -361,7 +364,7 @@ def process_it(changes_file, session): # If this is the Real Thing(tm), copy things into a private # holding directory first to avoid replacable file races. if not Options["No-Action"]: - os.chdir(cnf["Dir::Queue::Holding"]) + holding.chdir_to_holding() # Absolutize the filename to avoid the requirement of being in the # same directory as the .changes file. @@ -378,6 +381,12 @@ def process_it(changes_file, session): if u.pkg.changes["fingerprint"]: valid_changes_p = u.load_changes(changespath) else: + for reason in rejects: + if re_match_expired.match(reason): + # Hrm, key expired. Lets see if we can still parse the .changes before + # we reject. Then we would be able to mail the maintainer, instead of + # just silently dropping the upload. + u.load_changes(changespath) valid_changes_p = False u.rejects.extend(rejects) @@ -387,8 +396,9 @@ def process_it(changes_file, session): valid_dsc_p = u.check_dsc(not Options["No-Action"]) if valid_dsc_p and not Options["No-Action"]: u.check_source() - u.check_lintian() u.check_hashes() + if valid_dsc_p and not Options["No-Action"] and not len(u.rejects): + u.check_lintian() u.check_urgency() u.check_timestamps() u.check_signed_by_key() @@ -414,7 +424,6 @@ def main(): cnf = Config() summarystats = SummaryStats() - log_urgency = False DBConn() @@ -446,7 +455,7 @@ def main(): # Obtain lock if not in no-action mode and initialize the log if not Options["No-Action"]: - lock_fd = os.open(cnf["Dinstall::LockFile"], os.O_RDWR | os.O_CREAT) + lock_fd = os.open(os.path.join(cnf["Dir::Lock"], 'dinstall.lock'), os.O_RDWR | os.O_CREAT) try: fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError, e: @@ -454,12 +463,12 @@ def main(): utils.fubar("Couldn't obtain lock; assuming another 'dak process-upload' is already running.") else: raise - if cnf.get("Dir::UrgencyLog"): - # Initialise UrgencyLog() - log_urgency = True - UrgencyLog() - Logger = daklog.Logger(cnf, "process-upload", Options["No-Action"]) + # Initialise UrgencyLog() - it will deal with the case where we don't + # want to log urgencies + urgencylog = UrgencyLog() + + Logger = daklog.Logger("process-upload", Options["No-Action"]) # If we have a directory flag, use it to find our files if cnf["Dinstall::Options::Directory"] != "": @@ -493,11 +502,17 @@ def main(): utils.size_type(int(summarystats.accept_bytes))) Logger.log(["total", summarystats.accept_count, summarystats.accept_bytes]) + if summarystats.reject_count: + sets = "set" + if summarystats.reject_count > 1: + sets = "sets" + print "Rejected %d package %s." % (summarystats.reject_count, sets) + Logger.log(["rejected", summarystats.reject_count]) + byebye() if not Options["No-Action"]: - if log_urgency: - UrgencyLog().close() + urgencylog.close() Logger.close()