X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lisa;h=d98c0df683c77735d3fe47c512c5209abfb52f2e;hb=9540d873fa78598454af57f5f8a4875969ed0439;hp=b065e6821154ff96b9d663aa552136ba6d24afb9;hpb=d1429a5ed3d1914ccc502ae146b32445967e9ba8;p=dak.git diff --git a/lisa b/lisa index b065e682..d98c0df6 100755 --- a/lisa +++ b/lisa @@ -1,8 +1,8 @@ #!/usr/bin/env python # Handles NEW and BYHAND packages -# Copyright (C) 2001, 2002, 2003 James Troup -# $Id: lisa,v 1.23 2003-03-14 19:06:02 troup Exp $ +# Copyright (C) 2001, 2002, 2003, 2004, 2005 James Troup +# $Id: lisa,v 1.31 2005-11-15 09:50:32 ajt Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -37,12 +37,12 @@ ################################################################################ -import copy, errno, os, readline, stat, sys, tempfile; +import copy, errno, os, readline, stat, sys, time; import apt_pkg, apt_inst; import db_access, fernanda, katie, logging, utils; # Globals -lisa_version = "$Revision: 1.23 $"; +lisa_version = "$Revision: 1.31 $"; Cnf = None; Options = None; @@ -70,12 +70,16 @@ def recheck(): reject_message = ""; for file in files.keys(): + # The .orig.tar.gz can disappear out from under us is it's a + # duplicate of one in the archive. + if not files.has_key(file): + continue; # Check that the source still exists if files[file]["type"] == "deb": source_version = files[file]["source version"]; source_package = files[file]["source package"]; if not Katie.pkg.changes["architecture"].has_key("source") \ - and not Katie.source_exists(source_package, source_version): + and not Katie.source_exists(source_package, source_version, Katie.pkg.changes["distribution"].keys()): source_epochless_version = utils.re_no_epoch.sub('', source_version); dsc_filename = "%s_%s.dsc" % (source_package, source_epochless_version); if not os.path.exists(Cnf["Dir::Queue::Accepted"] + '/' + dsc_filename): @@ -249,12 +253,12 @@ def sort_changes(changes_files): for source in per_source.keys(): source_list = per_source[source]["list"]; first = source_list[0]; - oldest = os.stat(first["filename"])[stat.ST_CTIME]; + oldest = os.stat(first["filename"])[stat.ST_MTIME]; have_note = 0; for d in per_source[source]["list"]: - ctime = os.stat(d["filename"])[stat.ST_CTIME]; - if ctime < oldest: - oldest = ctime; + mtime = os.stat(d["filename"])[stat.ST_MTIME]; + if mtime < oldest: + oldest = mtime; have_note += (d.has_key("lisa note")); per_source[source]["oldest"] = oldest; if not have_note: @@ -390,9 +394,7 @@ def index_range (index): def edit_new (new): # Write the current data to a temporary file - temp_filename = tempfile.mktemp(); - fd = os.open(temp_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700); - os.close(fd); + temp_filename = utils.temp_filename(); temp_file = utils.open_file(temp_filename, 'w'); print_new (new, 0, temp_file); temp_file.close(); @@ -468,7 +470,7 @@ def edit_index (new, index): got_priority = 0; while not got_priority: new_priority = utils.our_raw_input("New priority: ").strip(); - if Priorities.priorities.count(new_priority) == 0: + if new_priority not in Priorities.priorities: print "E: '%s' is not a valid priority, try again." % (new_priority); else: got_priority = 1; @@ -480,7 +482,7 @@ def edit_index (new, index): got_section = 0; while not got_section: new_section = utils.our_raw_input("New section: ").strip(); - if Sections.sections.count(new_section) == 0: + if new_section not in Sections.sections: print "E: '%s' is not a valid section, try again." % (new_section); else: got_section = 1; @@ -538,9 +540,7 @@ def edit_overrides (new): def edit_note(note): # Write the current data to a temporary file - temp_filename = tempfile.mktemp(); - fd = os.open(temp_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700); - os.close(fd); + temp_filename = utils.temp_filename(); temp_file = utils.open_file(temp_filename, 'w'); temp_file.write(note); temp_file.close(); @@ -629,7 +629,7 @@ def add_overrides (new): type_id = db_access.get_override_type_id(new[pkg]["type"]); priority_id = new[pkg]["priority id"]; section_id = new[pkg]["section id"]; - projectB.query("INSERT INTO override (suite, component, type, package, priority, section) VALUES (%s, %s, %s, '%s', %s, %s)" % (suite_id, component_id, type_id, pkg, priority_id, section_id)); + projectB.query("INSERT INTO override (suite, component, type, package, priority, section, maintainer) VALUES (%s, %s, %s, '%s', %s, %s, '')" % (suite_id, component_id, type_id, pkg, priority_id, section_id)); for file in new[pkg]["files"]: if files[file].has_key("new"): del files[file]["new"]; @@ -642,6 +642,52 @@ def add_overrides (new): ################################################################################ +def prod_maintainer (): + # Here we prepare an editor and get them ready to prod... + temp_filename = utils.temp_filename(); + editor = os.environ.get("EDITOR","vi") + answer = 'E'; + while answer == 'E': + os.system("%s %s" % (editor, temp_filename)) + file = utils.open_file(temp_filename); + prod_message = "".join(file.readlines()); + file.close(); + print "Prod message:"; + print utils.prefix_multi_line_string(prod_message," ",include_blank_lines=1); + prompt = "[P]rod, Edit, Abandon, Quit ?" + answer = "XXX"; + while prompt.find(answer) == -1: + answer = utils.our_raw_input(prompt); + m = katie.re_default_answer.search(prompt); + if answer == "": + answer = m.group(1); + answer = answer[:1].upper(); + os.unlink(temp_filename); + if answer == 'A': + return; + elif answer == 'Q': + sys.exit(0); + # Otherwise, do the proding... + user_email_address = utils.whoami() + " <%s>" % ( + Cnf["Dinstall::MyAdminAddress"]); + + Subst = Katie.Subst; + + Subst["__FROM_ADDRESS__"] = user_email_address; + Subst["__PROD_MESSAGE__"] = prod_message; + Subst["__CC__"] = "Cc: " + Cnf["Dinstall::MyEmailAddress"]; + + prod_mail_message = utils.TemplateSubst( + Subst,Cnf["Dir::Templates"]+"/lisa.prod"); + + # Send the prod mail if appropriate + if not Cnf["Dinstall::Options::No-Mail"]: + utils.send_mail(prod_mail_message); + + print "Sent proding message"; + +################################################################################ + def do_new(): print "NEW\n"; files = Katie.pkg.files; @@ -686,7 +732,7 @@ def do_new(): print "W: note must be removed before package can be processed."; prompt += "Remove note, "; - prompt += "Edit overrides, Check, Manual reject, Note edit, [S]kip, Quit ?"; + prompt += "Edit overrides, Check, Manual reject, Note edit, Prod, [S]kip, Quit ?"; while prompt.find(answer) == -1: answer = utils.our_raw_input(prompt); @@ -708,6 +754,8 @@ def do_new(): done = 1; elif answer == 'N': edit_note(changes.get("lisa note", "")); + elif answer == 'P': + prod_maintainer(); elif answer == 'R': confirm = utils.our_raw_input("Really clear note (y/N)? ").lower(); if confirm == "y": @@ -822,9 +870,25 @@ def do_byhand(): def do_accept(): print "ACCEPT"; if not Options["No-Action"]: + retry = 0; + while retry < 10: + try: + lock_fd = os.open(Cnf["Lisa::AcceptedLockFile"], os.O_RDONLY | os.O_CREAT | os.O_EXCL); + retry = 10; + except OSError, e: + if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EEXIST': + retry += 1; + if (retry >= 10): + utils.fubar("Couldn't obtain lock; assuming jennifer is already running."); + else: + print("Unable to get accepted lock (try %d of 10)" % retry); + time.sleep(60); + else: + raise; (summary, short_summary) = Katie.build_summaries(); Katie.accept(summary, short_summary); os.unlink(Katie.pkg.changes_file[:-8]+".katie"); + os.unlink(Cnf["Lisa::AcceptedLockFile"]); def check_status(files): new = byhand = 0;