]> git.decadent.org.uk Git - dak.git/blob - dak/dak.py
changes for DM support
[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         
50         ("rm",
51          "Remove packages from suites"),
52         
53         ("process-new",
54          "Process NEW and BYHAND packages"),
55         ("process-unchecked",
56          "Process packages in queue/unchecked"),
57         ("process-accepted",
58          "Install packages into the pool"),
59         
60         ("make-suite-file-list",
61          "Generate lists of packages per suite for apt-ftparchive"),
62         ("generate-releases",
63          "Generate Release files"),
64         ("generate-index-diffs",
65          "Generate .diff/Index files"),
66         ("clean-suites",
67          "Clean unused/superseded packages from the archive"),
68         ("clean-queues",
69          "Clean cruft from incoming"),
70         ("clean-proposed-updates",
71          "Remove obsolete .changes from proposed-updates"),
72         
73         ("check-overrides",
74          "Override cruft checks"),
75         ("check-proposed-updates",
76          "Dependency checking for proposed-updates"),
77         ("compare-suites",
78          "Show fixable discrepencies between suites"),
79         ("control-overrides",
80          "Manipulate/list override entries in bulk"),
81         ("control-suite",
82          "Manipulate suites in bulk"),
83         ("cruft-report",
84          "Check for obsolete or duplicated packages"),
85         ("decode-dot-dak",
86          "Display contents of a .dak file"),
87         ("examine-package",
88          "Show information useful for NEW processing"),
89         ("find-null-maintainers",
90          "Check for users with no packages in the archive"),
91         ("import-archive",
92          "Populate SQL database based from an archive tree"),
93         ("import-keyring",
94          "Populate fingerprint/uid table based on a new/updated keyring"),
95         ("import-ldap-fingerprints",
96          "Syncs fingerprint and uid tables with Debian LDAP db"),
97         ("import-users-from-passwd",
98          "Sync PostgreSQL users with passwd file"),
99         ("init-db",
100          "Update the database to match the conf file"),
101         ("init-dirs",
102          "Initial setup of the archive"),
103         ("make-maintainers",
104          "Generates Maintainers file for BTS etc"),
105         ("make-overrides",
106          "Generates override files"),
107         ("mirror-split",
108          "Split the pool/ by architecture groups"),
109         ("poolize",
110          "Move packages from dists/ to pool/"),
111         ("reject-proposed-updates",
112          "Manually reject from proposed-updates"),
113         ("security-install",
114          "Install a security upload into the archive"),
115         ("new-security-install",
116          "New way to install a security upload into the archive"),
117         ("split-done",
118          "Split queue/done into a date-based hierarchy"),
119         ("stats",
120          "Generate statistics"),
121         ("symlink-dists",
122          "Generate compatability symlinks from dists/ into pool/"),
123         ]
124     return functionality
125     
126 ################################################################################
127
128 def usage(functionality, exit_code=0):
129     """Print a usage message and exit with 'exit_code'."""
130
131     print """Usage: dak COMMAND [...]
132 Run DAK commands.  (Will also work if invoked as COMMAND.)
133
134 Availble commands:"""
135     for (command, description) in functionality:
136         print "  %-23s %s" % (command, description)
137     sys.exit(exit_code)
138
139 ################################################################################
140
141 def main():
142     """Launch dak functionality."""
143
144     functionality = init()
145     modules = [ command for (command, _) in functionality ]
146     
147     if len(sys.argv) == 0:
148         daklib.utils.fubar("err, argc == 0? how is that possible?")
149     elif (len(sys.argv) == 1
150           or (len(sys.argv) == 2 and
151               (sys.argv[1] == "--help" or sys.argv[1] == "-h"))):
152         usage(functionality)
153
154     # First see if we were invoked with/as the name of a module
155     cmdname = sys.argv[0]
156     cmdname = cmdname[cmdname.rfind("/")+1:]
157     if cmdname in modules:
158         pass
159     # Otherwise the argument is the module
160     else:
161         cmdname = sys.argv[1]
162         sys.argv = [sys.argv[0] + " " + sys.argv[1]] + sys.argv[2:]
163         if cmdname not in modules:
164             match = []
165             for name in modules:
166                 if name.startswith(cmdname):
167                     match.append(name)
168             if len(match) == 1:
169                 cmdname = match[0]
170             elif len(match) > 1:
171                 daklib.utils.warn("ambiguous command '%s' - could be %s" \
172                            % (cmdname, ", ".join(match)))
173                 usage(functionality, 1)
174             else:
175                 daklib.utils.warn("unknown command '%s'" % (cmdname))
176                 usage(functionality, 1)
177
178     # Invoke the module
179     module = __import__(cmdname.replace("-","_"))
180     module.main()
181
182 ################################################################################
183
184 if __name__ == "__main__":
185     main()