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 ################################################################################
42 from daklib.daklog import Logger
43 from daklib.config import Config
44 from daklib.dak_exceptions import CantOpenError
46 ################################################################################
49 """Setup the list of modules and brief explanation of what they
54 "Show which suites packages are in"),
56 "Query/change the overrides"),
58 "Archive sanity checks"),
60 "Produce a report on NEW and BYHAND packages"),
62 "Output html for packages in NEW"),
64 "Output html and symlinks for packages in DEFERRED"),
67 "Remove packages from suites"),
70 "Process NEW and BYHAND packages"),
72 "Process packages in queue/unchecked"),
74 "Process packages in policy queues from COMMENTS files"),
77 "Remove obsolete source and binary associations from suites"),
78 ("make-pkg-file-mapping",
79 "Generate package <-> file mapping"),
81 "Generate file lists for apt-ftparchive"),
83 "Generate Release files"),
85 "Generate content files"),
86 ("generate-index-diffs",
87 "Generate .diff/Index files"),
89 "Clean unused/superseded packages from the archive"),
90 ("manage-build-queues",
91 "Clean and update metadata for build queues"),
93 "Clean cruft from incoming"),
94 ("clean-proposed-updates",
95 "Remove obsolete .changes from proposed-updates"),
98 "Manage the release transition file"),
100 "Override cruft checks"),
101 ("check-proposed-updates",
102 "Dependency checking for proposed-updates"),
103 ("control-overrides",
104 "Manipulate/list override entries in bulk"),
106 "Manipulate suites in bulk"),
108 "Check for obsolete or duplicated packages"),
110 "Display contents of a .dak file"),
112 "Show information useful for NEW processing"),
113 ("find-null-maintainers",
114 "Check for users with no packages in the archive"),
116 "Populate fingerprint/uid table based on a new/updated keyring"),
117 ("import-ldap-fingerprints",
118 "Syncs fingerprint and uid tables with Debian LDAP db"),
119 ("import-users-from-passwd",
120 "Sync PostgreSQL users with passwd file"),
122 "Perform administration on the dak database"),
124 "Update the database to match the conf file"),
126 "Updates databae schema to latest revision"),
128 "Initial setup of the archive"),
130 "Generates Maintainers file for BTS etc"),
132 "Generates override files"),
134 "Move packages from dists/ to pool/"),
135 ("new-security-install",
136 "New way to install a security upload into the archive"),
138 "Split queue/done into a date-based hierarchy"),
140 "Generate statistics"),
142 "Categorize uncategorized bugs filed against ftp.debian.org"),
143 ("import-known-changes",
144 "import old changes files into known_changes table"),
146 "Add a user to the archive"),
148 "Generate changelog between two suites"),
152 ################################################################################
154 def usage(functionality, exit_code=0):
155 """Print a usage message and exit with 'exit_code'."""
157 print """Usage: dak COMMAND [...]
158 Run DAK commands. (Will also work if invoked as COMMAND.)
160 Available commands:"""
161 for (command, description) in functionality:
162 print " %-23s %s" % (command, description)
165 ################################################################################
168 """Launch dak functionality."""
172 logger = Logger(Config(), 'dak top-level', print_starting=False)
173 except CantOpenError:
176 functionality = init()
177 modules = [ command for (command, _) in functionality ]
179 if len(sys.argv) == 0:
180 daklib.utils.fubar("err, argc == 0? how is that possible?")
181 elif (len(sys.argv) == 1
182 or (len(sys.argv) == 2 and
183 (sys.argv[1] == "--help" or sys.argv[1] == "-h"))):
186 # First see if we were invoked with/as the name of a module
187 cmdname = sys.argv[0]
188 cmdname = cmdname[cmdname.rfind("/")+1:]
189 if cmdname in modules:
191 # Otherwise the argument is the module
193 cmdname = sys.argv[1]
194 sys.argv = [sys.argv[0] + " " + sys.argv[1]] + sys.argv[2:]
195 if cmdname not in modules:
198 if name.startswith(cmdname):
203 daklib.utils.warn("ambiguous command '%s' - could be %s" \
204 % (cmdname, ", ".join(match)))
205 usage(functionality, 1)
207 daklib.utils.warn("unknown command '%s'" % (cmdname))
208 usage(functionality, 1)
210 # We do not care. No idea wth sqlalchemy warns about them, makes no sense,
212 warnings.filterwarnings("ignore", 'Predicate of partial index')
215 module = __import__(cmdname.replace("-","_"))
219 except KeyboardInterrupt:
220 msg = 'KeyboardInterrupt caught; exiting'
229 for line in traceback.format_exc().split('\n')[:-1]:
230 logger.log(['exception', line])
233 ################################################################################
235 if __name__ == "__main__":
236 os.environ['LANG'] = 'C'
237 os.environ['LC_ALL'] = 'C'