]> err.no Git - dak/commitdiff
better cleanup of temporary files, consolidate some repeated code
authorMike O'Connor <stew@vireo.org>
Sun, 22 Feb 2009 14:55:49 +0000 (09:55 -0500)
committerMike O'Connor <stew@vireo.org>
Sun, 22 Feb 2009 14:55:49 +0000 (09:55 -0500)
Signed-off-by: Mike O'Connor <stew@vireo.org>
dak/contents.py
dak/dakdb/update6.py
dak/process_unchecked.py
daklib/binary.py
daklib/utils.py

index f423b197cd21523358c5691c881e46cbe0aaa94b..eb9e5c38ca429d6b79db655592f0b8ff6f3e2eaa 100644 (file)
@@ -308,18 +308,13 @@ class Contents(object):
 
             # The MORE fun part. Ok, udebs need their own contents files, udeb, and udeb-nf (not-free)
             # This is HORRIBLY debian specific :-/
-            # First off, udeb
-            section_id = DBConn().get_section_id('debian-installer') # all udebs should be here)
-            if section_id != -1:
-                cursor.execute("EXECUTE udeb_contents_q(%d,%d,%d)" % (section_id, suite_id, suite_id))
-                self._write_content_file(cursor, "dists/%s/Contents-udeb.gz" % suite)
-
-            # Once more, with non-free
-            section_id = DBConn().get_section_id('non-free/debian-installer') # all udebs should be here)
+            for section_id, fn_pattern in [("debian-installer","dists/%s/Contents-udeb.gz"),
+                                           ("non-free/debian-installer", "dists/%s/Contents-udeb-nf.gz")]
 
+            section_id = DBConn().get_section_id(section_id) # all udebs should be here)
             if section_id != -1:
                 cursor.execute("EXECUTE udeb_contents_q(%d,%d,%d)" % (section_id, suite_id, suite_id))
-                self._write_content_file(cursor, "dists/%s/Contents-udeb-nf.gz" % suite)
+                self._write_content_file(cursor, fn_pattern % suite)
 
 
 ################################################################################
index 514a4e871b4c4abaaa19b48f48e277e46bfbfb2f..d1781223283d41142dd80c7d27a13b45c89c63c7 100644 (file)
@@ -82,7 +82,7 @@ def do_update(self):
 
         c.execute( "CREATE INDEX content_assocaitions_binary ON content_associations(binary_pkg)" )
 
-        c.execute("UPDATE config SET value = '2' WHERE name = 'db_revision'")
+        c.execute("UPDATE config SET value = '6' WHERE name = 'db_revision'")
         self.db.commit()
 
         print "REMINDER: Remember to fully regenerate the Contents files before running import-contents"
index 26b2ae55612ff85306641d89d90268218cac9f90..aa2926a0c85be6a8f181e738ec57964589d9cc71 100755 (executable)
@@ -40,7 +40,8 @@ import time
 import tempfile
 import traceback
 import tarfile
-import apt_inst, apt_pkg
+import apt_inst
+import apt_pkg
 from debian_bundle import deb822
 from daklib.dbconn import DBConn
 from daklib.binary import Binary
index 70133db693e3f731f930187fe6039894f2b49b69..d83737547948da97c8632bd50ea36a861871ac35 100755 (executable)
@@ -30,6 +30,7 @@ import tempfile
 import tarfile
 import commands
 import traceback
+import atexit
 from debian_bundle import deb822
 from dbconn import DBConn
 
@@ -40,8 +41,17 @@ class Binary(object):
         self.chunks = None
 
     def __del__(self):
-        # we need to remove the temporary directory, if we created one
+        """
+        make sure we cleanup when we are garbage collected.
+        """
+        self.cleanup()
+
+    def _cleanup(self):
+        """
+        we need to remove the temporary directory, if we created one
+        """
         if self.tmpdir and os.path.exists(self.tmpdir):
+            self.tmpdir = None
             shutil.rmtree(self.tmpdir)
 
     def __scan_ar(self):
@@ -75,6 +85,7 @@ class Binary(object):
                     reject(utils.prefix_multi_line_string(output, " [ar output:] "), "")
                 else:
                     self.tmpdir = tmpdir
+                    atexit.register( self.cleanup )
 
             finally:
                 os.chdir( cwd )
@@ -123,8 +134,6 @@ class Binary(object):
                 os.chdir(self.tmpdir)
                 if self.chunks[1] == "control.tar.gz":
                     control = tarfile.open(os.path.join(self.tmpdir, "control.tar.gz" ), "r:gz")
-                elif self.chunks[1] == "control.tar.bz2":
-                    control = tarfile.open(os.path.join(self.tmpdir, "control.tar.bz2" ), "r:bz2")
 
                 pkg = deb822.Packages.iter_paragraphs( control.extractfile('./control') ).next()
 
index a45eceeade0c93c2119e60a28f43adf8077ee375..27c3af38e422e1c5658462e5a0ccc4197cff749b 100755 (executable)
@@ -1532,8 +1532,8 @@ def generate_contents_information(filename):
     """
     Generate a list of flies contained in a .deb
 
-    @type filename: string
-    @param filename: the path to a data.tar.gz or data.tar.bz2
+    @ptype filename: string
+    @param filename: the path to a .deb
 
     @rtype: list
     @return: a list of files in the data.tar.* portion of the .deb