4 Wrapper to launch dak functionality
9 # Copyright (C) 2005, 2006 Anthony Towns <ajt@debian.org>
10 # Copyright (C) 2006 James Troup <james@nocrew.org>
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.
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.
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
26 ################################################################################
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
32 # (if James had a blog, I bet I could find a funny quote in it to use!)
34 ################################################################################
40 from daklib.daklog import Logger
41 from daklib.config import Config
43 ################################################################################
46 """Setup the list of modules and brief explanation of what they
51 "Show which suites packages are in"),
53 "Query/change the overrides"),
55 "Archive sanity checks"),
57 "Produce a report on NEW and BYHAND packages"),
59 "Output html for packages in NEW"),
61 "Output html and symlinks for packages in DEFERRED"),
64 "Remove packages from suites"),
67 "Process NEW and BYHAND packages"),
69 "Process packages in queue/unchecked"),
71 "Install packages into the pool"),
73 ("make-suite-file-list",
74 "Generate lists of packages per suite for apt-ftparchive"),
75 ("make-pkg-file-mapping",
76 "Generate package <-> file mapping"),
78 "Generate Release files"),
80 "Generate content files"),
81 ("generate-index-diffs",
82 "Generate .diff/Index files"),
84 "Clean unused/superseded packages from the archive"),
86 "Clean cruft from incoming"),
87 ("clean-proposed-updates",
88 "Remove obsolete .changes from proposed-updates"),
91 "Manage the release transition file"),
93 "Override cruft checks"),
94 ("check-proposed-updates",
95 "Dependency checking for proposed-updates"),
97 "Manipulate/list override entries in bulk"),
99 "Manipulate suites in bulk"),
101 "Check for obsolete or duplicated packages"),
103 "Display contents of a .dak file"),
105 "Show information useful for NEW processing"),
106 ("find-null-maintainers",
107 "Check for users with no packages in the archive"),
109 "Populate fingerprint/uid table based on a new/updated keyring"),
110 ("import-ldap-fingerprints",
111 "Syncs fingerprint and uid tables with Debian LDAP db"),
112 ("import-users-from-passwd",
113 "Sync PostgreSQL users with passwd file"),
115 "Perform administration on the dak database"),
117 "Update the database to match the conf file"),
119 "Updates databae schema to latest revision"),
121 "Initial setup of the archive"),
123 "Generates Maintainers file for BTS etc"),
125 "Generates override files"),
127 "Move packages from dists/ to pool/"),
128 ("new-security-install",
129 "New way to install a security upload into the archive"),
131 "Split queue/done into a date-based hierarchy"),
133 "Generate statistics"),
135 "Categorize uncategorized bugs filed against ftp.debian.org"),
137 "Add a user to the archive"),
141 ################################################################################
143 def usage(functionality, exit_code=0):
144 """Print a usage message and exit with 'exit_code'."""
146 print """Usage: dak COMMAND [...]
147 Run DAK commands. (Will also work if invoked as COMMAND.)
149 Available commands:"""
150 for (command, description) in functionality:
151 print " %-23s %s" % (command, description)
154 ################################################################################
157 """Launch dak functionality."""
159 logger = Logger(Config(), 'dak top-level', print_starting=False)
161 functionality = init()
162 modules = [ command for (command, _) in functionality ]
164 if len(sys.argv) == 0:
165 daklib.utils.fubar("err, argc == 0? how is that possible?")
166 elif (len(sys.argv) == 1
167 or (len(sys.argv) == 2 and
168 (sys.argv[1] == "--help" or sys.argv[1] == "-h"))):
171 # First see if we were invoked with/as the name of a module
172 cmdname = sys.argv[0]
173 cmdname = cmdname[cmdname.rfind("/")+1:]
174 if cmdname in modules:
176 # Otherwise the argument is the module
178 cmdname = sys.argv[1]
179 sys.argv = [sys.argv[0] + " " + sys.argv[1]] + sys.argv[2:]
180 if cmdname not in modules:
183 if name.startswith(cmdname):
188 daklib.utils.warn("ambiguous command '%s' - could be %s" \
189 % (cmdname, ", ".join(match)))
190 usage(functionality, 1)
192 daklib.utils.warn("unknown command '%s'" % (cmdname))
193 usage(functionality, 1)
196 module = __import__(cmdname.replace("-","_"))
200 except KeyboardInterrupt:
201 msg = 'KeyboardInterrupt caught; exiting'
206 for line in traceback.format_exc().split('\n')[:-1]:
207 logger.log(['exception', line])
210 ################################################################################
212 if __name__ == "__main__":