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