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 ################################################################################
41 from daklib.daklog import Logger
42 from daklib.config import Config
43 from daklib.dak_exceptions import CantOpenError
45 ################################################################################
48 """Setup the list of modules and brief explanation of what they
53 "Show which suites packages are in"),
55 "Query/change the overrides"),
57 "Archive sanity checks"),
59 "Produce a report on NEW and BYHAND packages"),
61 "Output html for packages in NEW"),
63 "Output html and symlinks for packages in DEFERRED"),
66 "Remove packages from suites"),
69 "Process NEW and BYHAND packages"),
71 "Process packages in queue/unchecked"),
73 "Process packages in policy queues from COMMENTS files"),
76 "Remove obsolete source and binary associations from suites"),
77 ("make-pkg-file-mapping",
78 "Generate package <-> file mapping"),
80 "Generate file lists for apt-ftparchive"),
82 "Generate Release files"),
83 ("generate-packages-sources",
84 "Generate Packages/Sources files"),
86 "Generate content files"),
87 ("generate-index-diffs",
88 "Generate .diff/Index files"),
90 "Clean unused/superseded packages from the archive"),
91 ("manage-build-queues",
92 "Clean and update metadata for build queues"),
94 "Clean cruft from incoming"),
95 ("clean-proposed-updates",
96 "Remove obsolete .changes from proposed-updates"),
99 "Manage the release transition file"),
101 "Override cruft checks"),
102 ("check-proposed-updates",
103 "Dependency checking for proposed-updates"),
104 ("control-overrides",
105 "Manipulate/list override entries in bulk"),
107 "Manipulate suites in bulk"),
109 "Check for obsolete or duplicated packages"),
111 "Show information useful for NEW processing"),
112 ("find-null-maintainers",
113 "Check for users with no packages in the archive"),
115 "Populate fingerprint/uid table based on a new/updated keyring"),
116 ("import-ldap-fingerprints",
117 "Syncs fingerprint and uid tables with Debian LDAP db"),
118 ("import-users-from-passwd",
119 "Sync PostgreSQL users with passwd file"),
121 "Perform administration on the dak database"),
123 "Updates databae schema to latest revision"),
125 "Initial setup of the archive"),
127 "Generates Maintainers file for BTS etc"),
129 "Generates override files"),
131 "Move packages from dists/ to pool/"),
132 ("new-security-install",
133 "New way to install a security upload into the archive"),
135 "Split queue/done into a date-based hierarchy"),
137 "Generate statistics"),
139 "Categorize uncategorized bugs filed against ftp.debian.org"),
140 ("import-known-changes",
141 "import old changes files into known_changes table"),
143 "Add a user to the archive"),
145 "Generate changelog between two suites"),
147 "Copies the installer from one suite to another"),
148 ("override-disparity",
149 "Generate a list of override disparities"),
153 ################################################################################
155 def usage(functionality, exit_code=0):
156 """Print a usage message and exit with 'exit_code'."""
158 print """Usage: dak COMMAND [...]
159 Run DAK commands. (Will also work if invoked as COMMAND.)
161 Available commands:"""
162 for (command, description) in functionality:
163 print " %-23s %s" % (command, description)
166 ################################################################################
169 """Launch dak functionality."""
173 logger = Logger(Config(), 'dak top-level', print_starting=False)
174 except CantOpenError:
177 functionality = init()
178 modules = [ command for (command, _) in functionality ]
180 if len(sys.argv) == 0:
181 daklib.utils.fubar("err, argc == 0? how is that possible?")
182 elif (len(sys.argv) == 1
183 or (len(sys.argv) == 2 and
184 (sys.argv[1] == "--help" or sys.argv[1] == "-h"))):
187 # First see if we were invoked with/as the name of a module
188 cmdname = sys.argv[0]
189 cmdname = cmdname[cmdname.rfind("/")+1:]
190 if cmdname in modules:
192 # Otherwise the argument is the module
194 cmdname = sys.argv[1]
195 sys.argv = [sys.argv[0] + " " + sys.argv[1]] + sys.argv[2:]
196 if cmdname not in modules:
199 if name.startswith(cmdname):
204 daklib.utils.warn("ambiguous command '%s' - could be %s" \
205 % (cmdname, ", ".join(match)))
206 usage(functionality, 1)
208 daklib.utils.warn("unknown command '%s'" % (cmdname))
209 usage(functionality, 1)
212 module = __import__(cmdname.replace("-","_"))
216 except KeyboardInterrupt:
217 msg = 'KeyboardInterrupt caught; exiting'
226 for line in traceback.format_exc().split('\n')[:-1]:
227 logger.log(['exception', line])
230 ################################################################################
232 if __name__ == "__main__":
233 os.environ['LANG'] = 'C'
234 os.environ['LC_ALL'] = 'C'