X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lisa;h=d961ede0e8edbdb4224f9f2efb056f658a0fd755;hb=cabe09b4d162c7f680b07863cc043359545dabdd;hp=45c500f677296c2880c71ae10d3d1906664c1088;hpb=57663cee3f2c0e03c6215b8b27a3d4d613128f6a;p=dak.git diff --git a/lisa b/lisa index 45c500f6..d961ede0 100755 --- a/lisa +++ b/lisa @@ -2,7 +2,7 @@ # Handles NEW and BYHAND packages # Copyright (C) 2001, 2002 James Troup -# $Id: lisa,v 1.12 2002-05-19 02:00:48 troup Exp $ +# $Id: lisa,v 1.17 2002-05-23 12:19:05 troup 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,28 +37,12 @@ ################################################################################ -# TODO -# ---- - -# We don't check error codes very thoroughly; the old 'trust jennifer' -# chess nut... db_access calls in particular - -# Possible TODO -# ------------- - -# Handle multiple different section/priorities (?) -# hardcoded debianness (debian-installer, source priority etc.) (?) -# Slang/ncurses interface (?) -# write changed sections/priority back to katie for later processing (?) - -################################################################################ - import copy, errno, os, readline, string, stat, sys, tempfile; import apt_pkg, apt_inst; import db_access, fernanda, katie, logging, utils; # Globals -lisa_version = "$Revision: 1.12 $"; +lisa_version = "$Revision: 1.17 $"; Cnf = None; Options = None; @@ -69,8 +53,68 @@ Logger = None; Priorities = None; Sections = None; +reject_message = ""; + +################################################################################ ################################################################################ ################################################################################ + +def reject (str, prefix="Rejected: "): + global reject_message; + if str: + reject_message = reject_message + prefix + str + "\n"; + +def recheck(): + global reject_message; + files = Katie.pkg.files; + reject_message = ""; + + for file in files.keys(): + # 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): + 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): + reject("no source found for %s %s (%s)." % (source_package, source_version, file)); + + # Version and file overwrite checks + if files[file]["type"] == "deb": + reject(Katie.check_binary_against_db(file)); + elif files[file]["type"] == "dsc": + reject(Katie.check_source_against_db(file)); + (reject_msg, is_in_incoming) = Katie.check_dsc_against_db(file); + reject(reject_msg); + + if reject_message: + answer = "XXX"; + if Options["No-Action"] or Options["Automatic"]: + answer = 'S' + + print "REJECT\n" + reject_message,; + prompt = "[R]eject, Skip, Quit ?"; + + while string.find(prompt, answer) == -1: + answer = utils.our_raw_input(prompt); + m = katie.re_default_answer.match(prompt); + if answer == "": + answer = m.group(1); + answer = string.upper(answer[:1]); + + if answer == 'R': + Katie.do_reject(0, reject_message); + os.unlink(Katie.pkg.changes_file[:-8]+".katie"); + return 0; + elif answer == 'S': + return 0; + elif answer == 'Q': + sys.exit(0); + + return 1; + ################################################################################ def determine_new (changes, files): @@ -136,63 +180,94 @@ def determine_new (changes, files): ################################################################################ -# Sort by 'have note', 'have source', by ctime, by source name, by -# source version number, and finally by filename - -def changes_compare (a, b): - try: - a_changes = utils.parse_changes(a); - except: - return 1; +def indiv_sg_compare (a, b): + """Sort by source name, source, version, 'have source', and + finally by filename.""" + # Sort by source version + q = apt_pkg.VersionCompare(a["version"], b["version"]); + if q: + return -q; - try: - b_changes = utils.parse_changes(b); - except: + # Sort by 'have source' + a_has_source = a["architecture"].get("source"); + b_has_source = b["architecture"].get("source"); + if a_has_source and not b_has_source: return -1; + elif b_has_source and not a_has_source: + return 1; - utils.cc_fix_changes (a_changes); - utils.cc_fix_changes (b_changes); + return cmp(a["filename"], b["filename"]); - # Sort by 'have note'; - a_has_note = a_changes.get("lisa note"); - b_has_note = b_changes.get("lisa note"); - if a_has_note and not b_has_note: - return -1; - elif b_has_note and not a_has_note: - return 1; +############################################################ - # Sort by 'have source' - a_has_source = a_changes["architecture"].get("source"); - b_has_source = b_changes["architecture"].get("source"); - if a_has_source and not b_has_source: +def sg_compare (a, b): + a = a[1]; + b = b[1]; + """Sort by have note, time of oldest upload.""" + # Sort by have note + a_note_state = a["note_state"]; + b_note_state = b["note_state"]; + if a_note_state < b_note_state: return -1; - elif b_has_source and not a_has_source: + elif a_note_state > b_note_state: return 1; - # Sort by ctime-per-source - a_source = a_changes.get("source"); - b_source = b_changes.get("source"); - if a_source != b_source: - a_ctime = os.stat(a)[stat.ST_CTIME]; - b_ctime = os.stat(b)[stat.ST_CTIME]; - q = cmp (a_ctime, b_ctime); - if q: - return q; - - # Sort by source name - q = cmp (a_source, b_source); - if q: - return q; + # Sort by time of oldest upload + return cmp(a["oldest"], b["oldest"]); - # Sort by source version - a_version = a_changes.get("version"); - b_version = b_changes.get("version"); - q = apt_pkg.VersionCompare(a_version, b_version); - if q: - return -q; +def sort_changes(changes_files): + """Sort into source groups, then sort each source group by version, + have source, filename. Finally, sort the source groups by have + note, time of oldest upload of each source upload.""" + if len(changes_files) == 1: + return changes_files; - # Fall back to sort by filename - return cmp(a, b); + sorted_list = []; + cache = {}; + # Read in all the .changes files + for filename in changes_files: + try: + Katie.pkg.changes_file = filename; + Katie.init_vars(); + Katie.update_vars(); + cache[filename] = copy.copy(Katie.pkg.changes); + cache[filename]["filename"] = filename; + except: + sorted_list.append(filename); + break; + # Divide the .changes into per-source groups + per_source = {}; + for filename in cache.keys(): + source = cache[filename]["source"]; + if not per_source.has_key(source): + per_source[source] = {}; + per_source[source]["list"] = []; + per_source[source]["list"].append(cache[filename]); + # Determine oldest time and have note status for each source group + for source in per_source.keys(): + source_list = per_source[source]["list"]; + first = source_list[0]; + oldest = os.stat(first["filename"])[stat.ST_CTIME]; + have_note = 0; + for d in per_source[source]["list"]: + ctime = os.stat(d["filename"])[stat.ST_CTIME]; + if ctime < oldest: + oldest = ctime; + have_note = have_note + (d.has_key("lisa note")); + per_source[source]["oldest"] = oldest; + if not have_note: + per_source[source]["note_state"] = 0; # none + elif have_note < len(source_list): + per_source[source]["note_state"] = 1; # some + else: + per_source[source]["note_state"] = 2; # all + per_source[source]["list"].sort(indiv_sg_compare); + per_source_items = per_source.items(); + per_source_items.sort(sg_compare); + for i in per_source_items: + for j in i[1]["list"]: + sorted_list.append(j["filename"]); + return sorted_list; ################################################################################ @@ -764,6 +839,9 @@ def do_pkg(changes_file): Katie.update_subst(); files = Katie.pkg.files; + if not recheck(): + return; + (new, byhand) = check_status(files); if new or byhand: if new: @@ -795,7 +873,9 @@ def end(): def main(): changes_files = init(); - changes_files.sort(changes_compare); + if len(changes_files) > 50: + sys.stderr.write("Sorting changes...\n"); + changes_files = sort_changes(changes_files); # Kill me now? **FIXME** Cnf["Dinstall::Options::No-Mail"] = "";