]> git.decadent.org.uk Git - dak.git/blobdiff - dak/process_accepted.py
Merge branch 'master' into content_generation, make changes based on Joerg's review
[dak.git] / dak / process_accepted.py
index a25c391fc374f9d286d8e515ecf74adfa64e9684..cc3f7eabdfe170ef1f4f7b19085144ac6d8ae2ed 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-# Installs Debian packages from queue/accepted into the pool
+""" Installs Debian packages from queue/accepted into the pool """
 # 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
 
 ###############################################################################
 
-import errno, fcntl, os, sys, time, re
-import apt_pkg
+import errno
+import fcntl
+import os
+import sys
+import time
+import re
+import apt_pkg, commands
 from daklib import database
 from daklib import logging
 from daklib import queue
 from daklib import utils
 from daklib.dak_exceptions import *
+from daklib.regexes import re_default_answer, re_issource, re_fdnic
 
 ###############################################################################
 
@@ -96,8 +102,10 @@ class Urgency_Log:
         else:
             os.unlink(self.log_filename)
 
+
 ###############################################################################
 
+
 def reject (str, prefix="Rejected: "):
     global reject_message
     if str:
@@ -220,7 +228,7 @@ def action ():
 
     while prompt.find(answer) == -1:
         answer = utils.our_raw_input(prompt)
-        m = queue.re_default_answer.match(prompt)
+        m = re_default_answer.match(prompt)
         if answer == "":
             answer = m.group(1)
         answer = answer[:1].upper()
@@ -371,34 +379,15 @@ def install ():
                 suite_id = database.get_suite_id(suite)
                 projectB.query("INSERT INTO bin_associations (suite, bin) VALUES (%d, currval('binaries_id_seq'))" % (suite_id))
 
-    # 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 = 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()
-        for qid in qd:
-            # Is this an old upload superseded by a newer -sa upload?  (See check_dsc() for details)
-            if legacy_source_untouchable.has_key(qid["files_id"]):
-                continue
-            # First move the files to the new location
-            legacy_filename = qid["path"] + qid["filename"]
-            pool_location = utils.poolify (changes["source"], files[newfile]["component"])
-            pool_filename = pool_location + os.path.basename(qid["filename"])
-            destination = Cnf["Dir::Pool"] + pool_location
-            utils.move(legacy_filename, destination)
-            # Then Update the DB's files table
-            q = projectB.query("UPDATE files SET filename = '%s', location = '%s' WHERE id = '%s'" % (pool_filename, dsc_location_id, qid["files_id"]))
-
-    # If this is a sourceful diff only upload that is moving non-legacy
+            if not database.copy_temporary_contents(package, version, files[newfile]):
+                reject("Missing contents for package")
+
+    # If this is a sourceful diff only upload that is moving
     # cross-component we need to copy the .orig.tar.gz into the new
     # component too for the same reasons as above.
     #
     if changes["architecture"].has_key("source") and orig_tar_id and \
-       orig_tar_location != "legacy" and orig_tar_location != dsc_location_id:
+       orig_tar_location != dsc_location_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]
@@ -433,7 +422,6 @@ def install ():
         utils.copy(pkg.changes_file, Cnf["Dir::Root"] + 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
@@ -538,11 +526,11 @@ def stable_install (summary, short_summary):
     for newfile in files.keys():
         if files[newfile]["type"] == "deb":
             new_changelog.write("stable/%s/binary-%s/%s\n" % (files[newfile]["component"], files[newfile]["architecture"], newfile))
-        elif utils.re_issource.match(newfile):
+        elif re_issource.match(newfile):
             new_changelog.write("stable/%s/source/%s\n" % (files[newfile]["component"], newfile))
         else:
             new_changelog.write("%s\n" % (newfile))
-    chop_changes = queue.re_fdnic.sub("\n", changes["changes"])
+    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)