]> git.decadent.org.uk Git - dak.git/blobdiff - lisa
sync
[dak.git] / lisa
diff --git a/lisa b/lisa
index 68d40f36edb6e5d08ffc8580a486a1ba0e84a1f8..724360a8aeeaa6c4f49852de01f7780a5d1d4377 100755 (executable)
--- a/lisa
+++ b/lisa
@@ -1,8 +1,8 @@
 #!/usr/bin/env python
 
 # Handles NEW and BYHAND packages
-# Copyright (C) 2001  James Troup <james@nocrew.org>
-# $Id: lisa,v 1.2 2002-02-15 04:01:07 troup Exp $
+# Copyright (C) 2001, 2002  James Troup <james@nocrew.org>
+# $Id: lisa,v 1.10 2002-05-10 00:24:23 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
 
 ################################################################################
 
-import errno, os, readline, string, stat, sys, tempfile;
+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.2 $";
+lisa_version = "$Revision: 1.10 $";
 
 Cnf = None;
 Options = None;
@@ -85,6 +85,9 @@ def determine_new (changes, files):
         pkg = f["package"];
         priority = f["priority"];
         section = f["section"];
+        # FIXME: unhardcode
+        if section == "non-US/main":
+            section = "non-US";
         type = get_type(f);
         component = f["component"];
 
@@ -107,8 +110,10 @@ def determine_new (changes, files):
                     new[pkg]["type"] = type;
                     new[pkg]["component"] = component;
         new[pkg]["files"].append(file);
+        if f.has_key("othercomponents"):
+            new[pkg]["othercomponents"] = f["othercomponents"];
 
-    for suite in changes["distribution"].keys():
+    for suite in changes["suite"].keys():
         suite_id = db_access.get_suite_id(suite);
         for pkg in new.keys():
             component_id = db_access.get_component_id(new[pkg]["component"]);
@@ -121,6 +126,12 @@ def determine_new (changes, files):
                         del files[file]["new"];
                 del new[pkg];
 
+    if changes["suite"].has_key("stable"):
+        print "WARNING: overrides will be added for stable!";
+    for pkg in new.keys():
+        if new[pkg].has_key("othercomponents"):
+            print "WARNING: %s already present in %s distribution." % (pkg, new[pkg]["othercomponents"]);
+
     return new;
 
 ################################################################################
@@ -345,7 +356,7 @@ def edit_index (new, index):
         edit_priority = edit_section = 0;
 
         while string.find(prompt, answer) == -1:
-            answer = raw_input(prompt);
+            answer = utils.our_raw_input(prompt);
             m = katie.re_default_answer.match(prompt)
             if answer == "":
                 answer = m.group(1)
@@ -365,7 +376,7 @@ def edit_index (new, index):
             readline.set_completer(Priorities.complete);
             got_priority = 0;
             while not got_priority:
-                new_priority = string.strip(raw_input("New priority: "));
+                new_priority = string.strip(utils.our_raw_input("New priority: "));
                 if Priorities.priorities.count(new_priority) == 0:
                     print "E: '%s' is not a valid priority, try again." % (new_priority);
                 else:
@@ -377,7 +388,7 @@ def edit_index (new, index):
             readline.set_completer(Sections.complete);
             got_section = 0;
             while not got_section:
-                new_section = string.strip(raw_input("New section: "));
+                new_section = string.strip(utils.our_raw_input("New section: "));
                 if Sections.sections.count(new_section) == 0:
                     print "E: '%s' is not a valid section, try again." % (new_section);
                 else:
@@ -411,8 +422,8 @@ def edit_overrides (new):
 
         got_answer = 0
         while not got_answer:
-            answer = raw_input(prompt)
-            answer = string.upper(answer[:1])
+            answer = utils.our_raw_input(prompt);
+            answer = string.upper(answer[:1]);
             if answer == "E" or answer == "D":
                 got_answer = 1;
             elif katie.re_isanum.match (answer):
@@ -474,7 +485,7 @@ def do_bxa_notification():
             summary = summary + "Package: %s\n" % (control.Find("Package"));
             summary = summary + "Description: %s\n" % (control.Find("Description"));
     Katie.Subst["__BINARY_DESCRIPTIONS__"] = summary;
-    bxa_mail = utils.TemplateSubst(Katie.Subst,open(Cnf["Dir::TemplatesDir"]+"/lisa.bxa_notification","r").read());
+    bxa_mail = utils.TemplateSubst(Katie.Subst,Cnf["Dir::Templates"]+"/lisa.bxa_notification");
     utils.send_mail(bxa_mail,"");
 
 ################################################################################
@@ -484,7 +495,7 @@ def add_overrides (new):
     files = Katie.pkg.files;
 
     projectB.query("BEGIN WORK");
-    for suite in changes["distribution"].keys():
+    for suite in changes["suite"].keys():
         suite_id = db_access.get_suite_id(suite);
         for pkg in new.keys():
             component_id = db_access.get_component_id(new[pkg]["component"]);
@@ -499,7 +510,7 @@ def add_overrides (new):
 
     projectB.query("COMMIT WORK");
 
-    if Cnf.FindI("Dinstall::BXANotify"):
+    if Cnf.FindB("Dinstall::BXANotify"):
         do_bxa_notification();
 
 ################################################################################
@@ -509,14 +520,17 @@ def do_new():
     files = Katie.pkg.files;
     changes = Katie.pkg.changes;
 
+    # Make a copy of distribution we can happily trample on
+    changes["suite"] = copy.copy(changes["distribution"]);
+
     # Fix up the list of target suites
-    for suite in changes["distribution"].keys():
+    for suite in changes["suite"].keys():
         override = Cnf.Find("Suite::%s::OverrideSuite" % (suite));
         if override:
-            del changes["distribution"][suite];
-            changes["distribution"][override] = 1;
+            del changes["suite"][suite];
+            changes["suite"][override] = 1;
     # Validate suites
-    for suite in changes["distribution"].keys():
+    for suite in changes["suite"].keys():
         suite_id = db_access.get_suite_id(suite);
         if suite_id == -1:
             utils.fubar("%s has invalid suite '%s' (possibly overriden).  say wha?" % (changes, suite));
@@ -532,23 +546,21 @@ def do_new():
 
         answer = "XXX";
         if Options["No-Action"] or Options["Automatic"]:
-            answer = 'S'
-        if Options["Automatic"]:
-            answer = 'A';
+            answer = 'S';
 
         broken = print_new(new, 0);
         prompt = "";
         if not broken:
-            prompt = "[A]dd overrides, ";
+            prompt = "Add overrides, ";
         else:
             print "W: [!] marked entries must be fixed before package can be processed.";
             if answer == 'A':
                 answer = 'E';
-        prompt = prompt + "Edit overrides, Check, Manual reject, Skip, Quit ?";
+        prompt = prompt + "Edit overrides, Check, Manual reject, [S]kip, Quit ?";
 
         while string.find(prompt, answer) == -1:
-            answer = raw_input(prompt)
-            m = katie.re_default_answer.match(prompt)
+            answer = utils.our_raw_input(prompt);
+            m = katie.re_default_answer.search(prompt);
             if answer == "":
                 answer = m.group(1)
             answer = string.upper(answer[:1])
@@ -560,9 +572,10 @@ def do_new():
         elif answer == 'E':
             new = edit_overrides (new);
         elif answer == 'M':
-            Katie.do_reject(1, Options["Manual-Reject"]);
-            os.unlink(Katie.pkg.changes_file[:-8]+".katie");
-            done = 1;
+            aborted = Katie.do_reject(1, Options["Manual-Reject"]);
+            if not aborted:
+                os.unlink(Katie.pkg.changes_file[:-8]+".katie");
+                done = 1;
         elif answer == 'S':
             done = 1;
         elif answer == 'Q':
@@ -656,11 +669,11 @@ def do_byhand():
             prompt = "Manual reject, [S]kip, Quit ?";
 
         while string.find(prompt, answer) == -1:
-            answer = raw_input(prompt)
-            m = katie.re_default_answer.match(prompt)
+            answer = utils.our_raw_input(prompt);
+            m = katie.re_default_answer.search(prompt);
             if answer == "":
-                answer = m.group(1)
-            answer = string.upper(answer[:1])
+                answer = m.group(1);
+            answer = string.upper(answer[:1]);
 
         if answer == 'A':
             done = 1;
@@ -740,13 +753,16 @@ def main():
 
     # Kill me now? **FIXME**
     Cnf["Dinstall::Options::No-Mail"] = "";
-    bcc = "X-Lisa: %s" % (lisa_version);
+    bcc = "X-Katie: %s" % (lisa_version);
     if Cnf.has_key("Dinstall::Bcc"):
         Katie.Subst["__BCC__"] = bcc + "\nBcc: %s" % (Cnf["Dinstall::Bcc"]);
     else:
         Katie.Subst["__BCC__"] = bcc;
 
     for changes_file in changes_files:
+        changes_file = utils.validate_changes_file_arg(changes_file, 0);
+        if not changes_file:
+            continue;
         print "\n" + changes_file;
         do_pkg (changes_file);