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 ("generate-releases",
112 "Generate Release files"),
113 ("generate-index-diffs",
114 "Generate .diff/Index files"),
116 "Clean unused/superseded packages from the archive"),
118 "Clean cruft from incoming"),
119 ("clean-proposed-updates",
120 "Remove obsolete .changes from proposed-updates"),
123 "Manage the release transition file"),
125 "Override cruft checks"),
126 ("check-proposed-updates",
127 "Dependency checking for proposed-updates"),
129 "Show fixable discrepencies between suites"),
130 ("control-overrides",
131 "Manipulate/list override entries in bulk"),
133 "Manipulate suites in bulk"),
135 "Check for obsolete or duplicated packages"),
137 "Display contents of a .dak file"),
139 "Show information useful for NEW processing"),
140 ("find-null-maintainers",
141 "Check for users with no packages in the archive"),
143 "Populate SQL database based from an archive tree"),
145 "Populate fingerprint/uid table based on a new/updated keyring"),
146 ("import-ldap-fingerprints",
147 "Syncs fingerprint and uid tables with Debian LDAP db"),
148 ("import-users-from-passwd",
149 "Sync PostgreSQL users with passwd file"),
151 "Update the database to match the conf file"),
153 "Updates databae schema to latest revision"),
155 "Initial setup of the archive"),
157 "Generates Maintainers file for BTS etc"),
159 "Generates override files"),
161 "Move packages from dists/ to pool/"),
162 ("reject-proposed-updates",
163 "Manually reject from proposed-updates"),
164 ("new-security-install",
165 "New way to install a security upload into the archive"),
167 "Split queue/done into a date-based hierarchy"),
169 "Generate statistics"),
171 "Categorize uncategorized bugs filed against ftp.debian.org"),
175 ################################################################################
177 def usage(functionality, exit_code=0):
178 """Print a usage message and exit with 'exit_code'."""
180 print """Usage: dak COMMAND [...]
181 Run DAK commands. (Will also work if invoked as COMMAND.)
183 Available commands:"""
184 for (command, description) in functionality:
185 print " %-23s %s" % (command, description)
188 ################################################################################
191 """Launch dak functionality."""
193 Cnf = daklib.utils.get_conf()
195 if Cnf.has_key("Dinstall::UserExtensions"):
196 userext = UserExtension(Cnf["Dinstall::UserExtensions"])
198 userext = UserExtension()
200 functionality = init()
201 modules = [ command for (command, _) in functionality ]
203 if len(sys.argv) == 0:
204 daklib.utils.fubar("err, argc == 0? how is that possible?")
205 elif (len(sys.argv) == 1
206 or (len(sys.argv) == 2 and
207 (sys.argv[1] == "--help" or sys.argv[1] == "-h"))):
210 # First see if we were invoked with/as the name of a module
211 cmdname = sys.argv[0]
212 cmdname = cmdname[cmdname.rfind("/")+1:]
213 if cmdname in modules:
215 # Otherwise the argument is the module
217 cmdname = sys.argv[1]
218 sys.argv = [sys.argv[0] + " " + sys.argv[1]] + sys.argv[2:]
219 if cmdname not in modules:
222 if name.startswith(cmdname):
227 daklib.utils.warn("ambiguous command '%s' - could be %s" \
228 % (cmdname, ", ".join(match)))
229 usage(functionality, 1)
231 daklib.utils.warn("unknown command '%s'" % (cmdname))
232 usage(functionality, 1)
235 module = __import__(cmdname.replace("-","_"))
237 module.dak_userext = userext
238 userext.dak_module = module
240 daklib.extensions.init(cmdname, module, userext)
241 if userext.init is not None: userext.init(cmdname)
245 ################################################################################
247 if __name__ == "__main__":