3 Import data for Packages files from .deb files
5 @contact: Debian FTPMaster <ftpmaster@debian.org>
6 @copyright: 2008, 2009 Michael Casadevall <mcasadevall@debian.org>
7 @copyright: 2009 Mike O'Connor <stew@debian.org>
8 @copyright: 2011 Torsten Werner <twerner@debian.org>
9 @copyright: 2011 Mark Hymers <mhy@debian.org>
10 @license: GNU General Public License version 2 or later
13 ################################################################################
15 # This program is free software; you can redistribute it and/or modify
16 # it under the terms of the GNU General Public License as published by
17 # the Free Software Foundation; either version 2 of the License, or
18 # (at your option) any later version.
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 ################################################################################
31 # < mvo> that screams for consolidation in libapt at least (that then in turn can
32 # use libdpkg ... ) - I guess the "d" means delayed ;)
34 # (whilst discussing adding xz support to dak, and therefore python-apt, and
35 # therefore libapt-pkg)
37 ################################################################################
42 from daklib.config import Config
43 from daklib.dbconn import *
44 from daklib.packages import PackagesScanner
45 from daklib import daklog
46 from daklib import utils
48 ################################################################################
50 def usage (exit_code=0):
51 print """Usage: dak packagescan [options] subcommand
55 scan the debs in the existing pool and load metadata into the database
59 show this help and exit
63 maximum number of packages to scan
67 ################################################################################
69 def scan_all(cnf, limit):
70 Logger = daklog.Logger(cnf.Cnf, 'packages scan')
71 result = PackagesScanner.scan_all(limit)
72 processed = '%(processed)d packages processed' % result
73 remaining = '%(remaining)d packages remaining' % result
74 Logger.log([processed, remaining])
77 ################################################################################
81 cnf['Packages::Options::Help'] = ''
82 cnf['Packages::Options::Suite'] = ''
83 cnf['Packages::Options::Limit'] = ''
84 cnf['Packages::Options::Force'] = ''
85 arguments = [('h', "help", 'Packages::Options::Help'),
86 ('s', "suite", 'Packages::Options::Suite', "HasArg"),
87 ('l', "limit", 'Packages::Options::Limit', "HasArg"),
88 ('f', "force", 'Packages::Options::Force'),
90 args = apt_pkg.ParseCommandLine(cnf.Cnf, arguments, sys.argv)
91 options = cnf.SubTree('Packages::Options')
93 if (len(args) != 1) or options['Help']:
97 if len(options['Limit']) > 0:
98 limit = int(options['Limit'])
100 if args[0] == 'scan':
104 suite_names = utils.split_args(options['Suite'])
106 force = bool(options['Force'])
108 if args[0] == 'generate':
109 raise NotImplementError
114 if __name__ == '__main__':