3 Create all the contents 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 @license: GNU General Public License version 2 or later
12 ################################################################################
14 # This program is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 ################################################################################
30 # <Ganneff> there is the idea to slowly replace contents files
31 # <Ganneff> with a new generation of such files.
32 # <Ganneff> having more info.
34 # <Ganneff> of course that wont help for now where we need to generate them :)
36 ################################################################################
41 from daklib.config import Config
42 from daklib.dbconn import *
43 from daklib.contents import ContentsScanner, ContentsWriter
44 from daklib import daklog
45 from daklib import utils
47 ################################################################################
49 def usage (exit_code=0):
50 print """Usage: dak contents [options] subcommand
54 generate Contents-$arch.gz files
57 scan the debs in the existing pool and load contents into the bin_contents table
61 show this help and exit
64 -s, --suite={stable,testing,unstable,...}
65 only operate on specified suite names
68 write Contents files for suites marked as untouchable, too
72 maximum number of packages to scan
76 ################################################################################
78 def write_all(cnf, suite_names = [], force = None):
79 Logger = daklog.Logger(cnf.Cnf, 'contents generate')
80 ContentsWriter.write_all(Logger, suite_names, force)
83 ################################################################################
85 def scan_all(cnf, limit):
86 Logger = daklog.Logger(cnf.Cnf, 'contents scan')
87 result = ContentsScanner.scan_all(limit)
88 processed = '%(processed)d packages processed' % result
89 remaining = '%(remaining)d packages remaining' % result
90 Logger.log([processed, remaining])
93 ################################################################################
97 cnf['Contents::Options::Help'] = ''
98 cnf['Contents::Options::Suite'] = ''
99 cnf['Contents::Options::Limit'] = ''
100 cnf['Contents::Options::Force'] = ''
101 arguments = [('h', "help", 'Contents::Options::Help'),
102 ('s', "suite", 'Contents::Options::Suite', "HasArg"),
103 ('l', "limit", 'Contents::Options::Limit', "HasArg"),
104 ('f', "force", 'Contents::Options::Force'),
106 args = apt_pkg.ParseCommandLine(cnf.Cnf, arguments, sys.argv)
107 options = cnf.SubTree('Contents::Options')
109 if (len(args) != 1) or options['Help']:
113 if len(options['Limit']) > 0:
114 limit = int(options['Limit'])
116 if args[0] == 'scan':
120 suite_names = utils.split_args(options['Suite'])
122 force = bool(options['Force'])
124 if args[0] == 'generate':
125 write_all(cnf, suite_names, force)
131 if __name__ == '__main__':