]> git.decadent.org.uk Git - dak.git/blobdiff - katie
Add TemplateSubst.
[dak.git] / katie
diff --git a/katie b/katie
index 1532a5e1725b9978ef142a4287d774be2acd6cd8..f9a2242cdcad5eb815c0dcdd0fbaab123fe5f2a1 100755 (executable)
--- a/katie
+++ b/katie
@@ -1,8 +1,8 @@
 #!/usr/bin/env python
 
 # Installs Debian packaes
-# Copyright (C) 2000  James Troup <james@nocrew.org>
-# $Id: katie,v 1.26 2001-01-31 03:36:36 troup Exp $
+# Copyright (C) 2000, 2001  James Troup <james@nocrew.org>
+# $Id: katie,v 1.32 2001-03-20 00:28:11 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
@@ -39,8 +39,6 @@ import utils, db_access
 ###############################################################################
 
 re_isanum = re.compile (r'^\d+$');
-re_isadeb = re.compile (r'.*\.u?deb$');
-re_issource = re.compile (r'(.+)_(.+?)\.(orig\.tar\.gz|diff\.gz|tar\.gz|dsc)');
 re_changes = re.compile (r'changes$');
 re_default_answer = re.compile(r"\[(.*)\]");
 re_fdnic = re.compile("\n\n");
@@ -159,7 +157,10 @@ def in_override_p (package, component, suite, binary_type, file):
 def check_changes(filename):
     global reject_message, changes, files
 
-    # Parse the .changes field into a dictionary [FIXME - need to trap errors, pass on to reject_message etc.]
+    # Default in case we bail out
+    changes["maintainer822"] = Cnf["Dinstall::MyEmailAddress"]; 
+
+    # Parse the .changes field into a dictionary
     try:
         changes = utils.parse_changes(filename, 0)
     except utils.cant_open_exc:
@@ -167,10 +168,9 @@ def check_changes(filename):
         return 0;
     except utils.changes_parse_error_exc, line:
         reject_message = "Rejected: error parsing changes file '%s', can't grok: %s.\n" % (filename, line)
-        changes["maintainer822"] = Cnf["Dinstall::MyEmailAddress"];
         return 0;
 
-    # Parse the Files field from the .changes into another dictionary [FIXME need to trap errors as above]
+    # Parse the Files field from the .changes into another dictionary
     try:
         files = utils.build_file_list(changes, "");
     except utils.changes_parse_error_exc, line:
@@ -296,7 +296,7 @@ def check_files():
             files[file]["byhand"] = 1;
             files[file]["type"] = "byhand";
         # Checks for a binary package...
-        elif re_isadeb.match(file) != None:
+        elif utils.re_isadeb.match(file) != None:
             files[file]["type"] = "deb";
 
             # Extract package information using dpkg-deb
@@ -350,7 +350,7 @@ def check_files():
                 files[file]["source"] = files[file]["package"];
         # Checks for a source package...
         else:
-            m = re_issource.match(file)
+            m = utils.re_issource.match(file)
             if m != None:
                 files[file]["package"] = m.group(1)
                 files[file]["version"] = m.group(2)
@@ -427,6 +427,10 @@ def check_files():
             if component_id == -1:
                 reject_message = reject_message + "Rejected: file '%s' has unknown component '%s'.\n" % (file, component);
                 continue;
+
+            # Validate the priority
+            if string.find(files[file]["priority"],'/') != -1:
+                reject_message = reject_message + "Rejected: file '%s' has invalid priority '%s' [contains '/'].\n" % (file, files[file]["priority"]);
             
             # Check the md5sum & size against existing files (if any)
             location = Cnf["Dir::PoolDir"];
@@ -460,13 +464,13 @@ def check_dsc ():
             try:
                 dsc = utils.parse_changes(file, 1)
             except utils.cant_open_exc:
-                reject_message = reject_message + "Rejected: can't read changes file '%s'.\n" % (filename)
+                reject_message = reject_message + "Rejected: can't read changes file '%s'.\n" % (file)
                 return 0;
             except utils.changes_parse_error_exc, line:
-                reject_message = reject_message + "Rejected: error parsing changes file '%s', can't grok: %s.\n" % (filename, line)
+                reject_message = reject_message + "Rejected: error parsing changes file '%s', can't grok: %s.\n" % (file, line)
                 return 0;
             except utils.invalid_dsc_format_exc, line:
-                reject_message = reject_message + "Rejected: syntax error in .dsc file '%s', line %s.\n" % (filename, line)
+                reject_message = reject_message + "Rejected: syntax error in .dsc file '%s', line %s.\n" % (file, line)
                 return 0;
             try:
                 dsc_files = utils.build_file_list(dsc, 1)
@@ -474,7 +478,7 @@ def check_dsc ():
                 reject_message = reject_message + "Rejected: no Files: field in .dsc file.\n";
                 continue;
             except utils.changes_parse_error_exc, line:
-                reject_message = "Rejected: error parsing .dsc file '%s', can't grok: %s.\n" % (filename, line);
+                reject_message = "Rejected: error parsing .dsc file '%s', can't grok: %s.\n" % (file, line);
                 continue;
 
             # Try and find all files mentioned in the .dsc.  This has
@@ -609,7 +613,7 @@ def check_override ():
 
     summary = ""
     for file in files.keys():
-        if not files[file].has_key("new") and (files[file]["type"] == "dsc" or files[file]["type"] == "deb"):
+        if not files[file].has_key("new") and files[file]["type"] == "deb":
             section = files[file]["section"];
             override_section = files[file]["override section"];
             if section != override_section and section != "-":
@@ -617,11 +621,10 @@ def check_override ():
                 if string.lower(section) == "non-us/main" and string.lower(override_section) == "non-us":
                     continue;
                 summary = summary + "%s: section is overridden from %s to %s.\n" % (file, section, override_section);
-            if files[file]["type"] == "deb": # don't do priority for source
-                priority = files[file]["priority"];
-                override_priority = files[file]["override priority"];
-                if priority != override_priority and priority != "-":
-                    summary = summary + "%s: priority is overridden from %s to %s.\n" % (file, priority, override_priority);
+            priority = files[file]["priority"];
+            override_priority = files[file]["override priority"];
+            if priority != override_priority and priority != "-":
+                summary = summary + "%s: priority is overridden from %s to %s.\n" % (file, priority, override_priority);
 
     if summary == "":
         return;
@@ -861,7 +864,10 @@ def install (changes_filename, summary, short_summary):
 
     projectB.query("COMMIT WORK");
 
-    utils.move (changes_filename, Cnf["Dir::IncomingDir"] + 'DONE/' + os.path.basename(changes_filename))
+    try:
+        utils.move (changes_filename, Cnf["Dir::IncomingDir"] + 'DONE/' + os.path.basename(changes_filename))
+    except:
+        sys.stderr.write("W: couldn't move changes file '%s' to DONE directory [Got %s].\n" % (os.path.basename(changes_filename), sys.exc_type));
 
     install_count = install_count + 1;
 
@@ -941,7 +947,7 @@ def stable_install (changes_filename, summary, short_summary):
     for file in files.keys():
         if files[file]["type"] == "deb":
             new_changelog.write("stable/%s/binary-%s/%s\n" % (files[file]["component"], files[file]["architecture"], file));
-        elif re_issource.match(file) != None:
+        elif utils.re_issource.match(file) != None:
             new_changelog.write("stable/%s/source/%s\n" % (files[file]["component"], file));
         else:
             new_changelog.write("%s\n" % (file));
@@ -984,8 +990,8 @@ def reject (changes_filename, manual_reject_mail_filename):
     # Move the .changes files and it's contents into REJECT/ (if we can; errors are ignored)
     try:
         utils.move (changes_filename, "%s/REJECT/%s" % (Cnf["Dir::IncomingDir"], base_changes_filename));
-    except utils.cant_overwrite_exc:
-        sys.stderr.write("W: couldn't overwrite existing file '%s/REJECT/%s" % (Cnf["Dir::IncomingDir"], base_changes_filename));
+    except:
+        sys.stderr.write("W: couldn't reject changes file '%s' [Got %s].\n" % (base_changes_filename, sys.exc_type));
         pass;
     for file in files.keys():
         if os.path.exists(file):
@@ -1049,7 +1055,7 @@ Subject: %s REJECTED
     if manual_reject_message == "":
         result = os.system("vi +6 %s" % (reject_file))
         if result != 0:
-            sys.stderr.write ("vi invocation failed for `%s'!" % (reject_file))
+            sys.stderr.write ("vi invocation failed for `%s'!\n" % (reject_file))
             sys.exit(result)
 
     # Then process it as if it were an automatic rejection
@@ -1115,7 +1121,9 @@ Installed:
     (dsc_rfc822, dsc_name, dsc_email) = utils.fix_maintainer (dsc.get("maintainer",Cnf["Dinstall::MyEmailAddress"]));
     bugs = changes["closes"].keys()
     bugs.sort()
-    if dsc_name == changes["maintainername"]:
+    # changes["changedbyname"] == dsc_name is probably never true, but better
+    # safe than sorry
+    if dsc_name == changes["maintainername"] and (changes["changedbyname"] == "" or changes["changedbyname"] == dsc_name):
         summary = summary + "Closing bugs: "
         for bug in bugs:
             summary = summary + "%s " % (bug)
@@ -1162,7 +1170,7 @@ administrators by mailing ftpmaster@debian.org)
         control_message = ""
         for bug in bugs:
             summary = summary + "%s " % (bug)
-            control_message = control_message + "severity %s fixed\n" % (bug)
+            control_message = control_message + "tag %s + fixed\n" % (bug)
         if action and control_message != "":
             mail_message = """Return-Path: %s
 From: %s
@@ -1267,7 +1275,7 @@ def main():
         Cnf["Dinstall::Options::Ack-New"] = ""
         postgresql_user = Cnf["DB::ROUser"];
 
-    projectB = pg.connect('projectb', Cnf["DB::Host"], int(Cnf["DB::Port"]), None, None, postgresql_user);
+    projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]), None, None, postgresql_user);
 
     db_access.init(Cnf, projectB);