X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fcontents.py;h=407b3c06475dfae80229d676175bbec415d7fd35;hb=03a86547e5d9b209016cc0b23f825d3baea92f8c;hp=5c33afa2f67f333e4ff1f3ee2b74e697338a4d5f;hpb=8204c1531d3521299478d60492299600d11f880e;p=dak.git diff --git a/dak/contents.py b/dak/contents.py index 5c33afa2..407b3c06 100755 --- a/dak/contents.py +++ b/dak/contents.py @@ -40,7 +40,8 @@ import apt_pkg from daklib.config import Config from daklib.dbconn import * -from daklib.contents import ContentsScanner, ContentsWriter +from daklib.contents import BinaryContentsScanner, ContentsWriter, \ + SourceContentsScanner from daklib import daklog from daklib import utils @@ -53,21 +54,32 @@ SUBCOMMANDS generate generate Contents-$arch.gz files - scan - scan the debs in the existing pool and load contents into the bin_contents table + scan-source + scan the source packages in the existing pool and load contents into + the src_contents table + + scan-binary + scan the (u)debs in the existing pool and load contents into the + bin_contents table OPTIONS -h, --help show this help and exit OPTIONS for generate + -a, --archive=ARCHIVE + only operate on suites in the specified archive + -s, --suite={stable,testing,unstable,...} only operate on specified suite names + -c, --component={main,contrib,non-free} + only operate on specified components + -f, --force write Contents files for suites marked as untouchable, too -OPTIONS for scan +OPTIONS for scan-source and scan-binary -l, --limit=NUMBER maximum number of packages to scan """ @@ -75,31 +87,26 @@ OPTIONS for scan ################################################################################ -def write_all(cnf, suite_names = [], force = None): - Logger = daklog.Logger(cnf.Cnf, 'contents generate') - ContentsWriter.write_all(suite_names, force) +def write_all(cnf, archive_names = [], suite_names = [], component_names = [], force = None): + Logger = daklog.Logger('contents generate') + ContentsWriter.write_all(Logger, archive_names, suite_names, component_names, force) Logger.close() ################################################################################ -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 binary_scan_all(cnf, limit): + Logger = daklog.Logger('contents scan-binary') + result = BinaryContentsScanner.scan_all(limit) + processed = '%(processed)d packages processed' % result + remaining = '%(remaining)d packages remaining' % result + Logger.log([processed, remaining]) + Logger.close() ################################################################################ -def scan_all(cnf, limit): - Logger = daklog.Logger(cnf.Cnf, 'contents scan') - result = ContentsScanner.scan_all(limit) +def source_scan_all(cnf, limit): + Logger = daklog.Logger('contents scan-source') + result = SourceContentsScanner.scan_all(limit) processed = '%(processed)d packages processed' % result remaining = '%(remaining)d packages remaining' % result Logger.log([processed, remaining]) @@ -111,37 +118,42 @@ def main(): cnf = Config() cnf['Contents::Options::Help'] = '' cnf['Contents::Options::Suite'] = '' + cnf['Contents::Options::Component'] = '' cnf['Contents::Options::Limit'] = '' cnf['Contents::Options::Force'] = '' - arguments = [('h', "help", 'Contents::Options::Help'), - ('s', "suite", 'Contents::Options::Suite', "HasArg"), - ('l', "limit", 'Contents::Options::Limit', "HasArg"), - ('f', "force", 'Contents::Options::Force'), + arguments = [('h', "help", 'Contents::Options::Help'), + ('a', 'archive', 'Contents::Options::Archive', 'HasArg'), + ('s', "suite", 'Contents::Options::Suite', "HasArg"), + ('c', "component", 'Contents::Options::Component', "HasArg"), + ('l', "limit", 'Contents::Options::Limit', "HasArg"), + ('f', "force", 'Contents::Options::Force'), ] - args = apt_pkg.ParseCommandLine(cnf.Cnf, arguments, sys.argv) - options = cnf.SubTree('Contents::Options') + args = apt_pkg.parse_commandline(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 if len(options['Limit']) > 0: limit = int(options['Limit']) - if args[0] == 'scan': - scan_all(cnf, limit) + if args[0] == 'scan-source': + source_scan_all(cnf, limit) + return + + if args[0] == 'scan-binary': + binary_scan_all(cnf, limit) return - suite_names = utils.split_args(options['Suite']) + archive_names = utils.split_args(options['Archive']) + suite_names = utils.split_args(options['Suite']) + component_names = utils.split_args(options['Component']) force = bool(options['Force']) if args[0] == 'generate': - write_all(cnf, suite_names, force) - return - - if args[0] == 'generate_helper': - write_helper(suite_names[0], args[1:]) + write_all(cnf, archive_names, suite_names, component_names, force) return usage()