]> git.decadent.org.uk Git - dak.git/blob - dak/dak.py
Add show-new to dak wrapper
[dak.git] / dak / dak.py
1 #!/usr/bin/env python
2
3 """Wrapper to launch dak functionality"""
4 # Copyright (C) 2005, 2006 Anthony Towns <ajt@debian.org>
5 # Copyright (C) 2006 James Troup <james@nocrew.org>
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21 ################################################################################
22
23 # well I don't know where you're from but in AMERICA, there's a little
24 # thing called "abstinent until proven guilty."
25 #  -- http://harrietmiers.blogspot.com/2005/10/wow-i-feel-loved.html
26
27 # (if James had a blog, I bet I could find a funny quote in it to use!)
28
29 ################################################################################
30
31 import sys
32 import daklib.utils
33
34 ################################################################################
35
36 def init():
37     """Setup the list of modules and brief explanation of what they
38     do."""
39
40     functionality = [
41         ("ls",
42          "Show which suites packages are in"),
43         ("override",
44          "Query/change the overrides"),
45         ("check-archive",
46          "Archive sanity checks"),
47         ("queue-report",
48          "Produce a report on NEW and BYHAND packages"),
49         ("show-new",
50          "Output html for packages in NEW"),
51         
52         ("rm",
53          "Remove packages from suites"),
54         
55         ("process-new",
56          "Process NEW and BYHAND packages"),
57         ("process-unchecked",
58          "Process packages in queue/unchecked"),
59         ("process-accepted",
60          "Install packages into the pool"),
61         
62         ("make-suite-file-list",
63          "Generate lists of packages per suite for apt-ftparchive"),
64         ("generate-releases",
65          "Generate Release files"),
66         ("generate-index-diffs",
67          "Generate .diff/Index files"),
68         ("clean-suites",
69          "Clean unused/superseded packages from the archive"),
70         ("clean-queues",
71          "Clean cruft from incoming"),
72         ("clean-proposed-updates",
73          "Remove obsolete .changes from proposed-updates"),
74         
75         ("check-overrides",
76          "Override cruft checks"),
77         ("check-proposed-updates",
78          "Dependency checking for proposed-updates"),
79         ("compare-suites",
80          "Show fixable discrepencies between suites"),
81         ("control-overrides",
82          "Manipulate/list override entries in bulk"),
83         ("control-suite",
84          "Manipulate suites in bulk"),
85         ("cruft-report",
86          "Check for obsolete or duplicated packages"),
87         ("decode-dot-dak",
88          "Display contents of a .dak file"),
89         ("examine-package",
90          "Show information useful for NEW processing"),
91         ("find-null-maintainers",
92          "Check for users with no packages in the archive"),
93         ("import-archive",
94          "Populate SQL database based from an archive tree"),
95         ("import-keyring",
96          "Populate fingerprint/uid table based on a new/updated keyring"),
97         ("import-ldap-fingerprints",
98          "Syncs fingerprint and uid tables with Debian LDAP db"),
99         ("import-users-from-passwd",
100          "Sync PostgreSQL users with passwd file"),
101         ("init-db",
102          "Update the database to match the conf file"),
103         ("init-dirs",
104          "Initial setup of the archive"),
105         ("make-maintainers",
106          "Generates Maintainers file for BTS etc"),
107         ("make-overrides",
108          "Generates override files"),
109         ("mirror-split",
110          "Split the pool/ by architecture groups"),
111         ("poolize",
112          "Move packages from dists/ to pool/"),
113         ("reject-proposed-updates",
114          "Manually reject from proposed-updates"),
115         ("security-install",
116          "Install a security upload into the archive"),
117         ("new-security-install",
118          "New way to install a security upload into the archive"),
119         ("split-done",
120          "Split queue/done into a date-based hierarchy"),
121         ("stats",
122          "Generate statistics"),
123         ("symlink-dists",
124          "Generate compatability symlinks from dists/ into pool/"),
125         ]
126     return functionality
127     
128 ################################################################################
129
130 def usage(functionality, exit_code=0):
131     """Print a usage message and exit with 'exit_code'."""
132
133     print """Usage: dak COMMAND [...]
134 Run DAK commands.  (Will also work if invoked as COMMAND.)
135
136 Availble commands:"""
137     for (command, description) in functionality:
138         print "  %-23s %s" % (command, description)
139     sys.exit(exit_code)
140
141 ################################################################################
142
143 def main():
144     """Launch dak functionality."""
145
146     functionality = init()
147     modules = [ command for (command, _) in functionality ]
148     
149     if len(sys.argv) == 0:
150         daklib.utils.fubar("err, argc == 0? how is that possible?")
151     elif (len(sys.argv) == 1
152           or (len(sys.argv) == 2 and
153               (sys.argv[1] == "--help" or sys.argv[1] == "-h"))):
154         usage(functionality)
155
156     # First see if we were invoked with/as the name of a module
157     cmdname = sys.argv[0]
158     cmdname = cmdname[cmdname.rfind("/")+1:]
159     if cmdname in modules:
160         pass
161     # Otherwise the argument is the module
162     else:
163         cmdname = sys.argv[1]
164         sys.argv = [sys.argv[0] + " " + sys.argv[1]] + sys.argv[2:]
165         if cmdname not in modules:
166             match = []
167             for name in modules:
168                 if name.startswith(cmdname):
169                     match.append(name)
170             if len(match) == 1:
171                 cmdname = match[0]
172             elif len(match) > 1:
173                 daklib.utils.warn("ambiguous command '%s' - could be %s" \
174                            % (cmdname, ", ".join(match)))
175                 usage(functionality, 1)
176             else:
177                 daklib.utils.warn("unknown command '%s'" % (cmdname))
178                 usage(functionality, 1)
179
180     # Invoke the module
181     module = __import__(cmdname.replace("-","_"))
182     module.main()
183
184 ################################################################################
185
186 if __name__ == "__main__":
187     main()