From: Torsten Werner Date: Tue, 22 Mar 2011 14:47:09 +0000 (+0000) Subject: Do no longer re-exec dak contents. X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=e45d89ab8cc899846042dc554d8fe7592869b302;p=dak.git Do no longer re-exec dak contents. We just call DBConn().reset() in the child process now. Signed-off-by: Torsten Werner --- diff --git a/dak/contents.py b/dak/contents.py index 5c33afa2..a8578ae3 100755 --- a/dak/contents.py +++ b/dak/contents.py @@ -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() diff --git a/daklib/contents.py b/daklib/contents.py index 5bf94d9a..99d852b3 100755 --- a/daklib/contents.py +++ b/daklib/contents.py @@ -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): '''