]> git.decadent.org.uk Git - dak.git/blob - dak/dak.py
drop unused imports
[dak.git] / dak / dak.py
1 #!/usr/bin/env python
2
3 """
4 Wrapper to launch dak functionality
5
6 G{importgraph}
7
8 """
9 # Copyright (C) 2005, 2006 Anthony Towns <ajt@debian.org>
10 # Copyright (C) 2006 James Troup <james@nocrew.org>
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 # well I don't know where you're from but in AMERICA, there's a little
29 # thing called "abstinent until proven guilty."
30 #  -- http://harrietmiers.blogspot.com/2005/10/wow-i-feel-loved.html
31
32 # (if James had a blog, I bet I could find a funny quote in it to use!)
33
34 ################################################################################
35
36 import sys
37 import daklib.utils
38
39 ################################################################################
40
41 def init():
42     """Setup the list of modules and brief explanation of what they
43     do."""
44
45     functionality = [
46         ("ls",
47          "Show which suites packages are in"),
48         ("override",
49          "Query/change the overrides"),
50         ("check-archive",
51          "Archive sanity checks"),
52         ("queue-report",
53          "Produce a report on NEW and BYHAND packages"),
54         ("show-new",
55          "Output html for packages in NEW"),
56         ("show-deferred",
57          "Output html and symlinks for packages in DEFERRED"),
58
59         ("rm",
60          "Remove packages from suites"),
61
62         ("process-new",
63          "Process NEW and BYHAND packages"),
64         ("process-unchecked",
65          "Process packages in queue/unchecked"),
66         ("process-accepted",
67          "Install packages into the pool"),
68
69         ("make-suite-file-list",
70          "Generate lists of packages per suite for apt-ftparchive"),
71         ("make-pkg-file-mapping",
72          "Generate package <-> file mapping"),
73         ("generate-releases",
74          "Generate Release files"),
75         ("contents",
76          "Generate content files"),
77         ("generate-index-diffs",
78          "Generate .diff/Index files"),
79         ("clean-suites",
80          "Clean unused/superseded packages from the archive"),
81         ("clean-queues",
82          "Clean cruft from incoming"),
83         ("clean-proposed-updates",
84          "Remove obsolete .changes from proposed-updates"),
85
86         ("transitions",
87          "Manage the release transition file"),
88         ("check-overrides",
89          "Override cruft checks"),
90         ("check-proposed-updates",
91          "Dependency checking for proposed-updates"),
92         ("control-overrides",
93          "Manipulate/list override entries in bulk"),
94         ("control-suite",
95          "Manipulate suites in bulk"),
96         ("cruft-report",
97          "Check for obsolete or duplicated packages"),
98         ("decode-dot-dak",
99          "Display contents of a .dak file"),
100         ("examine-package",
101          "Show information useful for NEW processing"),
102         ("find-null-maintainers",
103          "Check for users with no packages in the archive"),
104         ("import-keyring",
105          "Populate fingerprint/uid table based on a new/updated keyring"),
106         ("import-ldap-fingerprints",
107          "Syncs fingerprint and uid tables with Debian LDAP db"),
108         ("import-users-from-passwd",
109          "Sync PostgreSQL users with passwd file"),
110         ("admin",
111          "Perform administration on the dak database"),
112         ("init-db",
113          "Update the database to match the conf file"),
114         ("update-db",
115          "Updates databae schema to latest revision"),
116         ("init-dirs",
117          "Initial setup of the archive"),
118         ("make-maintainers",
119          "Generates Maintainers file for BTS etc"),
120         ("make-overrides",
121          "Generates override files"),
122         ("poolize",
123          "Move packages from dists/ to pool/"),
124         ("new-security-install",
125          "New way to install a security upload into the archive"),
126         ("split-done",
127          "Split queue/done into a date-based hierarchy"),
128         ("stats",
129          "Generate statistics"),
130         ("bts-categorize",
131          "Categorize uncategorized bugs filed against ftp.debian.org"),
132         ("add-user",
133          "Add a user to the archive"),
134         ]
135     return functionality
136
137 ################################################################################
138
139 def usage(functionality, exit_code=0):
140     """Print a usage message and exit with 'exit_code'."""
141
142     print """Usage: dak COMMAND [...]
143 Run DAK commands.  (Will also work if invoked as COMMAND.)
144
145 Available commands:"""
146     for (command, description) in functionality:
147         print "  %-23s %s" % (command, description)
148     sys.exit(exit_code)
149
150 ################################################################################
151
152 def main():
153     """Launch dak functionality."""
154
155     functionality = init()
156     modules = [ command for (command, _) in functionality ]
157
158     if len(sys.argv) == 0:
159         daklib.utils.fubar("err, argc == 0? how is that possible?")
160     elif (len(sys.argv) == 1
161           or (len(sys.argv) == 2 and
162               (sys.argv[1] == "--help" or sys.argv[1] == "-h"))):
163         usage(functionality)
164
165     # First see if we were invoked with/as the name of a module
166     cmdname = sys.argv[0]
167     cmdname = cmdname[cmdname.rfind("/")+1:]
168     if cmdname in modules:
169         pass
170     # Otherwise the argument is the module
171     else:
172         cmdname = sys.argv[1]
173         sys.argv = [sys.argv[0] + " " + sys.argv[1]] + sys.argv[2:]
174         if cmdname not in modules:
175             match = []
176             for name in modules:
177                 if name.startswith(cmdname):
178                     match.append(name)
179             if len(match) == 1:
180                 cmdname = match[0]
181             elif len(match) > 1:
182                 daklib.utils.warn("ambiguous command '%s' - could be %s" \
183                            % (cmdname, ", ".join(match)))
184                 usage(functionality, 1)
185             else:
186                 daklib.utils.warn("unknown command '%s'" % (cmdname))
187                 usage(functionality, 1)
188
189     # Invoke the module
190     module = __import__(cmdname.replace("-","_"))
191
192     module.main()
193
194 ################################################################################
195
196 if __name__ == "__main__":
197     main()