]> git.decadent.org.uk Git - dak.git/blobdiff - neve
2.2r5 and multiple signatures in Release.gpg
[dak.git] / neve
diff --git a/neve b/neve
index bb8b5f8cee1c25c1e71dc0f16e101e62e018985c..4b9b624967b8f9a5c0e64aaad8809635fe77e9a0 100755 (executable)
--- a/neve
+++ b/neve
@@ -1,8 +1,8 @@
 #!/usr/bin/env python
 
 # Populate the DB
-# Copyright (C) 2000  James Troup <james@nocrew.org>
-# $Id: neve,v 1.1.1.1 2000-11-24 00:20:09 troup Exp $
+# Copyright (C) 2000, 2001  James Troup <james@nocrew.org>
+# $Id: neve,v 1.7 2001-11-18 19:57:58 rmurray Exp $
 
 # 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
@@ -117,8 +117,10 @@ def update_suites ():
     projectB.query("DELETE FROM suite")
     for suite in Cnf.SubTree("Suite").List():
         SubSec = Cnf.SubTree("Suite::%s" %(suite))
-        projectB.query("INSERT INTO suite (suite_name, version, origin, description) VALUES ('%s', '%s', '%s', '%s')"
-                       % (string.lower(suite), SubSec["Version"], SubSec["Origin"], SubSec["Description"]))
+        projectB.query("INSERT INTO suite (suite_name) VALUES ('%s')" % string.lower(suite));
+        for i in ("Version", "Origin", "Description"):
+            if SubSec.has_key(i):
+                projectB.query("UPDATE suite SET %s = '%s' WHERE suite_name = '%s'" % (string.lower(i), SubSec[i], string.lower(suite)))
         for architecture in Cnf.SubTree("Suite::%s::Architectures" % (suite)).List():
             architecture_id = db_access.get_architecture_id (architecture);
             projectB.query("INSERT INTO suite_architectures (suite, architecture) VALUES (currval('suite_id_seq'), %d)" % (architecture_id));
@@ -133,7 +135,7 @@ def get_or_set_files_id (filename, size, md5sum, location_id):
         files_id_serial = files_id_serial + 1
         files_query_cache.write("%d\t%s\t%s\t%s\t%d\n" % (files_id_serial, filename, size, md5sum, location_id));
         files_id_cache[cache_key] = files_id_serial
-        
+
     return files_id_cache[cache_key]
 
 ##############################################################################################################
@@ -146,7 +148,7 @@ def process_sources (location, filename, suite, component, archive):
     if suite == 'stable':
         testing_id = db_access.get_suite_id("testing");
     try:
-        file = utils.open_file (filename, "r")
+        file = utils.open_file (filename);
     except utils.cant_open_exc:
         print "WARNING: can't open '%s'" % (filename);
         return;
@@ -199,7 +201,7 @@ def process_sources (location, filename, suite, component, archive):
                 dsc_files_query_cache.write("%d\t%d\t%d\n" % (dsc_files_id_serial, tmp_source_id,id));
         else:
             tmp_source_id = source_cache[cache_key];
-            
+
         src_associations_id_serial = src_associations_id_serial + 1;
         src_associations_query_cache.write("%d\t%d\t%d\n" % (src_associations_id_serial, suite_id, tmp_source_id))
         # populate 'testing' with a mirror of 'stable'
@@ -213,7 +215,7 @@ def process_sources (location, filename, suite, component, archive):
 
 def process_packages (location, filename, suite, component, archive):
     global arch_all_cache, binary_cache, binaries_id_serial, binaries_query_cache, bin_associations_id_serial, bin_associations_query_cache;
-    
+
     count_total = 0;
     count_bad = 0;
     suite = string.lower(suite);
@@ -221,7 +223,7 @@ def process_packages (location, filename, suite, component, archive):
     if suite == "stable":
         testing_id = db_access.get_suite_id("testing");
     try:
-        file = utils.open_file (filename, "r")
+        file = utils.open_file (filename);
     except utils.cant_open_exc:
         print "WARNING: can't open '%s'" % (filename);
         return;
@@ -272,7 +274,7 @@ def process_packages (location, filename, suite, component, archive):
                 tmp_binaries_id = binaries_id_serial;
             else:
                 tmp_binaries_id = binary_cache[cache_key];
-            
+
             bin_associations_id_serial = bin_associations_id_serial + 1;
             bin_associations_query_cache.write("%d\t%d\t%d\n" % (bin_associations_id_serial, suite_id, tmp_binaries_id));
             if suite == "stable":
@@ -295,8 +297,7 @@ def do_sources(location, prefix, suite, component, server):
     sources = location + prefix + 'Sources.gz';
     (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (sources, temp_filename));
     if (result != 0):
-        sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output));
-        sys.exit(result);
+        utils.fubar("Gunzip invocation failed!\n%s" % (output), result);
     print 'Processing '+sources+'...';
     process_sources (location, temp_filename, suite, component, server);
     os.unlink(temp_filename);
@@ -306,19 +307,16 @@ def do_sources(location, prefix, suite, component, server):
 def main ():
     global Cnf, projectB, query_cache, files_query_cache, source_query_cache, src_associations_query_cache, dsc_files_query_cache, bin_associations_query_cache, binaries_query_cache;
 
-    apt_pkg.init();
-    
-    Cnf = apt_pkg.newConfiguration();
-    apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
+    Cnf = utils.get_conf()
 
     print "Re-Creating DB..."
     (result, output) = commands.getstatusoutput("psql -f init_pool.sql")
     if (result != 0):
-        sys.exit(2)
+        utils.fubar("psql invocation failed!\n", result);
     print output
 
-    projectB = pg.connect('projectb', 'localhost', -1, None, None, 'postgres')
-      
+    projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]), None, None, 'postgres')
+
     db_access.init (Cnf, projectB);
 
     print "Adding static tables from conf file..."
@@ -358,9 +356,8 @@ def main ():
 #                prefix = component + '/'
 #                do_sources(location, prefix);
         else:
-            sys.stderr.write("Unknown location type ('%s').\n" % (type));
-            sys.exit(2);
-    
+            utils.fubar("Unknown location type ('%s')." % (type));
+
     # Process Packages files to populate `binaries' and friends
 
     for location in Cnf.SubTree("Location").List():
@@ -383,7 +380,7 @@ def main ():
                         process_packages (location, packages, suite, component, server);
         elif type == "pool":
             continue;
-            
+
     files_query_cache.close();
     source_query_cache.close();
     src_associations_query_cache.close();
@@ -412,10 +409,9 @@ def main ():
     (result, output) = commands.getstatusoutput("psql projectb < add_constraints.sql");
     print output
     if (result != 0):
-        sys.stderr.write("psql invocation failed!\n");
-        sys.exit(result);
-    
+        utils.fubar("psql invocation failed!\n%s" % (output), result);
+
     return;
-            
+
 if __name__ == '__main__':
     main()