3 Import data for Package/Sources files from .deb and .dsc files
4 @copyright: 2011 Torsten Werner <twerner@debian.org>
5 @copyright: 2011 Mark Hymers <mhy@debian.org>
6 @license: GNU General Public License version 2 or later
9 ################################################################################
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 ################################################################################
27 # < mvo> that screams for consolidation in libapt at least (that then in turn can
28 # use libdpkg ... ) - I guess the "d" means delayed ;)
30 # (whilst discussing adding xz support to dak, and therefore python-apt, and
31 # therefore libapt-pkg)
33 ################################################################################
38 from daklib.config import Config
39 from daklib.dbconn import *
40 from daklib.metadata import MetadataScanner
41 from daklib import daklog
42 from daklib import utils
44 ################################################################################
46 def usage (exit_code=0):
47 print """Usage: dak metadata [options] subcommand
51 scan the dsc files in the existing pool and load metadata into the database
54 scan the deb files in the existing pool and load metadata into the database
58 show this help and exit
62 maximum number of items to scan
66 ################################################################################
68 def scan_all(cnf, mode, limit):
69 Logger = daklog.Logger('metadata scan (%s)' % mode)
70 result = MetadataScanner.scan_all(mode, limit)
71 processed = '%(processed)d %(type)s processed' % result
72 remaining = '%(remaining)d %(type)s remaining' % result
73 Logger.log([processed, remaining])
76 ################################################################################
80 cnf['Metadata::Options::Help'] = ''
81 cnf['Metadata::Options::Suite'] = ''
82 cnf['Metadata::Options::Limit'] = ''
83 cnf['Metadata::Options::Force'] = ''
84 arguments = [('h', "help", 'Metadata::Options::Help'),
85 ('s', "suite", 'Metadata::Options::Suite', "HasArg"),
86 ('l', "limit", 'Metadata::Options::Limit', "HasArg"),
87 ('f', "force", 'Metadata::Options::Force'),
89 args = apt_pkg.parse_commandline(cnf.Cnf, arguments, sys.argv)
90 options = cnf.subtree('Metadata::Options')
92 if (len(args) != 1) or options['Help']:
96 if len(options['Limit']) > 0:
97 limit = int(options['Limit'])
99 if args[0] == 'scan-source':
100 scan_all(cnf, 'source', limit)
102 elif args[0] == 'scan-binary':
103 scan_all(cnf, 'binary', limit)
106 suite_names = utils.split_args(options['Suite'])
108 force = bool(options['Force'])
110 if args[0] == 'generate':
111 raise NotImplementError
116 if __name__ == '__main__':