]> git.decadent.org.uk Git - dak.git/blobdiff - katie
IntLevel fix for Shania. tbm's TrackingServer patch and comment typo.
[dak.git] / katie
diff --git a/katie b/katie
index fa600e60a8bc47acbbec82b5606a64c08a37c599..7decb53a352e7f4365b6ce1dde7d773775436d3c 100755 (executable)
--- a/katie
+++ b/katie
@@ -1,8 +1,8 @@
 #!/usr/bin/env python
 
-# Installs Debian packaes
+# Installs Debian packages
 # Copyright (C) 2000, 2001  James Troup <james@nocrew.org>
-# $Id: katie,v 1.61 2001-11-04 20:42:38 troup Exp $
+# $Id: katie,v 1.68 2002-01-28 18:53:01 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
@@ -20,7 +20,7 @@
 
 # Originally based almost entirely on dinstall by Guy Maor <maor@debian.org>
 
-#########################################################################################
+###############################################################################
 
 #    Cartman: "I'm trying to make the best of a bad situation, I don't
 #              need to hear crap from a bunch of hippy freaks living in
@@ -30,7 +30,7 @@
 #
 #    Cartman: "uhh.. screw you guys... home."
 
-#########################################################################################
+###############################################################################
 
 import FCNTL, commands, fcntl, getopt, gzip, os, pg, pwd, re, shutil, stat, string, sys, tempfile, time, traceback
 import apt_inst, apt_pkg
@@ -70,17 +70,14 @@ orig_tar_location = "";
 legacy_source_untouchable = {};
 Subst = {};
 nmu = None;
-katie_version = "$Revision: 1.61 $";
+katie_version = "$Revision: 1.68 $";
 
 ###############################################################################
 
 def init():
     global Cnf, Options;
 
-    apt_pkg.init();
-
-    Cnf = apt_pkg.newConfiguration();
-    apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
+    Cnf = utils.get_conf()
 
     Arguments = [('a',"automatic","Dinstall::Options::Automatic"),
                  ('h',"help","Dinstall::Options::Help"),
@@ -94,14 +91,15 @@ def init():
 
     for i in ["automatic", "help", "ack-new", "manual-reject", "no-action",
               "no-lock", "no-mail", "override-distribution", "version"]:
-        Cnf["Dinstall::Options::%s" % (i)] = "";
+       if not Cnf.has_key("Dinstall::Options::%s" % (i)):
+           Cnf["Dinstall::Options::%s" % (i)] = "";
 
     changes_files = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
     Options = Cnf.SubTree("Dinstall::Options")
 
     return changes_files;
 
-#########################################################################################
+###############################################################################
 
 def usage (exit_code=0):
     print """Usage: dinstall [OPTION]... [CHANGES]...
@@ -135,7 +133,7 @@ class nmu_p:
         self.group_maint = {};
         if Cnf.get("Dinstall::GroupOverrideFilename"):
             filename = Cnf["Dir::OverrideDir"] + Cnf["Dinstall::GroupOverrideFilename"];
-            file = utils.open_file(filename, 'r');
+            file = utils.open_file(filename);
             for line in file.readlines():
                 line = string.strip(utils.re_comments.sub('', line));
                 if line != "":
@@ -301,7 +299,7 @@ def check_changes(filename):
                 reject_message = reject_message + "Rejected: `%s' from Closes field isn't a number.\n" % (i)
 
     # Ensure there _is_ a target distribution
-    if changes["distribution"].keys() == []:
+    if not changes["distribution"].keys():
         reject_message = reject_message + "Rejected: huh? Distribution field is empty in changes file.\n";
 
     # Map frozen to unstable if frozen doesn't exist
@@ -395,7 +393,7 @@ def check_files():
 
             # Extract package information using dpkg-deb
             try:
-                control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(file,"r")))
+                control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(file)));
             except:
                 reject_message = reject_message + "Rejected: %s: debExtractControl() raised %s.\n" % (file, sys.exc_type);
                 # Can't continue, none of the checks on control would work.
@@ -670,7 +668,7 @@ def check_dsc ():
                         if len(ql) > 1:
                             for i in ql:
                                 old_file = i[0] + i[1];
-                                actual_md5 = apt_pkg.md5sum(utils.open_file(old_file,"r"));
+                                actual_md5 = apt_pkg.md5sum(utils.open_file(old_file));
                                 actual_size = os.stat(old_file)[stat.ST_SIZE];
                                 if actual_md5 == dsc_files[dsc_file]["md5sum"] and actual_size == int(dsc_files[dsc_file]["size"]):
                                     x = i;
@@ -678,7 +676,7 @@ def check_dsc ():
                                     legacy_source_untouchable[i[3]] = "";
 
                         old_file = x[0] + x[1];
-                        actual_md5 = apt_pkg.md5sum(utils.open_file(old_file,"r"));
+                        actual_md5 = apt_pkg.md5sum(utils.open_file(old_file));
                         actual_size = os.stat(old_file)[stat.ST_SIZE];
                         found = old_file;
                         suite_type = x[2];
@@ -750,7 +748,7 @@ def check_md5sums ():
 
     for file in files.keys():
         try:
-            file_handle = utils.open_file(file,"r");
+            file_handle = utils.open_file(file);
         except utils.cant_open_exc:
             pass;
         else:
@@ -813,6 +811,8 @@ def update_subst (changes_filename):
         Subst["__MAINTAINER_FROM__"] = changes["maintainer822"];
         Subst["__MAINTAINER_TO__"] = changes["maintainer822"];
         Subst["__MAINTAINER__"] = changes.get("maintainer", "Unknown");
+    if Cnf.has_key("Dinstall::TrackingServer") and changes.has_key("source"):
+        Subst["__MAINTAINER_TO__"] = Subst["__MAINTAINER_TO__"] + "\nBcc: %s@%s" % (changes.get("source"), Cnf["Dinstall::TrackingServer"])
 
     Subst["__REJECT_MESSAGE__"] = reject_message;
     Subst["__SOURCE__"] = changes.get("source", "Unknown");
@@ -821,21 +821,23 @@ def update_subst (changes_filename):
 #####################################################################################################################
 
 def action (changes_filename):
-    byhand = confirm = suites = summary = new = "";
+    byhand = summary = new = "";
 
     # changes["distribution"] may not exist in corner cases
     # (e.g. unreadable changes files)
     if not changes.has_key("distribution") or not isinstance(changes["distribution"], DictType):
         changes["distribution"] = {};
 
+    confirm = []
+    suites = []
     for suite in changes["distribution"].keys():
         if Cnf.has_key("Suite::%s::Confirm"):
-            confirm = confirm + suite + ", "
-        suites = suites + suite + ", "
-    confirm = confirm[:-2]
-    suites = suites[:-2]
+            confirm.append(suite)
+        suites.append(suite)
 
-    for file in files.keys():
+    file_keys = files.keys();
+    file_keys.sort();
+    for file in file_keys:
         if files[file].has_key("byhand"):
             byhand = 1
             summary = summary + file + " byhand\n"
@@ -845,7 +847,7 @@ def action (changes_filename):
             if files[file].has_key("othercomponents"):
                 summary = summary + "WARNING: Already present in %s distribution.\n" % (files[file]["othercomponents"])
             if files[file]["type"] == "deb":
-                summary = summary + apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(file,"r")))["Description"] + '\n';
+                summary = summary + apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(file)))["Description"] + '\n';
         else:
             files[file]["pool name"] = utils.poolify (changes["source"], files[file]["component"])
             destination = Cnf["Dir::PoolRoot"] + files[file]["pool name"] + file
@@ -879,7 +881,7 @@ def action (changes_filename):
             if Options["Automatic"]:
                 answer = 'R';
     elif new:
-        print "NEW to %s\n%s%s" % (suites, reject_message, summary),;
+        print "NEW to %s\n%s%s" % (string.join(suites, ", "), reject_message, summary),;
         prompt = "[S]kip, New ack, Manual reject, Quit ?";
         if Options["Automatic"] and Options["Ack-New"]:
             answer = 'N';
@@ -887,7 +889,7 @@ def action (changes_filename):
         print "BYHAND\n" + reject_message + summary,;
         prompt = "[I]nstall, Manual reject, Skip, Quit ?";
     elif confirm:
-        print "CONFIRM to %s\n%s%s" % (confirm, reject_message, summary),
+        print "CONFIRM to %s\n%s%s" % (string.join(confirm, ", "), reject_message, summary),
         prompt = "[I]nstall, Manual reject, Skip, Quit ?";
     else:
         print "INSTALL\n" + reject_message + summary,;
@@ -914,7 +916,7 @@ def action (changes_filename):
     elif answer == 'Q':
         sys.exit(0)
 
-#####################################################################################################################
+###############################################################################
 
 def install (changes_filename, summary, short_summary):
     global install_count, install_bytes, Subst;
@@ -1063,7 +1065,7 @@ def install (changes_filename, summary, short_summary):
         announce (short_summary, 1)
         check_override ();
 
-#####################################################################################################################
+################################################################################
 
 def stable_install (changes_filename, summary, short_summary):
     global install_count, install_bytes, Subst;
@@ -1082,7 +1084,7 @@ def stable_install (changes_filename, summary, short_summary):
             version = dsc["version"]  # NB: not files[file]["version"], that has no epoch
             q = projectB.query("SELECT id FROM source WHERE source = '%s' AND version = '%s'" % (package, version))
             ql = q.getresult()
-            if ql == []:
+            if not ql:
                 utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s) in source table." % (package, version));
             source_id = ql[0][0];
             suite_id = db_access.get_suite_id('proposed-updates');
@@ -1099,7 +1101,7 @@ def stable_install (changes_filename, summary, short_summary):
             architecture = files[file]["architecture"]
             q = projectB.query("SELECT b.id FROM binaries b, architecture a WHERE b.package = '%s' AND b.version = '%s' AND (a.arch_string = '%s' OR a.arch_string = 'all') AND b.architecture = a.id" % (package, version, architecture))
             ql = q.getresult()
-            if ql == []:
+            if not ql:
                 utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s for %s architecture) in binaries table." % (package, version, architecture));
             binary_id = ql[0][0];
             suite_id = db_access.get_suite_id('proposed-updates');
@@ -1131,7 +1133,7 @@ def stable_install (changes_filename, summary, short_summary):
     chop_changes = re_fdnic.sub("\n", changes["changes"]);
     new_changelog.write(chop_changes + '\n\n');
     if os.access(changelog_filename, os.R_OK) != 0:
-        changelog = utils.open_file(changelog_filename, 'r');
+        changelog = utils.open_file(changelog_filename);
         new_changelog.write(changelog.read());
     new_changelog.close();
     if os.access(changelog_filename, os.R_OK) != 0:
@@ -1181,7 +1183,7 @@ def reject (changes_filename, manual_reject_mail_filename):
                 version = dsc["version"];  # NB: not files[file]["version"], that has no epoch
                 q = projectB.query("SELECT id FROM source WHERE source = '%s' AND version = '%s'" % (package, version));
                 ql = q.getresult();
-                if ql == []:
+                if not ql:
                     utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s) in source table." % (package, version));
                 source_id = ql[0][0];
                 projectB.query("DELETE FROM src_associations WHERE suite = '%s' AND source = '%s'" % (suite_id, source_id));
@@ -1191,7 +1193,7 @@ def reject (changes_filename, manual_reject_mail_filename):
                 architecture = files[file]["architecture"];
                 q = projectB.query("SELECT b.id FROM binaries b, architecture a WHERE b.package = '%s' AND b.version = '%s' AND (a.arch_string = '%s' OR a.arch_string = 'all') AND b.architecture = a.id" % (package, version, architecture));
                 ql = q.getresult();
-                if ql == []:
+                if not ql:
                     utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s for %s architecture) in binaries table." % (package, version, architecture));
                 binary_id = ql[0][0];
                 projectB.query("DELETE FROM bin_associations WHERE suite = '%s' AND bin = '%s'" % (suite_id, binary_id));
@@ -1257,6 +1259,8 @@ def acknowledge_new (changes_filename, summary):
 
     changes_filename = os.path.basename(changes_filename);
 
+    Logger.log(["new",changes_filename]);
+
     new_ack_new[changes_filename] = 1;
 
     if new_ack_old.has_key(changes_filename):
@@ -1422,7 +1426,7 @@ def main():
         # Read in the list of already-acknowledged NEW packages
         if not os.path.exists(Cnf["Dinstall::NewAckList"]):
             utils.touch_file(Cnf["Dinstall::NewAckList"]);
-        new_ack_list = utils.open_file(Cnf["Dinstall::NewAckList"],'r');
+        new_ack_list = utils.open_file(Cnf["Dinstall::NewAckList"]);
         new_ack_old = {};
         for line in new_ack_list.readlines():
             new_ack_old[line[:-1]] = 1;