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 ################################################################################
37 import daklib.utils, daklib.extensions
39 ################################################################################
42 def __init__(self, user_extension = None):
44 m = imp.load_source("dak_userext", user_extension)
48 self.__dict__["_module"] = m
49 self.__dict__["_d"] = d
51 def __getattr__(self, a):
52 if a in self.__dict__: return self.__dict__[a]
53 if a[0] == "_": raise AttributeError, a
54 return self._d.get(a, None)
56 def __setattr__(self, a, v):
59 ################################################################################
62 def __init__(self, user_extension = None):
64 m = imp.load_source("dak_userext", user_extension)
68 self.__dict__["_module"] = m
69 self.__dict__["_d"] = d
71 def __getattr__(self, a):
72 if a in self.__dict__: return self.__dict__[a]
73 if a[0] == "_": raise AttributeError, a
74 return self._d.get(a, None)
76 def __setattr__(self, a, v):
79 ################################################################################
82 """Setup the list of modules and brief explanation of what they
87 "Show which suites packages are in"),
89 "Query/change the overrides"),
91 "Archive sanity checks"),
93 "Produce a report on NEW and BYHAND packages"),
95 "Output html for packages in NEW"),
97 "Output html and symlinks for packages in DEFERRED"),
100 "Remove packages from suites"),
103 "Process NEW and BYHAND packages"),
104 ("process-unchecked",
105 "Process packages in queue/unchecked"),
107 "Install packages into the pool"),
109 ("make-suite-file-list",
110 "Generate lists of packages per suite for apt-ftparchive"),
111 ("make-pkg-file-mapping",
112 "Generate package <-> file mapping"),
113 ("generate-releases",
114 "Generate Release files"),
115 ("generate-index-diffs",
116 "Generate .diff/Index files"),
118 "Clean unused/superseded packages from the archive"),
120 "Clean cruft from incoming"),
121 ("clean-proposed-updates",
122 "Remove obsolete .changes from proposed-updates"),
125 "Manage the release transition file"),
127 "Override cruft checks"),
128 ("check-proposed-updates",
129 "Dependency checking for proposed-updates"),
131 "Show fixable discrepencies between suites"),
132 ("control-overrides",
133 "Manipulate/list override entries in bulk"),
135 "Manipulate suites in bulk"),
137 "Check for obsolete or duplicated packages"),
139 "Display contents of a .dak file"),
141 "Show information useful for NEW processing"),
142 ("find-null-maintainers",
143 "Check for users with no packages in the archive"),
145 "Populate SQL database based from an archive tree"),
147 "Populate fingerprint/uid table based on a new/updated keyring"),
148 ("import-ldap-fingerprints",
149 "Syncs fingerprint and uid tables with Debian LDAP db"),
150 ("import-users-from-passwd",
151 "Sync PostgreSQL users with passwd file"),
153 "Update the database to match the conf file"),
155 "Updates databae schema to latest revision"),
157 "Initial setup of the archive"),
159 "Generates Maintainers file for BTS etc"),
161 "Generates override files"),
163 "Move packages from dists/ to pool/"),
164 ("reject-proposed-updates",
165 "Manually reject from proposed-updates"),
166 ("new-security-install",
167 "New way to install a security upload into the archive"),
169 "Split queue/done into a date-based hierarchy"),
171 "Generate statistics"),
173 "Categorize uncategorized bugs filed against ftp.debian.org"),
177 ################################################################################
179 def usage(functionality, exit_code=0):
180 """Print a usage message and exit with 'exit_code'."""
182 print """Usage: dak COMMAND [...]
183 Run DAK commands. (Will also work if invoked as COMMAND.)
185 Available commands:"""
186 for (command, description) in functionality:
187 print " %-23s %s" % (command, description)
190 ################################################################################
193 """Launch dak functionality."""
195 Cnf = daklib.utils.get_conf()
197 if Cnf.has_key("Dinstall::UserExtensions"):
198 userext = UserExtension(Cnf["Dinstall::UserExtensions"])
200 userext = UserExtension()
202 functionality = init()
203 modules = [ command for (command, _) in functionality ]
205 if len(sys.argv) == 0:
206 daklib.utils.fubar("err, argc == 0? how is that possible?")
207 elif (len(sys.argv) == 1
208 or (len(sys.argv) == 2 and
209 (sys.argv[1] == "--help" or sys.argv[1] == "-h"))):
212 # First see if we were invoked with/as the name of a module
213 cmdname = sys.argv[0]
214 cmdname = cmdname[cmdname.rfind("/")+1:]
215 if cmdname in modules:
217 # Otherwise the argument is the module
219 cmdname = sys.argv[1]
220 sys.argv = [sys.argv[0] + " " + sys.argv[1]] + sys.argv[2:]
221 if cmdname not in modules:
224 if name.startswith(cmdname):
229 daklib.utils.warn("ambiguous command '%s' - could be %s" \
230 % (cmdname, ", ".join(match)))
231 usage(functionality, 1)
233 daklib.utils.warn("unknown command '%s'" % (cmdname))
234 usage(functionality, 1)
237 module = __import__(cmdname.replace("-","_"))
239 module.dak_userext = userext
240 userext.dak_module = module
242 daklib.extensions.init(cmdname, module, userext)
243 if userext.init is not None: userext.init(cmdname)
247 ################################################################################
249 if __name__ == "__main__":