]> git.decadent.org.uk Git - dak.git/commitdiff
Do no longer re-exec dak contents.
authorTorsten Werner <twerner@debian.org>
Tue, 22 Mar 2011 14:47:09 +0000 (14:47 +0000)
committerTorsten Werner <twerner@debian.org>
Tue, 22 Mar 2011 14:47:09 +0000 (14:47 +0000)
We just call DBConn().reset() in the child process now.

Signed-off-by: Torsten Werner <twerner@debian.org>
dak/contents.py
daklib/contents.py

index 5c33afa2f67f333e4ff1f3ee2b74e697338a4d5f..a8578ae32c51a4bfad7e2a4ced29df2bfe1134c6 100755 (executable)
@@ -82,21 +82,6 @@ def write_all(cnf, suite_names = [], force = None):
 
 ################################################################################
 
-def write_helper(suite_name, argv):
-    session = DBConn().session()
-    suite = get_suite(suite_name, session)
-    architecture = get_architecture(argv[0], session)
-    debtype = get_override_type(argv[1], session)
-    if len(argv) == 3:
-        component = get_component(argv[2], session)
-    else:
-        component = None
-    session.rollback()
-    ContentsWriter(suite, architecture, debtype, component).write_file()
-    session.close()
-
-################################################################################
-
 def scan_all(cnf, limit):
     Logger = daklog.Logger(cnf.Cnf, 'contents scan')
     result = ContentsScanner.scan_all(limit)
@@ -121,7 +106,7 @@ def main():
     args = apt_pkg.ParseCommandLine(cnf.Cnf, arguments, sys.argv)
     options = cnf.SubTree('Contents::Options')
 
-    if (len(args) < 1) or options['Help']:
+    if (len(args) != 1) or options['Help']:
         usage()
 
     limit = None
@@ -140,10 +125,6 @@ def main():
         write_all(cnf, suite_names, force)
         return
 
-    if args[0] == 'generate_helper':
-        write_helper(suite_names[0], args[1:])
-        return
-
     usage()
 
 
index 5bf94d9a252da7c7bdd5a6c10d70b408294b5dab..99d852b37970112edfae1b20bbceca858f4cdc54 100755 (executable)
@@ -32,7 +32,7 @@ from multiprocessing import Pool
 
 from sqlalchemy import desc, or_
 from sqlalchemy.exc import IntegrityError
-from subprocess import Popen, PIPE, call
+from subprocess import Popen, PIPE
 
 import os.path
 
@@ -208,24 +208,40 @@ select bc.file, string_agg(o.section || '/' || b.package, ',' order by b.package
             suite_query = suite_query.filter(Suite.suite_name.in_(suite_names))
         if not force:
             suite_query = suite_query.filter_by(untouchable = False)
+        deb_id = get_override_type('deb', session).overridetype_id
+        udeb_id = get_override_type('udeb', session).overridetype_id
+        main_id = get_component('main', session).component_id
+        non_free_id = get_component('non-free', session).component_id
         pool = Pool()
         for suite in suite_query:
+            suite_id = suite.suite_id
             for architecture in suite.get_architectures(skipsrc = True, skipall = True):
+                arch_id = architecture.arch_id
                 # handle 'deb' packages
-                command = ['dak', 'contents', '-s', suite.suite_name, \
-                    'generate_helper', architecture.arch_string, 'deb']
-                pool.apply_async(call, (command, ))
+                pool.apply_async(generate_helper, (suite_id, arch_id, deb_id))
                 # handle 'udeb' packages for 'main' and 'non-free'
-                command = ['dak', 'contents', '-s', suite.suite_name, \
-                    'generate_helper', architecture.arch_string, 'udeb', 'main']
-                pool.apply_async(call, (command, ))
-                command = ['dak', 'contents', '-s', suite.suite_name, \
-                    'generate_helper', architecture.arch_string, 'udeb', 'non-free']
-                pool.apply_async(call, (command, ))
+                pool.apply_async(generate_helper, (suite_id, arch_id, udeb_id, main_id))
+                pool.apply_async(generate_helper, (suite_id, arch_id, udeb_id, non_free_id))
         pool.close()
         pool.join()
         session.close()
 
+def generate_helper(suite_id, arch_id, overridetype_id, component_id = None):
+    '''
+    This function is called in a new subprocess.
+    '''
+    DBConn().reset()
+    session = DBConn().session()
+    suite = Suite.get(suite_id, session)
+    architecture = Architecture.get(arch_id, session)
+    overridetype = OverrideType.get(overridetype_id, session)
+    if component_id is None:
+        component = None
+    else:
+        component = Component.get(component_id, session)
+    contents_writer = ContentsWriter(suite, architecture, overridetype, component)
+    contents_writer.write_file()
+
 
 class ContentsScanner(object):
     '''