]> git.decadent.org.uk Git - dak.git/blobdiff - amber
more typos/thinkos
[dak.git] / amber
diff --git a/amber b/amber
index fb680c8ee66d1b3d3a0b3db6d8a44d3d4d4241df..4f1832adee18e517459ecc154182c4a19e0a8828 100755 (executable)
--- a/amber
+++ b/amber
@@ -1,8 +1,8 @@
 #!/usr/bin/env python
 
 # Wrapper for Debian Security team
-# Copyright (C) 2002  James Troup <james@nocrew.org>
-# $Id: amber,v 1.4 2002-06-09 17:31:12 troup Exp $
+# Copyright (C) 2002, 2003, 2004  James Troup <james@nocrew.org>
+# $Id: amber,v 1.11 2005-11-26 07:52:06 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
@@ -31,7 +31,7 @@
 
 ################################################################################
 
-import commands, os, pwd, re, string, sys, time;
+import commands, os, pwd, re, sys, time;
 import apt_pkg;
 import katie, utils;
 
@@ -64,7 +64,9 @@ def do_upload(changes_files):
     for component in Cnf.SubTree("Amber::ComponentMappings").List():
         component_mapping[component] = Cnf["Amber::ComponentMappings::%s" % (component)];
     uploads = {}; # uploads[uri] = file_list;
+    changesfiles = {}; # changesfiles[uri] = file_list;
     package_list = {} # package_list[source_name][version];
+    changes_files.sort(utils.changes_compare);
     for changes_file in changes_files:
         changes_file = utils.validate_changes_file_arg(changes_file);
         # Reset variables
@@ -78,6 +80,13 @@ def do_upload(changes_files):
         files = Katie.pkg.files;
         changes = Katie.pkg.changes;
         dsc = Katie.pkg.dsc;
+        # We have the changes, now return if its amd64, to not upload them to ftp-master
+        if changes["architecture"].has_key("amd64"):
+            print "Not uploading amd64 part to ftp-master\n";
+            continue
+        if changes["distribution"].has_key("oldstable-security"):
+            print "Not uploading oldstable-security changes to ftp-master\n";
+            continue
         # Build the file list for this .changes file
         for file in files.keys():
             poolname = os.path.join(Cnf["Dir::Root"], Cnf["Dir::PoolRoot"],
@@ -86,7 +95,6 @@ def do_upload(changes_files):
             file_list.append(poolname);
             orig_component = files[file].get("original component", files[file]["component"]);
             components[orig_component] = "";
-        file_list.append(changes_file);
         # Determine the upload uri for this .changes file
         for component in components.keys():
             upload_uri = component_mapping.get(component);
@@ -95,16 +103,20 @@ def do_upload(changes_files):
         num_upload_uris = len(upload_uris.keys());
         if num_upload_uris == 0:
             utils.fubar("%s: No valid upload URI found from components (%s)."
-                        % (changes_file, string.join(components.keys(), ", ")));
+                        % (changes_file, ", ".join(components.keys())));
         elif num_upload_uris > 1:
             utils.fubar("%s: more than one upload URI (%s) from components (%s)."
-                        % (changes_file, string.join(upload_uris.keys(), ", "),
-                           string.join(components.keys(), ", ")));
+                        % (changes_file, ", ".join(upload_uris.keys()),
+                           ", ".join(components.keys())));
         upload_uri = upload_uris.keys()[0];
         # Update the file list for the upload uri
         if not uploads.has_key(upload_uri):
             uploads[upload_uri] = [];
         uploads[upload_uri].extend(file_list);
+        # Update the changes list for the upload uri
+        if not changes.has_key(upload_uri):
+            changesfiles[upload_uri] = [];
+        changesfiles[upload_uri].append(changes_file);
         # Remember the suites and source name/version
         for suite in changes["distribution"].keys():
             suites[suite] = "";
@@ -115,18 +127,15 @@ def do_upload(changes_files):
                 package_list[dsc["source"]] = {};
             package_list[dsc["source"]][dsc["version"]] = "";
 
-    if len(suites.keys()) == 1 and suites.has_key("oldstable"):
-        print "Advisory only for 'oldstable'; not uploading elsewhere.";
-        return;
-
     if not Options["No-Action"]:
         answer = yes_no("Upload to files to main archive (Y/n)?");
         if answer != "y":
             return;
 
     for uri in uploads.keys():
-        (host, path) = string.split(uri, ":");
-        file_list = string.join(uploads[uri]);
+        uploads[uri].extend(changesfiles[uri]);
+        (host, path) = uri.split(":");
+        file_list = " ".join(uploads[uri]);
         print "Uploading files to %s..." % (host);
         spawn("lftp -c 'open %s; cd %s; put %s'" % (host, path, file_list));
 
@@ -135,20 +144,12 @@ def do_upload(changes_files):
         file = utils.open_file(filename, 'a');
         for source in package_list.keys():
             for version in package_list[source].keys():
-                file.write(string.join([source, version])+'\n');
+                file.write(" ".join([source, version])+'\n');
         file.close();
 
-################################################################################
-
-# Next two functions originally written by aj and NIHishly merged into
-# amber by me.
-
-def join_with_commas_and(list):
-       if len(list) == 0: return "nothing";
-       if len(list) == 1: return list[0];
-       return string.join(list[:-1], ", ") + " and " + list[-1];
-
 ######################################################################
+# This function was originally written by aj and NIHishly merged into
+# amber by me.
 
 def make_advisory(advisory_nr, changes_files):
     adv_packages = [];
@@ -162,7 +163,7 @@ def make_advisory(advisory_nr, changes_files):
 
        src = Katie.pkg.changes["source"];
        if src not in adv_packages:
-           adv_packages = adv_packages + [src];
+           adv_packages += [src];
 
        suites = Katie.pkg.changes["distribution"].keys();
        for suite in suites:
@@ -176,7 +177,7 @@ def make_advisory(advisory_nr, changes_files):
            size = files[file]["size"];
            poolname = Cnf["Dir::PoolRoot"] + \
                utils.poolify(src, files[file]["component"]);
-           if arch == "source" and file[-4:] == ".dsc":
+           if arch == "source" and file.endswith(".dsc"):
                dscpoolname = poolname;
            for suite in suites:
                if not updated_pkgs[suite].has_key(arch):
@@ -203,17 +204,17 @@ def make_advisory(advisory_nr, changes_files):
                     "poolname": dscpoolname };
 
     if os.environ.has_key("SUDO_UID"):
-        whoami = string.atol(os.environ["SUDO_UID"]);
+        whoami = long(os.environ["SUDO_UID"]);
     else:
         whoami = os.getuid();
     whoamifull = pwd.getpwuid(whoami);
-    username = string.split(whoamifull[4], ",")[0];
+    username = whoamifull[4].split(",")[0];
 
     Subst = {
        "__ADVISORY__": advisory_nr,
        "__WHOAMI__": username,
        "__DATE__": time.strftime("%B %d, %Y", time.gmtime(time.time())),
-       "__PACKAGE__": string.join(adv_packages,", "),
+       "__PACKAGE__": ", ".join(adv_packages),
         "__KATIE_ADDRESS__": Cnf["Dinstall::MyEmailAddress"]
         };
 
@@ -225,7 +226,7 @@ def make_advisory(advisory_nr, changes_files):
     for suite in updated_pkgs.keys():
         suite_header = "%s %s (%s)" % (Cnf["Dinstall::MyDistribution"],
                                        Cnf["Suite::%s::Version" % suite], suite);
-        adv = adv + "%s\n%s\n\n" % (suite_header, "-"*len(suite_header));
+        adv += "%s\n%s\n\n" % (suite_header, "-"*len(suite_header));
 
        arches = Cnf.ValueList("Suite::%s::Architectures" % suite);
        if "source" in arches:
@@ -234,35 +235,35 @@ def make_advisory(advisory_nr, changes_files):
             arches.remove("all");
        arches.sort();
 
-       adv = adv + "  %s was released for %s.\n\n" % (
-               string.capitalize(suite), join_with_commas_and(arches));
+       adv += "  %s was released for %s.\n\n" % (
+               suite.capitalize(), utils.join_with_commas_and(arches));
 
        for a in ["source", "all"] + arches:
            if not updated_pkgs[suite].has_key(a):
                 continue;
 
            if a == "source":
-               adv = adv + "  Source archives:\n\n";
+               adv += "  Source archives:\n\n";
            elif a == "all":
-               adv = adv + "  Architecture independent packages:\n\n";
+               adv += "  Architecture independent packages:\n\n";
            else:
-               adv = adv + "  %s architecture (%s)\n\n" % (a,
+               adv += "  %s architecture (%s)\n\n" % (a,
                        Cnf["Architectures::%s" % a]);
 
            for file in updated_pkgs[suite][a].keys():
-               adv = adv + "    http://%s/%s%s\n" % (
+               adv += "    http://%s/%s%s\n" % (
                                archive, updated_pkgs[suite][a][file]["poolname"], file);
-               adv = adv + "      Size/MD5 checksum: %8s %s\n" % (
+               adv += "      Size/MD5 checksum: %8s %s\n" % (
                        updated_pkgs[suite][a][file]["size"],
                        updated_pkgs[suite][a][file]["md5"]);
-           adv = adv + "\n";
-    adv = string.rstrip(adv);
+           adv += "\n";
+    adv = adv.rstrip();
 
     Subst["__ADVISORY_TEXT__"] = adv;
 
     adv = utils.TemplateSubst(Subst, Cnf["Dir::Templates"]+"/amber.advisory");
     if not Options["No-Action"]:
-        utils.send_mail (adv, "");
+        utils.send_mail (adv);
     else:
         print "[<Would send template advisory mail>]";
 
@@ -292,7 +293,7 @@ def init():
 
     advisory_number = arguments[0];
     changes_files = arguments[1:];
-    if advisory_number[-8:] == ".changes":
+    if advisory_number.endswith(".changes"):
         utils.warn("first argument must be the advisory number.");
         usage(1);
     for file in changes_files:
@@ -303,7 +304,7 @@ def init():
 
 def yes_no(prompt):
     while 1:
-        answer = string.lower(utils.our_raw_input(prompt+" "));
+        answer = utils.our_raw_input(prompt+" ").lower();
         if answer == "y" or answer == "n":
             break;
         else:
@@ -339,7 +340,7 @@ def main():
 
     os.chdir(Cnf["Dir::Queue::Accepted"]);
     print "Installing packages into the archive...";
-    spawn("%s/katie -pa %s" % (Cnf["Dir::Katie"], string.join(changes_files)));
+    spawn("%s/kelly -pa %s" % (Cnf["Dir::Katie"], " ".join(changes_files)));
     os.chdir(Cnf["Dir::Katie"]);
     print "Updating file lists for apt-ftparchive...";
     spawn("./jenna");
@@ -355,6 +356,9 @@ def main():
     print "Generating template advisory...";
     make_advisory(advisory_number, changes_files);
 
+    # Trigger security mirrors
+    spawn("sudo -u archvsync /home/archvsync/signal_security");
+
     do_upload(changes_files);
 
 ################################################################################