]> git.donarmstrong.com Git - dak.git/blob - dak/generate_packages_sources.py
Add start of a generate_packages_sources command
[dak.git] / dak / generate_packages_sources.py
1 #!/usr/bin/env python
2
3 """ Generate Packages/Sources files
4
5 @contact: Debian FTPMaster <ftpmaster@debian.org>
6 @copyright: 2000, 2001, 2002, 2006  James Troup <james@nocrew.org>
7 @copyright: 2009  Mark Hymers <mhy@debian.org>
8 @copyright: 2010  Joerg Jaspert <joerg@debian.org>
9
10 """
11
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
16
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
26 ################################################################################
27
28 import os
29 import os.path
30 import stat
31 import sys
32 from datetime import datetime
33 import apt_pkg
34
35 from daklib import daklog
36 from daklib.dbconn import *
37 from daklib.config import Config
38
39 ################################################################################
40
41 Options = None
42 Logger = None
43
44 ################################################################################
45
46 def usage (exit_code=0):
47     print """Usage: dak generate-packages-sources [OPTIONS]
48 Generate the Packages/Sources files
49
50   -s, --suite=SUITE(s)       process this suite
51                              Default: All suites not marked 'untouchable'
52   -f, --force                Allow processing of untouchable suites
53                              CAREFUL: Only to be used at point release time!
54   -h, --help                 show this help and exit
55
56 SUITE can be a space seperated list, e.g.
57    --suite=unstable testing
58   """
59
60     sys.exit(exit_code)
61
62 ################################################################################
63
64 def main ():
65     global Options, Logger
66
67     cnf = Config()
68
69     for i in ["Help", "Suite", "Force"]:
70         if not cnf.has_key("Generate-Packages-Sources::Options::%s" % (i)):
71             cnf["Generate-Packages-Sources::Options::%s" % (i)] = ""
72
73     Arguments = [('h',"help","Generate-Packages-Sources::Options::Help"),
74                  ('s',"suite","Generate-Packages-Sources::Options::Suite"),
75                  ('f',"force","Generate-Packages-Sources::Options::Force")]
76
77     suite_names = apt_pkg.ParseCommandLine(cnf.Cnf, Arguments, sys.argv)
78     Options = cnf.SubTree("Generate-Packages-Sources::Options")
79
80     if Options["Help"]:
81         usage()
82
83 #    Logger = daklog.Logger(cnf, 'generate-packages-sources')
84
85     session = DBConn().session()
86
87     if Options["Suite"]:
88         # Something here
89         suites = []
90         for s in suite_names:
91             suite = get_suite(s.lower(), session)
92             if suite:
93                 suites.append(suite)
94             else:
95                 print "cannot find suite %s" % s
96 #                Logger.log(['cannot find suite %s' % s])
97     else:
98         suites=session.query(Suite).filter(Suite.untouchable == 'false').all()
99
100     for s in suites:
101         print "Working on: %s" % (s.suite_name)
102     sys.exit(0)
103     # For each given suite, look up object and call generate-filelist
104     for s in suites:
105         Logger.log(['generating filelist for %s' % (s.suite_name)])
106         s.generate_filelist(Logger)
107
108 #    Logger.close()
109
110 #######################################################################################
111
112 if __name__ == '__main__':
113     main()