]> git.decadent.org.uk Git - dak.git/blobdiff - dak/process_accepted.py
Merge branch 'master' into content_generation
[dak.git] / dak / process_accepted.py
index 8e48ae1f7505715c56d211472d731e0e2b5d7199..fa66a0c42975c44df0f8ed777efb8f8b72804ba1 100755 (executable)
@@ -1,8 +1,7 @@
 #!/usr/bin/env python
 
 # Installs Debian packages from queue/accepted into the pool
-# Copyright (C) 2000, 2001, 2002, 2003, 2004  James Troup <james@nocrew.org>
-# $Id: kelly,v 1.18 2005-12-17 10:57:03 rmurray Exp $
+# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006  James Troup <james@nocrew.org>
 
 # 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, fcntl, os, sys, time, re
-import apt_pkg
-import db_access, katie, logging, utils
+import apt_pkg, tarfile, commands
+from daklib import database
+from daklib import logging
+from daklib import queue
+from daklib import utils
+from daklib.dak_exceptions import *
 
 ###############################################################################
 
-# Globals
-kelly_version = "$Revision: 1.18 $"
-
 Cnf = None
 Options = None
 Logger = None
 Urgency_Logger = None
 projectB = None
-Katie = None
+Upload = None
 pkg = None
 
 reject_message = ""
@@ -72,9 +72,9 @@ class Urgency_Log:
         self.timestamp = time.strftime("%Y%m%d%H%M%S")
         # Create the log directory if it doesn't exist
         self.log_dir = Cnf["Dir::UrgencyLog"]
-        if not os.path.exists(self.log_dir):
-            umask = os.umask(00000)
-            os.makedirs(self.log_dir, 02775)
+        if not os.path.exists(self.log_dir) or not os.access(self.log_dir, os.W_OK):
+            utils.warn("UrgencyLog directory %s does not exist or is not writeable, using /srv/ftp.debian.org/tmp/ instead" % (self.log_dir))
+            self.log_dir = '/srv/ftp.debian.org/tmp/'
         # Open the logfile
         self.log_filename = "%s/.install-urgencies-%s.new" % (self.log_dir, self.timestamp)
         self.log_file = utils.open_file(self.log_filename, 'w')
@@ -96,6 +96,43 @@ class Urgency_Log:
         else:
             os.unlink(self.log_filename)
 
+
+###############################################################################
+
+def generate_contents_information(filename):
+    # Generate all the contents for the database
+    cmd = "ar t %s" % (filename)
+    (result, output) = commands.getstatusoutput(cmd)
+    if result != 0:
+        reject("%s: 'ar t' invocation failed." % (filename))
+        reject(utils.prefix_multi_line_string(output, " [ar output:] "), "")
+
+    # Ugh ... this is ugly ... Code ripped from process_unchecked.py
+    chunks = output.split('\n')
+    cmd = "ar x %s %s" % (filename, chunks[2])
+    (result, output) = commands.getstatusoutput(cmd)
+    if result != 0:
+        reject("%s: 'ar t' invocation failed." % (filename))
+        reject(utils.prefix_multi_line_string(output, " [ar output:] "), "")
+
+    # Got deb tarballs, now lets go through and determine what bits
+    # and pieces the deb had ...
+    if chunks[2] == "data.tar.gz":
+        data = tarfile.open("data.tar.gz", "r:gz")
+    elif data_tar == "data.tar.bz2":
+        data = tarfile.open("data.tar.bz2", "r:bz2")
+    else:
+        os.remove(chunks[2])
+        reject("couldn't find data.tar.*")
+
+    contents = []
+    for tarinfo in data:
+        if not tarinfo.isdir():
+            contents.append(tarinfo.name[2:])
+
+    os.remove(chunks[2])
+    return contents
+
 ###############################################################################
 
 def reject (str, prefix="Rejected: "):
@@ -119,41 +156,41 @@ def check():
             source_version = files[file]["source version"]
             source_package = files[file]["source package"]
             if not changes["architecture"].has_key("source") \
-               and not Katie.source_exists(source_package, source_version,  changes["distribution"].keys()):
+               and not Upload.source_exists(source_package, source_version,  changes["distribution"].keys()):
                 reject("no source found for %s %s (%s)." % (source_package, source_version, file))
 
         # Version and file overwrite checks
         if not installing_to_stable:
             if files[file]["type"] == "deb":
-                reject(Katie.check_binary_against_db(file), "")
+                reject(Upload.check_binary_against_db(file), "")
             elif files[file]["type"] == "dsc":
-                reject(Katie.check_source_against_db(file), "")
-                (reject_msg, is_in_incoming) = Katie.check_dsc_against_db(file)
+                reject(Upload.check_source_against_db(file), "")
+                (reject_msg, is_in_incoming) = Upload.check_dsc_against_db(file)
                 reject(reject_msg, "")
 
         # propogate in the case it is in the override tables:
         if changes.has_key("propdistribution"):
             for suite in changes["propdistribution"].keys():
-               if Katie.in_override_p(files[file]["package"], files[file]["component"], suite, files[file].get("dbtype",""), file):
-                   propogate[suite] = 1
-               else:
-                   nopropogate[suite] = 1
+                if Upload.in_override_p(files[file]["package"], files[file]["component"], suite, files[file].get("dbtype",""), file):
+                    propogate[suite] = 1
+                else:
+                    nopropogate[suite] = 1
 
     for suite in propogate.keys():
-       if suite in nopropogate:
-           continue
-       changes["distribution"][suite] = 1
+        if suite in nopropogate:
+            continue
+        changes["distribution"][suite] = 1
 
     for file in files.keys():
         # Check the package is still in the override tables
         for suite in changes["distribution"].keys():
-            if not Katie.in_override_p(files[file]["package"], files[file]["component"], suite, files[file].get("dbtype",""), file):
+            if not Upload.in_override_p(files[file]["package"], files[file]["component"], suite, files[file].get("dbtype",""), file):
                 reject("%s is NEW for %s." % (file, suite))
 
 ###############################################################################
 
 def init():
-    global Cnf, Options, Katie, projectB, changes, dsc, dsc_files, files, pkg, Subst
+    global Cnf, Options, Upload, projectB, changes, dsc, dsc_files, files, pkg, Subst
 
     Cnf = utils.get_conf()
 
@@ -161,12 +198,11 @@ def init():
                  ('h',"help","Dinstall::Options::Help"),
                  ('n',"no-action","Dinstall::Options::No-Action"),
                  ('p',"no-lock", "Dinstall::Options::No-Lock"),
-                 ('s',"no-mail", "Dinstall::Options::No-Mail"),
-                 ('V',"version","Dinstall::Options::Version")]
+                 ('s',"no-mail", "Dinstall::Options::No-Mail")]
 
     for i in ["automatic", "help", "no-action", "no-lock", "no-mail", "version"]:
-       if not Cnf.has_key("Dinstall::Options::%s" % (i)):
-           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")
@@ -174,26 +210,22 @@ def init():
     if Options["Help"]:
         usage()
 
-    if Options["Version"]:
-        print "kelly %s" % (kelly_version)
-        sys.exit(0)
-
-    Katie = katie.Katie(Cnf)
-    projectB = Katie.projectB
+    Upload = queue.Upload(Cnf)
+    projectB = Upload.projectB
 
-    changes = Katie.pkg.changes
-    dsc = Katie.pkg.dsc
-    dsc_files = Katie.pkg.dsc_files
-    files = Katie.pkg.files
-    pkg = Katie.pkg
-    Subst = Katie.Subst
+    changes = Upload.pkg.changes
+    dsc = Upload.pkg.dsc
+    dsc_files = Upload.pkg.dsc_files
+    files = Upload.pkg.files
+    pkg = Upload.pkg
+    Subst = Upload.Subst
 
     return changes_files
 
 ###############################################################################
 
 def usage (exit_code=0):
-    print """Usage: kelly [OPTION]... [CHANGES]...
+    print """Usage: dak process-accepted [OPTION]... [CHANGES]...
   -a, --automatic           automatic run
   -h, --help                show this help and exit.
   -n, --no-action           don't do anything
@@ -205,7 +237,7 @@ def usage (exit_code=0):
 ###############################################################################
 
 def action ():
-    (summary, short_summary) = Katie.build_summaries()
+    (summary, short_summary) = Upload.build_summaries()
 
     (prompt, answer) = ("", "XXX")
     if Options["No-Action"] or Options["Automatic"]:
@@ -217,15 +249,15 @@ def action ():
         if Options["Automatic"]:
             answer = 'R'
     else:
-        print "INSTALL to " + ", ".join(changes["distribution"].keys()) 
-       print reject_message + summary,
+        print "INSTALL to " + ", ".join(changes["distribution"].keys())
+        print reject_message + summary,
         prompt = "[I]nstall, Skip, Quit ?"
         if Options["Automatic"]:
             answer = 'I'
 
     while prompt.find(answer) == -1:
         answer = utils.our_raw_input(prompt)
-        m = katie.re_default_answer.match(prompt)
+        m = queue.re_default_answer.match(prompt)
         if answer == "":
             answer = m.group(1)
         answer = answer[:1].upper()
@@ -251,7 +283,7 @@ def do_reject ():
     Subst["__REJECTOR_ADDRESS__"] = Cnf["Dinstall::MyEmailAddress"]
     Subst["__REJECT_MESSAGE__"] = reject_message
     Subst["__CC__"] = "Cc: " + Cnf["Dinstall::MyEmailAddress"]
-    reject_mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/kelly.unaccept")
+    reject_mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-accepted.unaccept")
 
     # Write the rejection email out as the <foo>.reason file
     reason_filename = os.path.basename(pkg.changes_file[:-8]) + ".reason"
@@ -279,6 +311,14 @@ def install ():
     # Begin a transaction; if we bomb out anywhere between here and the COMMIT WORK below, the DB will not be changed.
     projectB.query("BEGIN WORK")
 
+    # Ensure that we have all the hashes we need below.
+    rejmsg = utils.ensure_hashes(changes, dsc, files, dsc_files)
+    if len(rejmsg) > 0:
+        # There were errors.  Print them and SKIP the changes.
+        for msg in rejmsg:
+            utils.warn(msg)
+        return
+
     # Add the .dsc file to the DB
     for file in files.keys():
         if files[file]["type"] == "dsc":
@@ -286,19 +326,26 @@ def install ():
             version = dsc["version"]  # NB: not files[file]["version"], that has no epoch
             maintainer = dsc["maintainer"]
             maintainer = maintainer.replace("'", "\\'")
-            maintainer_id = db_access.get_or_set_maintainer_id(maintainer)
-            fingerprint_id = db_access.get_or_set_fingerprint_id(dsc["fingerprint"])
+            maintainer_id = database.get_or_set_maintainer_id(maintainer)
+            changedby = changes["changed-by"]
+            changedby = changedby.replace("'", "\\'")
+            changedby_id = database.get_or_set_maintainer_id(changedby)
+            fingerprint_id = database.get_or_set_fingerprint_id(dsc["fingerprint"])
             install_date = time.strftime("%Y-%m-%d")
             filename = files[file]["pool name"] + file
             dsc_component = files[file]["component"]
             dsc_location_id = files[file]["location id"]
+            if dsc.has_key("dm-upload-allowed") and  dsc["dm-upload-allowed"] == "yes":
+                dm_upload_allowed = "true"
+            else:
+                dm_upload_allowed = "false"
             if not files[file].has_key("files id") or not files[file]["files id"]:
-                files[file]["files id"] = db_access.set_files_id (filename, files[file]["size"], files[file]["md5sum"], dsc_location_id)
-            projectB.query("INSERT INTO source (source, version, maintainer, file, install_date, sig_fpr) VALUES ('%s', '%s', %d, %d, '%s', %s)"
-                           % (package, version, maintainer_id, files[file]["files id"], install_date, fingerprint_id))
+                files[file]["files id"] = database.set_files_id (filename, files[file]["size"], files[file]["md5sum"], files[file]["sha1sum"], files[file]["sha256sum"], dsc_location_id)
+            projectB.query("INSERT INTO source (source, version, maintainer, changedby, file, install_date, sig_fpr, dm_upload_allowed) VALUES ('%s', '%s', %d, %d, %d, '%s', %s, %s)"
+                           % (package, version, maintainer_id, changedby_id, files[file]["files id"], install_date, fingerprint_id, dm_upload_allowed))
 
             for suite in changes["distribution"].keys():
-                suite_id = db_access.get_suite_id(suite)
+                suite_id = database.get_suite_id(suite)
                 projectB.query("INSERT INTO src_associations (suite, source) VALUES (%d, currval('source_id_seq'))" % (suite_id))
 
             # Add the source files to the DB (files and dsc_files)
@@ -309,12 +356,29 @@ def install ():
                 # files id is stored in dsc_files by check_dsc().
                 files_id = dsc_files[dsc_file].get("files id", None)
                 if files_id == None:
-                    files_id = db_access.get_files_id(filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], dsc_location_id)
+                    files_id = database.get_files_id(filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], dsc_location_id)
                 # FIXME: needs to check for -1/-2 and or handle exception
                 if files_id == None:
-                    files_id = db_access.set_files_id (filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], dsc_location_id)
+                    files_id = database.set_files_id (filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], files[dsc_file]["sha1sum"], files[dsc_file]["sha256sum"], dsc_location_id)
                 projectB.query("INSERT INTO dsc_files (source, file) VALUES (currval('source_id_seq'), %d)" % (files_id))
 
+            # Add the src_uploaders to the DB
+            uploader_ids = [maintainer_id]
+            if dsc.has_key("uploaders"):
+                for u in dsc["uploaders"].split(","):
+                    u = u.replace("'", "\\'")
+                    u = u.strip()
+                    uploader_ids.append(
+                        database.get_or_set_maintainer_id(u))
+            added_ids = {}
+            for u in uploader_ids:
+                if added_ids.has_key(u):
+                    utils.warn("Already saw uploader %s for source %s" % (u, package))
+                    continue
+                added_ids[u]=1
+                projectB.query("INSERT INTO src_uploaders (source, maintainer) VALUES (currval('source_id_seq'), %d)" % (u))
+
+
     # Add the .deb files to the DB
     for file in files.keys():
         if files[file]["type"] == "deb":
@@ -322,35 +386,41 @@ def install ():
             version = files[file]["version"]
             maintainer = files[file]["maintainer"]
             maintainer = maintainer.replace("'", "\\'")
-            maintainer_id = db_access.get_or_set_maintainer_id(maintainer)
-            fingerprint_id = db_access.get_or_set_fingerprint_id(changes["fingerprint"])
+            maintainer_id = database.get_or_set_maintainer_id(maintainer)
+            fingerprint_id = database.get_or_set_fingerprint_id(changes["fingerprint"])
             architecture = files[file]["architecture"]
-            architecture_id = db_access.get_architecture_id (architecture)
+            architecture_id = database.get_architecture_id (architecture)
             type = files[file]["dbtype"]
             source = files[file]["source package"]
             source_version = files[file]["source version"]
             filename = files[file]["pool name"] + file
-           if not files[file].has_key("location id") or not files[file]["location id"]:
-               files[file]["location id"] = db_access.get_location_id(Cnf["Dir::Pool"],files[file]["component"],utils.where_am_i())
+            contents = generate_contents_information(file)
+            if not files[file].has_key("location id") or not files[file]["location id"]:
+                files[file]["location id"] = database.get_location_id(Cnf["Dir::Pool"],files[file]["component"],utils.where_am_i())
             if not files[file].has_key("files id") or not files[file]["files id"]:
-                files[file]["files id"] = db_access.set_files_id (filename, files[file]["size"], files[file]["md5sum"], files[file]["location id"])
-            source_id = db_access.get_source_id (source, source_version)
+                files[file]["files id"] = database.set_files_id (filename, files[file]["size"], files[file]["md5sum"], files[file]["sha1sum"], files[file]["sha256sum"], files[file]["location id"])
+            source_id = database.get_source_id (source, source_version)
             if source_id:
                 projectB.query("INSERT INTO binaries (package, version, maintainer, source, architecture, file, type, sig_fpr) VALUES ('%s', '%s', %d, %d, %d, %d, '%s', %d)"
                                % (package, version, maintainer_id, source_id, architecture_id, files[file]["files id"], type, fingerprint_id))
             else:
-                projectB.query("INSERT INTO binaries (package, version, maintainer, architecture, file, type, sig_fpr) VALUES ('%s', '%s', %d, %d, %d, '%s', %d)"
-                               % (package, version, maintainer_id, architecture_id, files[file]["files id"], type, fingerprint_id))
+                raise NoSourceFieldError, "Unable to find a source id for %s (%s), %s, file %s, type %s, signed by %s" % (package, version, architecture, file, type, sig_fpr)
             for suite in changes["distribution"].keys():
-                suite_id = db_access.get_suite_id(suite)
+                suite_id = database.get_suite_id(suite)
                 projectB.query("INSERT INTO bin_associations (suite, bin) VALUES (%d, currval('binaries_id_seq'))" % (suite_id))
 
+            # insert contents into the database
+            q = projectB.query("SELECT currval('binaries_id_seq')")
+            bin_id = int(q.getresult()[0][0])
+            for file in contents:
+                database.insert_content_path(bin_id, file)
+
     # If the .orig.tar.gz is in a legacy directory we need to poolify
     # it, so that apt-get source (and anything else that goes by the
     # "Directory:" field in the Sources.gz file) works.
-    orig_tar_id = Katie.pkg.orig_tar_id
-    orig_tar_location = Katie.pkg.orig_tar_location
-    legacy_source_untouchable = Katie.pkg.legacy_source_untouchable
+    orig_tar_id = Upload.pkg.orig_tar_id
+    orig_tar_location = Upload.pkg.orig_tar_location
+    legacy_source_untouchable = Upload.pkg.legacy_source_untouchable
     if orig_tar_id and orig_tar_location == "legacy":
         q = projectB.query("SELECT DISTINCT ON (f.id) l.path, f.filename, f.id as files_id, df.source, df.id as dsc_files_id, f.size, f.md5sum FROM files f, dsc_files df, location l WHERE df.source IN (SELECT source FROM dsc_files WHERE file = %s) AND f.id = df.file AND l.id = f.location AND (l.type = 'legacy' OR l.type = 'legacy-mixed')" % (orig_tar_id))
         qd = q.dictresult()
@@ -373,17 +443,19 @@ def install ():
     #
     if changes["architecture"].has_key("source") and orig_tar_id and \
        orig_tar_location != "legacy" and orig_tar_location != dsc_location_id:
-        q = projectB.query("SELECT l.path, f.filename, f.size, f.md5sum FROM files f, location l WHERE f.id = %s AND f.location = l.id" % (orig_tar_id))
+        q = projectB.query("SELECT l.path, f.filename, f.size, f.md5sum, f.sha1sum, f.sha256sum FROM files f, location l WHERE f.id = %s AND f.location = l.id" % (orig_tar_id))
         ql = q.getresult()[0]
         old_filename = ql[0] + ql[1]
         file_size = ql[2]
         file_md5sum = ql[3]
+        file_sha1sum = ql[4]
+        file_sha256sum = ql[5]
         new_filename = utils.poolify(changes["source"], dsc_component) + os.path.basename(old_filename)
-        new_files_id = db_access.get_files_id(new_filename, file_size, file_md5sum, dsc_location_id)
+        new_files_id = database.get_files_id(new_filename, file_size, file_md5sum, dsc_location_id)
         if new_files_id == None:
             utils.copy(old_filename, Cnf["Dir::Pool"] + new_filename)
-            new_files_id = db_access.set_files_id(new_filename, file_size, file_md5sum, dsc_location_id)
-            projectB.query("UPDATE dsc_files SET file = %s WHERE source = %s AND file = %s" % (new_files_id, source_id, orig_tar_id))
+            new_files_id = database.set_files_id(new_filename, file_size, file_md5sum, file_sha1sum, file_sha256sum, dsc_location_id)
+            projectB.query("UPDATE dsc_files SET file = %s WHERE source = %s AND file = %s" % (new_files_id, database.get_source_id(changes["source"], changes["version"]), orig_tar_id))
 
     # Install the files into the pool
     for file in files.keys():
@@ -394,38 +466,37 @@ def install ():
 
     # Copy the .changes file across for suite which need it.
     copy_changes = {}
-    copy_katie = {}
+    copy_dot_dak = {}
     for suite in changes["distribution"].keys():
         if Cnf.has_key("Suite::%s::CopyChanges" % (suite)):
             copy_changes[Cnf["Suite::%s::CopyChanges" % (suite)]] = ""
-        # and the .katie file...
-        if Cnf.has_key("Suite::%s::CopyKatie" % (suite)):
-            copy_katie[Cnf["Suite::%s::CopyKatie" % (suite)]] = ""
+        # and the .dak file...
+        if Cnf.has_key("Suite::%s::CopyDotDak" % (suite)):
+            copy_dot_dak[Cnf["Suite::%s::CopyDotDak" % (suite)]] = ""
     for dest in copy_changes.keys():
         utils.copy(pkg.changes_file, Cnf["Dir::Root"] + dest)
-    for dest in copy_katie.keys():
-        utils.copy(Katie.pkg.changes_file[:-8]+".katie", dest)
-
+    for dest in copy_dot_dak.keys():
+        utils.copy(Upload.pkg.changes_file[:-8]+".dak", dest)
     projectB.query("COMMIT WORK")
 
     # Move the .changes into the 'done' directory
     utils.move (pkg.changes_file,
                 os.path.join(Cnf["Dir::Queue::Done"], os.path.basename(pkg.changes_file)))
 
-    # Remove the .katie file
-    os.unlink(Katie.pkg.changes_file[:-8]+".katie")
+    # Remove the .dak file
+    os.unlink(Upload.pkg.changes_file[:-8]+".dak")
 
     if changes["architecture"].has_key("source") and Urgency_Logger:
         Urgency_Logger.log(dsc["source"], dsc["version"], changes["urgency"])
 
-    # Undo the work done in katie.py(accept) to help auto-building
+    # Undo the work done in queue.py(accept) to help auto-building
     # from accepted.
     projectB.query("BEGIN WORK")
     for suite in changes["distribution"].keys():
         if suite not in Cnf.ValueList("Dinstall::QueueBuildSuites"):
             continue
         now_date = time.strftime("%Y-%m-%d %H:%M")
-        suite_id = db_access.get_suite_id(suite)
+        suite_id = database.get_suite_id(suite)
         dest_dir = Cnf["Dir::QueueBuild"]
         if Cnf.FindB("Dinstall::SecurityQueueBuild"):
             dest_dir = os.path.join(dest_dir, suite)
@@ -474,46 +545,31 @@ def stable_install (summary, short_summary):
             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')
+            suite_id = database.get_suite_id('proposed-updates')
             projectB.query("DELETE FROM src_associations WHERE suite = '%s' AND source = '%s'" % (suite_id, source_id))
-            suite_id = db_access.get_suite_id('stable')
+            suite_id = database.get_suite_id('stable')
             projectB.query("INSERT INTO src_associations (suite, source) VALUES ('%s', '%s')" % (suite_id, source_id))
 
     # Add the binaries to stable (and remove it/them from proposed-updates)
     for file in files.keys():
         if files[file]["type"] == "deb":
-           binNMU = 0
             package = files[file]["package"]
             version = files[file]["version"]
             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 not ql:
-               suite_id = db_access.get_suite_id('proposed-updates')
-               que = "SELECT b.version FROM binaries b JOIN bin_associations ba ON (b.id = ba.bin) JOIN suite su ON (ba.suite = su.id) WHERE b.package = '%s' AND (ba.suite = '%s')" % (package, suite_id)
-               q = projectB.query(que)
-
-               # Reduce the query results to a list of version numbers
-               ql = map(lambda x: x[0], q.getresult())
-               if not ql:
-                   utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s for %s architecture) in binaries table." % (package, version, architecture))
-               else:
-                   for x in ql:
-                       if re.match(re.compile(r"%s((\.0)?\.)|(\+b)\d+$" % re.escape(version)),x):
-                           binNMU = 1
-                           break
-           if not binNMU:
-               binary_id = ql[0][0]
-               suite_id = db_access.get_suite_id('proposed-updates')
-               projectB.query("DELETE FROM bin_associations WHERE suite = '%s' AND bin = '%s'" % (suite_id, binary_id))
-               suite_id = db_access.get_suite_id('stable')
-               projectB.query("INSERT INTO bin_associations (suite, bin) VALUES ('%s', '%s')" % (suite_id, binary_id))
-           else:
-                del files[file]
+                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 = database.get_suite_id('proposed-updates')
+            projectB.query("DELETE FROM bin_associations WHERE suite = '%s' AND bin = '%s'" % (suite_id, binary_id))
+            suite_id = database.get_suite_id('stable')
+            projectB.query("INSERT INTO bin_associations (suite, bin) VALUES ('%s', '%s')" % (suite_id, binary_id))
 
     projectB.query("COMMIT WORK")
 
-    utils.move (pkg.changes_file, Cnf["Dir::Morgue"] + '/katie/' + os.path.basename(pkg.changes_file))
+    utils.move (pkg.changes_file, Cnf["Dir::Morgue"] + '/process-accepted/' + os.path.basename(pkg.changes_file))
 
     ## Update the Stable ChangeLog file
     new_changelog_filename = Cnf["Dir::Root"] + Cnf["Suite::Stable::ChangeLogBase"] + ".ChangeLog"
@@ -529,7 +585,7 @@ def stable_install (summary, short_summary):
             new_changelog.write("stable/%s/source/%s\n" % (files[file]["component"], file))
         else:
             new_changelog.write("%s\n" % (file))
-    chop_changes = katie.re_fdnic.sub("\n", changes["changes"])
+    chop_changes = queue.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)
@@ -544,13 +600,13 @@ def stable_install (summary, short_summary):
     if not Options["No-Mail"] and changes["architecture"].has_key("source"):
         Subst["__SUITE__"] = " into stable"
         Subst["__SUMMARY__"] = summary
-        mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/kelly.installed")
+        mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-accepted.install")
         utils.send_mail(mail_message)
-        Katie.announce(short_summary, 1)
+        Upload.announce(short_summary, 1)
 
-    # Finally remove the .katie file
-    katie_file = os.path.join(Cnf["Suite::Proposed-Updates::CopyKatie"], os.path.basename(Katie.pkg.changes_file[:-8]+".katie"))
-    os.unlink(katie_file)
+    # Finally remove the .dak file
+    dot_dak_file = os.path.join(Cnf["Suite::Proposed-Updates::CopyDotDak"], os.path.basename(Upload.pkg.changes_file[:-8]+".dak"))
+    os.unlink(dot_dak_file)
 
 ################################################################################
 
@@ -568,16 +624,16 @@ def process_it (changes_file):
     pkg.directory = os.getcwd()
 
     if installing_to_stable:
-        old = Katie.pkg.changes_file
-        Katie.pkg.changes_file = os.path.basename(old)
-        os.chdir(Cnf["Suite::Proposed-Updates::CopyKatie"])
+        old = Upload.pkg.changes_file
+        Upload.pkg.changes_file = os.path.basename(old)
+        os.chdir(Cnf["Suite::Proposed-Updates::CopyDotDak"])
 
-    Katie.init_vars()
-    Katie.update_vars()
-    Katie.update_subst()
+    Upload.init_vars()
+    Upload.update_vars()
+    Upload.update_subst()
 
     if installing_to_stable:
-        Katie.pkg.changes_file = old
+        Upload.pkg.changes_file = old
 
     check()
     action()
@@ -612,15 +668,15 @@ def main():
             fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
         except IOError, e:
             if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EAGAIN':
-                utils.fubar("Couldn't obtain lock; assuming another kelly is already running.")
+                utils.fubar("Couldn't obtain lock; assuming another 'dak process-accepted' is already running.")
             else:
                 raise
-        Logger = Katie.Logger = logging.Logger(Cnf, "kelly")
+        Logger = Upload.Logger = logging.Logger(Cnf, "process-accepted")
         if not installing_to_stable and Cnf.get("Dir::UrgencyLog"):
             Urgency_Logger = Urgency_Log(Cnf)
 
     # Initialize the substitution template mapping global
-    bcc = "X-Katie: %s" % (kelly_version)
+    bcc = "X-DAK: dak process-accepted\nX-Katie: $Revision: 1.18 $"
     if Cnf.has_key("Dinstall::Bcc"):
         Subst["__BCC__"] = bcc + "\nBcc: %s" % (Cnf["Dinstall::Bcc"])
     else: