]> git.decadent.org.uk Git - dak.git/blobdiff - dak/security_install.py
Merge branch 'master' into security
[dak.git] / dak / security_install.py
old mode 100755 (executable)
new mode 100644 (file)
index 2763abb..3aebedc
@@ -32,7 +32,8 @@
 
 import commands, os, pwd, re, sys, time
 import apt_pkg
-import dak.lib.queue, dak.lib.utils
+from daklib import queue
+import daklib.utils
 
 ################################################################################
 
@@ -65,14 +66,14 @@ def do_upload(changes_files):
     uploads = {}; # uploads[uri] = file_list
     changesfiles = {}; # changesfiles[uri] = file_list
     package_list = {} # package_list[source_name][version]
-    changes_files.sort(dak.lib.utils.changes_compare)
+    changes_files.sort(daklib.utils.changes_compare)
     for changes_file in changes_files:
-        changes_file = dak.lib.utils.validate_changes_file_arg(changes_file)
+        changes_file = daklib.utils.validate_changes_file_arg(changes_file)
         # Reset variables
         components = {}
         upload_uris = {}
         file_list = []
-       Upload.init_vars()
+        Upload.init_vars()
         # Parse the .dak file for the .changes file
         Upload.pkg.changes_file = changes_file
         Upload.update_vars()
@@ -83,16 +84,13 @@ def do_upload(changes_files):
         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():
+        for f in files.keys():
             poolname = os.path.join(Cnf["Dir::Root"], Cnf["Dir::PoolRoot"],
-                                    dak.lib.utils.poolify(changes["source"], files[file]["component"]),
-                                    file)
+                                    daklib.utils.poolify(changes["source"], files[f]["component"]),
+                                    f)
             file_list.append(poolname)
-            orig_component = files[file].get("original component", files[file]["component"])
+            orig_component = files[f].get("original component", files[f]["component"])
             components[orig_component] = ""
         # Determine the upload uri for this .changes file
         for component in components.keys():
@@ -101,10 +99,10 @@ def do_upload(changes_files):
                 upload_uris[upload_uri] = ""
         num_upload_uris = len(upload_uris.keys())
         if num_upload_uris == 0:
-            dak.lib.utils.fubar("%s: No valid upload URI found from components (%s)."
+            daklib.utils.fubar("%s: No valid upload URI found from components (%s)."
                         % (changes_file, ", ".join(components.keys())))
         elif num_upload_uris > 1:
-            dak.lib.utils.fubar("%s: more than one upload URI (%s) from components (%s)."
+            daklib.utils.fubar("%s: more than one upload URI (%s) from components (%s)."
                         % (changes_file, ", ".join(upload_uris.keys()),
                            ", ".join(components.keys())))
         upload_uri = upload_uris.keys()[0]
@@ -113,7 +111,7 @@ def do_upload(changes_files):
             uploads[upload_uri] = []
         uploads[upload_uri].extend(file_list)
         # Update the changes list for the upload uri
-        if not changes.has_key(upload_uri):
+        if not changesfiles.has_key(upload_uri):
             changesfiles[upload_uri] = []
         changesfiles[upload_uri].append(changes_file)
         # Remember the suites and source name/version
@@ -140,11 +138,11 @@ def do_upload(changes_files):
 
     if not Options["No-Action"]:
         filename = "%s/testing-processed" % (Cnf["Dir::Log"])
-        file = dak.lib.utils.open_file(filename, 'a')
+        f = daklib.utils.open_file(filename, 'a')
         for source in package_list.keys():
             for version in package_list[source].keys():
-                file.write(" ".join([source, version])+'\n')
-        file.close()
+                f.write(" ".join([source, version])+'\n')
+        f.close()
 
 ######################################################################
 # This function was originally written by aj and NIHishly merged into
@@ -155,50 +153,50 @@ def make_advisory(advisory_nr, changes_files):
     updated_pkgs = {};  # updated_pkgs[distro][arch][file] = {path,md5,size}
 
     for arg in changes_files:
-        arg = dak.lib.utils.validate_changes_file_arg(arg)
-       Upload.pkg.changes_file = arg
-       Upload.init_vars()
-       Upload.update_vars()
-
-       src = Upload.pkg.changes["source"]
-       if src not in adv_packages:
-           adv_packages += [src]
-
-       suites = Upload.pkg.changes["distribution"].keys()
-       for suite in suites:
-           if not updated_pkgs.has_key(suite):
+        arg = daklib.utils.validate_changes_file_arg(arg)
+        Upload.pkg.changes_file = arg
+        Upload.init_vars()
+        Upload.update_vars()
+
+        src = Upload.pkg.changes["source"]
+        if src not in adv_packages:
+            adv_packages += [src]
+
+        suites = Upload.pkg.changes["distribution"].keys()
+        for suite in suites:
+            if not updated_pkgs.has_key(suite):
                 updated_pkgs[suite] = {}
 
-       files = Upload.pkg.files
-       for file in files.keys():
-           arch = files[file]["architecture"]
-           md5 = files[file]["md5sum"]
-           size = files[file]["size"]
-           poolname = Cnf["Dir::PoolRoot"] + \
-               dak.lib.utils.poolify(src, files[file]["component"])
-           if arch == "source" and file.endswith(".dsc"):
-               dscpoolname = poolname
-           for suite in suites:
-               if not updated_pkgs[suite].has_key(arch):
-                   updated_pkgs[suite][arch] = {}
-               updated_pkgs[suite][arch][file] = {
+        files = Upload.pkg.files
+        for f in files.keys():
+            arch = files[f]["architecture"]
+            md5 = files[f]["md5sum"]
+            size = files[f]["size"]
+            poolname = Cnf["Dir::PoolRoot"] + \
+                daklib.utils.poolify(src, files[f]["component"])
+            if arch == "source" and f.endswith(".dsc"):
+                dscpoolname = poolname
+            for suite in suites:
+                if not updated_pkgs[suite].has_key(arch):
+                    updated_pkgs[suite][arch] = {}
+                updated_pkgs[suite][arch][f] = {
                     "md5": md5, "size": size,
                     "poolname": poolname }
 
-       dsc_files = Upload.pkg.dsc_files
-       for file in dsc_files.keys():
-           arch = "source"
-           if not dsc_files[file].has_key("files id"):
+        dsc_files = Upload.pkg.dsc_files
+        for f in dsc_files.keys():
+            arch = "source"
+            if not dsc_files[f].has_key("files id"):
                 continue
 
-           # otherwise, it's already in the pool and needs to be
-           # listed specially
-           md5 = dsc_files[file]["md5sum"]
-           size = dsc_files[file]["size"]
-           for suite in suites:
-               if not updated_pkgs[suite].has_key(arch):
-                   updated_pkgs[suite][arch] = {}
-               updated_pkgs[suite][arch][file] = {
+            # otherwise, it's already in the pool and needs to be
+            # listed specially
+            md5 = dsc_files[f]["md5sum"]
+            size = dsc_files[f]["size"]
+            for suite in suites:
+                if not updated_pkgs[suite].has_key(arch):
+                    updated_pkgs[suite][arch] = {}
+                updated_pkgs[suite][arch][f] = {
                     "md5": md5, "size": size,
                     "poolname": dscpoolname }
 
@@ -210,10 +208,10 @@ def make_advisory(advisory_nr, changes_files):
     username = whoamifull[4].split(",")[0]
 
     Subst = {
-       "__ADVISORY__": advisory_nr,
-       "__WHOAMI__": username,
-       "__DATE__": time.strftime("%B %d, %Y", time.gmtime(time.time())),
-       "__PACKAGE__": ", ".join(adv_packages),
+        "__ADVISORY__": advisory_nr,
+        "__WHOAMI__": username,
+        "__DATE__": time.strftime("%B %d, %Y", time.gmtime(time.time())),
+        "__PACKAGE__": ", ".join(adv_packages),
         "__DAK_ADDRESS__": Cnf["Dinstall::MyEmailAddress"]
         }
 
@@ -221,48 +219,48 @@ def make_advisory(advisory_nr, changes_files):
         Subst["__BCC__"] = "Bcc: %s" % (Cnf["Dinstall::Bcc"])
 
     adv = ""
-    archive = Cnf["Archive::%s::PrimaryMirror" % (dak.lib.utils.where_am_i())]
+    archive = Cnf["Archive::%s::PrimaryMirror" % (daklib.utils.where_am_i())]
     for suite in updated_pkgs.keys():
         suite_header = "%s %s (%s)" % (Cnf["Dinstall::MyDistribution"],
                                        Cnf["Suite::%s::Version" % suite], suite)
         adv += "%s\n%s\n\n" % (suite_header, "-"*len(suite_header))
 
-       arches = Cnf.ValueList("Suite::%s::Architectures" % suite)
-       if "source" in arches:
+        arches = Cnf.ValueList("Suite::%s::Architectures" % suite)
+        if "source" in arches:
             arches.remove("source")
-       if "all" in arches:
+        if "all" in arches:
             arches.remove("all")
-       arches.sort()
+        arches.sort()
 
-       adv += "  %s was released for %s.\n\n" % (
-               suite.capitalize(), dak.lib.utils.join_with_commas_and(arches))
+        adv += "  %s was released for %s.\n\n" % (
+                suite.capitalize(), daklib.utils.join_with_commas_and(arches))
 
-       for a in ["source", "all"] + arches:
-           if not updated_pkgs[suite].has_key(a):
+        for a in ["source", "all"] + arches:
+            if not updated_pkgs[suite].has_key(a):
                 continue
 
-           if a == "source":
-               adv += "  Source archives:\n\n"
-           elif a == "all":
-               adv += "  Architecture independent packages:\n\n"
-           else:
-               adv += "  %s architecture (%s)\n\n" % (a,
-                       Cnf["Architectures::%s" % a])
-
-           for file in updated_pkgs[suite][a].keys():
-               adv += "    http://%s/%s%s\n" % (
-                               archive, updated_pkgs[suite][a][file]["poolname"], file)
-               adv += "      Size/MD5 checksum: %8s %s\n" % (
-                       updated_pkgs[suite][a][file]["size"],
-                       updated_pkgs[suite][a][file]["md5"])
-           adv += "\n"
+            if a == "source":
+                adv += "  Source archives:\n\n"
+            elif a == "all":
+                adv += "  Architecture independent packages:\n\n"
+            else:
+                adv += "  %s architecture (%s)\n\n" % (a,
+                        Cnf["Architectures::%s" % a])
+
+            for f in updated_pkgs[suite][a].keys():
+                adv += "    http://%s/%s%s\n" % (
+                                archive, updated_pkgs[suite][a][f]["poolname"], f)
+                adv += "      Size/MD5 checksum: %8s %s\n" % (
+                        updated_pkgs[suite][a][f]["size"],
+                        updated_pkgs[suite][a][f]["md5"])
+            adv += "\n"
     adv = adv.rstrip()
 
     Subst["__ADVISORY_TEXT__"] = adv
 
-    adv = dak.lib.utils.TemplateSubst(Subst, Cnf["Dir::Templates"]+"/security-install.advisory")
+    adv = daklib.utils.TemplateSubst(Subst, Cnf["Dir::Templates"]+"/security-install.advisory")
     if not Options["No-Action"]:
-        dak.lib.utils.send_mail (adv)
+        daklib.utils.send_mail (adv)
     else:
         print "[<Would send template advisory mail>]"
 
@@ -272,7 +270,7 @@ def init():
     global Cnf, Upload, Options
 
     apt_pkg.init()
-    Cnf = dak.lib.utils.get_conf()
+    Cnf = daklib.utils.get_conf()
 
     Arguments = [('h', "help", "Security-Install::Options::Help"),
                  ('n', "no-action", "Security-Install::Options::No-Action")]
@@ -282,7 +280,7 @@ def init():
 
     arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
     Options = Cnf.SubTree("Security-Install::Options")
-    Upload = dak.lib.queue.Upload(Cnf)
+    Upload = queue.Upload(Cnf)
 
     if Options["Help"]:
         usage(0)
@@ -293,17 +291,17 @@ def init():
     advisory_number = arguments[0]
     changes_files = arguments[1:]
     if advisory_number.endswith(".changes"):
-        dak.lib.utils.warn("first argument must be the advisory number.")
+        daklib.utils.warn("first argument must be the advisory number.")
         usage(1)
-    for file in changes_files:
-        file = dak.lib.utils.validate_changes_file_arg(file)
+    for f in changes_files:
+        f = daklib.utils.validate_changes_file_arg(f)
     return (advisory_number, changes_files)
 
 ######################################################################
 
 def yes_no(prompt):
     while 1:
-        answer = dak.lib.utils.our_raw_input(prompt+" ").lower()
+        answer = daklib.utils.our_raw_input(prompt+" ").lower()
         if answer == "y" or answer == "n":
             break
         else:
@@ -314,37 +312,40 @@ def yes_no(prompt):
 
 def spawn(command):
     if not re_taint_free.match(command):
-        dak.lib.utils.fubar("Invalid character in \"%s\"." % (command))
+        daklib.utils.fubar("Invalid character in \"%s\"." % (command))
 
     if Options["No-Action"]:
         print "[%s]" % (command)
     else:
         (result, output) = commands.getstatusoutput(command)
         if (result != 0):
-            dak.lib.utils.fubar("Invocation of '%s' failed:\n%s\n" % (command, output), result)
+            daklib.utils.fubar("Invocation of '%s' failed:\n%s\n" % (command, output), result)
 
 ######################################################################
 
 
 def main():
+    print "Disabled. See your team@security email, and/or contact aj on OFTC."
+    sys.exit(1)
+
     (advisory_number, changes_files) = init()
 
     if not Options["No-Action"]:
         print "About to install the following files: "
-        for file in changes_files:
-            print "  %s" % (file)
+        for f in changes_files:
+            print "  %s" % (f)
         answer = yes_no("Continue (Y/n)?")
         if answer == "n":
             sys.exit(0)
 
     os.chdir(Cnf["Dir::Queue::Accepted"])
     print "Installing packages into the archive..."
-    spawn("dak process-accepted -pa %s" % (Cnf["Dir::Dak"], " ".join(changes_files)))
+    spawn("dak process-accepted -pa %s" % (" ".join(changes_files)))
     os.chdir(Cnf["Dir::Dak"])
     print "Updating file lists for apt-ftparchive..."
     spawn("dak make-suite-file-list")
     print "Updating Packages and Sources files..."
-    spawn("apt-ftparchive generate %s" % (dak.lib.utils.which_apt_conf_file()))
+    spawn("apt-ftparchive generate %s" % (daklib.utils.which_apt_conf_file()))
     print "Updating Release files..."
     spawn("dak generate-releases")