def process_it(changes_file, session): global Logger Logger.log(["Processing changes file", changes_file]) cnf = Config() 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() u.logger = Logger origchanges = os.path.abspath(u.pkg.changes_file) # Some defaults in case we can't fully process the .changes file u.pkg.changes["maintainer2047"] = cnf["Dinstall::MyEmailAddress"] u.pkg.changes["changedby2047"] = cnf["Dinstall::MyEmailAddress"] # debian-{devel-,}[email protected] toggles writes access based on this header bcc = "X-DAK: dak process-upload" if cnf.has_key("Dinstall::Bcc"): u.Subst["__BCC__"] = bcc + "\nBcc: %s" % (cnf["Dinstall::Bcc"]) else: u.Subst["__BCC__"] = bcc # Remember where we are so we can come back after cd-ing into the # holding directory. TODO: Fix this stupid hack u.prevdir = os.getcwd() try: # 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"]: holding.chdir_to_holding() # Absolutize the filename to avoid the requirement of being in the # same directory as the .changes file. holding.copy_to_holding(origchanges) # Relativize the filename so we use the copy in holding # rather than the original... changespath = os.path.basename(u.pkg.changes_file) else: changespath = origchanges (u.pkg.changes["fingerprint"], rejects) = utils.check_signature(changespath) 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) if valid_changes_p: u.check_distributions() u.check_files(not Options["No-Action"]) valid_dsc_p = u.check_dsc(not Options["No-Action"]) if valid_dsc_p and not Options["No-Action"]: u.check_source() 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() action(u, session) except (SystemExit, KeyboardInterrupt): cleanup() raise except: print "ERROR" traceback.print_exc(file=sys.stderr) cleanup() # Restore previous WD os.chdir(u.prevdir)
def cleanup(): h = Holding() if not Options["No-Action"]: h.clean()