]> git.decadent.org.uk Git - dak.git/blobdiff - dak/import_archive.py
various
[dak.git] / dak / import_archive.py
index 13343c2f5aa93954c94d091dad425e5afca881ef..53635e2acac63b7f086cb4b5b208f138ef0acd56 100755 (executable)
@@ -38,8 +38,9 @@
 
 import commands, os, pg, re, sys, time
 import apt_pkg
-import dak.lib.database as database
-import dak.lib.utils as utils
+from daklib import database
+from daklib import utils
+from daklib.dak_exceptions import *
 
 ###############################################################################
 
@@ -98,8 +99,8 @@ def check_signature (filename):
         return None
 
     status_read, status_write = os.pipe()
-    cmd = "gpgv --status-fd %s --keyring %s --keyring %s %s" \
-          % (status_write, Cnf["Dinstall::PGPKeyring"], Cnf["Dinstall::GPGKeyring"], filename)
+    cmd = "gpgv --status-fd %s %s %s" \
+          % (status_write, utils.gpg_keyring_args(), filename)
     (output, status, exit_status) = utils.gpgv_get_status_output(cmd, status_read, status_write)
 
     # Process the status-fd output
@@ -280,7 +281,6 @@ def update_section():
                 prefix = ""
         else:
             prefix = ""
-            component = component.replace("non-US/", "")
             if component != 'main':
                 suffix = '/' + component
             else:
@@ -307,7 +307,7 @@ def get_location_path(directory):
 def get_or_set_files_id (filename, size, md5sum, location_id):
     global files_id_cache, files_id_serial, files_query_cache
 
-    cache_key = "~".join((filename, size, md5sum, repr(location_id)))
+    cache_key = "_".join((filename, size, md5sum, repr(location_id)))
     if not files_id_cache.has_key(cache_key):
         files_id_serial += 1
         files_query_cache.write("%d\t%s\t%s\t%s\t%d\t\\N\n" % (files_id_serial, filename, size, md5sum, location_id))
@@ -324,7 +324,7 @@ def process_sources (filename, suite, component, archive):
     suite_id = database.get_suite_id(suite)
     try:
         file = utils.open_file (filename)
-    except utils.cant_open_exc:
+    except CantOpenError:
         utils.warn("can't open '%s'" % (filename))
         return
     Scanner = apt_pkg.ParseTagFile(file)
@@ -363,7 +363,7 @@ def process_sources (filename, suite, component, archive):
             (md5sum, size, filename) = line.strip().split()
             # Don't duplicate .orig.tar.gz's
             if filename.endswith(".orig.tar.gz"):
-                cache_key = "%s~%s~%s" % (filename, size, md5sum)
+                cache_key = "%s_%s_%s" % (filename, size, md5sum)
                 if orig_tar_gz_cache.has_key(cache_key):
                     id = orig_tar_gz_cache[cache_key]
                 else:
@@ -376,9 +376,9 @@ def process_sources (filename, suite, component, archive):
             if filename.endswith(".dsc"):
                 files_id = id
         filename = directory + package + '_' + no_epoch_version + '.dsc'
-        cache_key = "%s~%s" % (package, version)
+        cache_key = "%s_%s" % (package, version)
         if not source_cache.has_key(cache_key):
-            nasty_key = "%s~%s" % (package, version)
+            nasty_key = "%s_%s" % (package, version)
             source_id_serial += 1
             if not source_cache_for_binaries.has_key(nasty_key):
                 source_cache_for_binaries[nasty_key] = source_id_serial
@@ -407,7 +407,7 @@ def process_packages (filename, suite, component, archive):
     suite_id = database.get_suite_id(suite)
     try:
         file = utils.open_file (filename)
-    except utils.cant_open_exc:
+    except CantOpenError:
         utils.warn("can't open '%s'" % (filename))
         return
     Scanner = apt_pkg.ParseTagFile(file)
@@ -433,21 +433,24 @@ def process_packages (filename, suite, component, archive):
         if not source_version:
             source_version = version
         filename = Scanner.Section["filename"]
+        if filename.endswith(".deb"):
+            type = "deb"
+        else:
+            type = "udeb"
         location = get_location_path(filename.split('/')[0])
-        location_id = database.get_location_id (location, component, archive)
+        location_id = database.get_location_id (location, component.replace("/debian-installer", ""), archive)
         filename = poolify (filename, location)
         if architecture == "all":
             filename = re_arch_from_filename.sub("binary-all", filename)
-        cache_key = "%s~%s" % (source, source_version)
+        cache_key = "%s_%s" % (source, source_version)
         source_id = source_cache_for_binaries.get(cache_key, None)
         size = Scanner.Section["size"]
         md5sum = Scanner.Section["md5sum"]
         files_id = get_or_set_files_id (filename, size, md5sum, location_id)
-        type = "deb"; # FIXME
-        cache_key = "%s~%s~%s~%d~%d~%d~%d" % (package, version, repr(source_id), architecture_id, location_id, files_id, suite_id)
+        cache_key = "%s_%s_%s_%d_%d_%d_%d" % (package, version, repr(source_id), architecture_id, location_id, files_id, suite_id)
         if not arch_all_cache.has_key(cache_key):
             arch_all_cache[cache_key] = 1
-            cache_key = "%s~%s~%s~%d" % (package, version, repr(source_id), architecture_id)
+            cache_key = "%s_%s_%s_%d" % (package, version, repr(source_id), architecture_id)
             if not binary_cache.has_key(cache_key):
                 if not source_id:
                     source_id = "\N"
@@ -474,7 +477,7 @@ def process_packages (filename, suite, component, archive):
 ###############################################################################
 
 def do_sources(sources, suite, component, server):
-    temp_filename = utils.temp_filename()
+    (fd, temp_filename) = utils.temp_filename()
     (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (sources, temp_filename))
     if (result != 0):
         utils.fubar("Gunzip invocation failed!\n%s" % (output), result)
@@ -491,14 +494,14 @@ def do_da_do_da ():
     Arguments = [('a', "action", "Import-Archive::Options::Action"),
                  ('h', "help", "Import-Archive::Options::Help")]
     for i in [ "action", "help" ]:
-       if not Cnf.has_key("Import-Archive::Options::%s" % (i)):
-           Cnf["Import-Archive::Options::%s" % (i)] = ""
+        if not Cnf.has_key("Import-Archive::Options::%s" % (i)):
+            Cnf["Import-Archive::Options::%s" % (i)] = ""
 
     apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv)
 
     Options = Cnf.SubTree("Import-Archive::Options")
     if Options["Help"]:
-       usage()
+        usage()
 
     if not Options["Action"]:
         utils.warn("""no -a/--action given; not doing anything.
@@ -566,7 +569,9 @@ Please read the documentation before running this script.
             process_packages (packages, suite, "", server)
         elif type == "legacy" or type == "pool":
             for suite in Cnf.ValueList("Location::%s::Suites" % (location)):
-                for component in Cnf.SubTree("Component").List():
+                udeb_components = map(lambda x: x+"/debian-installer",
+                                      Cnf.ValueList("Suite::%s::UdebComponents" % suite))
+                for component in Cnf.SubTree("Component").List() + udeb_components:
                     architectures = filter(utils.real_arch,
                                            Cnf.ValueList("Suite::%s::Architectures" % (suite)))
                     for architecture in architectures: