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"),
65 "Output graphs of number of packages in various queues"),
68 "Remove packages from suites"),
71 "Process NEW and BYHAND packages"),
73 "Process packages in queue/unchecked"),
75 "Process packages in policy queues from COMMENTS files"),
78 "Remove obsolete source and binary associations from suites"),
79 ("make-pkg-file-mapping",
80 "Generate package <-> file mapping"),
82 "Generate file lists for apt-ftparchive"),
84 "Generate Release files"),
85 ("generate-packages-sources",
86 "Generate Packages/Sources files"),
87 ("generate-packages-sources2",
88 "Generate Packages/Sources files [directly from database]"),
90 "Generate content files"),
92 "Load data for packages/sources files"),
93 ("generate-index-diffs",
94 "Generate .diff/Index files"),
96 "Clean unused/superseded packages from the archive"),
97 ("manage-build-queues",
98 "Clean and update metadata for build queues"),
100 "Clean cruft from incoming"),
101 ("clean-proposed-updates",
102 "Remove obsolete .changes from proposed-updates"),
105 "Manage the release transition file"),
107 "Override cruft checks"),
108 ("check-proposed-updates",
109 "Dependency checking for proposed-updates"),
110 ("control-overrides",
111 "Manipulate/list override entries in bulk"),
113 "Manipulate suites in bulk"),
115 "Check for obsolete or duplicated packages"),
117 "Show information useful for NEW processing"),
118 ("find-null-maintainers",
119 "Check for users with no packages in the archive"),
121 "Populate fingerprint/uid table based on a new/updated keyring"),
122 ("import-ldap-fingerprints",
123 "Syncs fingerprint and uid tables with Debian LDAP db"),
124 ("import-users-from-passwd",
125 "Sync PostgreSQL users with passwd file"),
127 "Perform administration on the dak database"),
129 "Updates databae schema to latest revision"),
131 "Initial setup of the archive"),
133 "Generates Maintainers file for BTS etc"),
135 "Generates override files"),
137 "Move packages from dists/ to pool/"),
138 ("new-security-install",
139 "New way to install a security upload into the archive"),
141 "Split queue/done into a date-based hierarchy"),
143 "Generate statistics"),
145 "Categorize uncategorized bugs filed against ftp.debian.org"),
146 ("import-known-changes",
147 "import old changes files into known_changes table"),
149 "Add a user to the archive"),
151 "Generate changelog between two suites"),
153 "Copies the installer from one suite to another"),
154 ("override-disparity",
155 "Generate a list of override disparities"),
156 ("external-overrides",
157 "Modify external overrides"),
161 ################################################################################
163 def usage(functionality, exit_code=0):
164 """Print a usage message and exit with 'exit_code'."""
166 print """Usage: dak COMMAND [...]
167 Run DAK commands. (Will also work if invoked as COMMAND.)
169 Available commands:"""
170 for (command, description) in functionality:
171 print " %-23s %s" % (command, description)
174 ################################################################################
177 """Launch dak functionality."""
181 logger = Logger('dak top-level', print_starting=False)
182 except CantOpenError:
185 functionality = init()
186 modules = [ command for (command, _) in functionality ]
188 if len(sys.argv) == 0:
189 daklib.utils.fubar("err, argc == 0? how is that possible?")
190 elif (len(sys.argv) == 1
191 or (len(sys.argv) == 2 and
192 (sys.argv[1] == "--help" or sys.argv[1] == "-h"))):
195 # First see if we were invoked with/as the name of a module
196 cmdname = sys.argv[0]
197 cmdname = cmdname[cmdname.rfind("/")+1:]
198 if cmdname in modules:
200 # Otherwise the argument is the module
202 cmdname = sys.argv[1]
203 sys.argv = [sys.argv[0] + " " + sys.argv[1]] + sys.argv[2:]
204 if cmdname not in modules:
207 if name.startswith(cmdname):
212 daklib.utils.warn("ambiguous command '%s' - could be %s" \
213 % (cmdname, ", ".join(match)))
214 usage(functionality, 1)
216 daklib.utils.warn("unknown command '%s'" % (cmdname))
217 usage(functionality, 1)
220 module = __import__(cmdname.replace("-","_"))
224 except KeyboardInterrupt:
225 msg = 'KeyboardInterrupt caught; exiting'
234 for line in traceback.format_exc().split('\n')[:-1]:
235 logger.log(['exception', line])
238 ################################################################################
240 if __name__ == "__main__":
241 os.environ['LANG'] = 'C'
242 os.environ['LC_ALL'] = 'C'