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 ################################################################################
39 import daklib.extensions
41 ################################################################################
44 def __init__(self, user_extension = None):
46 m = imp.load_source("dak_userext", user_extension)
50 self.__dict__["_module"] = m
51 self.__dict__["_d"] = d
53 def __getattr__(self, a):
54 if a in self.__dict__: return self.__dict__[a]
55 if a[0] == "_": raise AttributeError, a
56 return self._d.get(a, None)
58 def __setattr__(self, a, v):
61 ################################################################################
64 def __init__(self, user_extension = None):
66 m = imp.load_source("dak_userext", user_extension)
70 self.__dict__["_module"] = m
71 self.__dict__["_d"] = d
73 def __getattr__(self, a):
74 if a in self.__dict__: return self.__dict__[a]
75 if a[0] == "_": raise AttributeError, a
76 return self._d.get(a, None)
78 def __setattr__(self, a, v):
81 ################################################################################
84 """Setup the list of modules and brief explanation of what they
89 "Show which suites packages are in"),
91 "Query/change the overrides"),
93 "Archive sanity checks"),
95 "Produce a report on NEW and BYHAND packages"),
97 "Output html for packages in NEW"),
99 "Output html and symlinks for packages in DEFERRED"),
102 "Remove packages from suites"),
105 "Process NEW and BYHAND packages"),
106 ("process-unchecked",
107 "Process packages in queue/unchecked"),
109 "Install packages into the pool"),
111 ("make-suite-file-list",
112 "Generate lists of packages per suite for apt-ftparchive"),
113 ("make-pkg-file-mapping",
114 "Generate package <-> file mapping"),
115 ("generate-releases",
116 "Generate Release files"),
118 "Generate content files"),
119 ("generate-index-diffs",
120 "Generate .diff/Index files"),
122 "Clean unused/superseded packages from the archive"),
124 "Clean cruft from incoming"),
125 ("clean-proposed-updates",
126 "Remove obsolete .changes from proposed-updates"),
129 "Manage the release transition file"),
131 "Override cruft checks"),
132 ("check-proposed-updates",
133 "Dependency checking for proposed-updates"),
135 "Show fixable discrepencies between suites"),
136 ("control-overrides",
137 "Manipulate/list override entries in bulk"),
139 "Manipulate suites in bulk"),
141 "Check for obsolete or duplicated packages"),
143 "Display contents of a .dak file"),
145 "Show information useful for NEW processing"),
146 ("find-null-maintainers",
147 "Check for users with no packages in the archive"),
149 "Populate SQL database based from an archive tree"),
151 "Populate fingerprint/uid table based on a new/updated keyring"),
152 ("import-ldap-fingerprints",
153 "Syncs fingerprint and uid tables with Debian LDAP db"),
154 ("import-users-from-passwd",
155 "Sync PostgreSQL users with passwd file"),
157 "Update the database to match the conf file"),
159 "Updates databae schema to latest revision"),
161 "Initial setup of the archive"),
163 "Generates Maintainers file for BTS etc"),
165 "Generates override files"),
167 "Move packages from dists/ to pool/"),
168 ("reject-proposed-updates",
169 "Manually reject from proposed-updates"),
170 ("new-security-install",
171 "New way to install a security upload into the archive"),
173 "Split queue/done into a date-based hierarchy"),
175 "Generate statistics"),
177 "Categorize uncategorized bugs filed against ftp.debian.org"),
179 "Add a user to the archive"),
183 ################################################################################
185 def usage(functionality, exit_code=0):
186 """Print a usage message and exit with 'exit_code'."""
188 print """Usage: dak COMMAND [...]
189 Run DAK commands. (Will also work if invoked as COMMAND.)
191 Available commands:"""
192 for (command, description) in functionality:
193 print " %-23s %s" % (command, description)
196 ################################################################################
199 """Launch dak functionality."""
201 Cnf = daklib.utils.get_conf()
203 if Cnf.has_key("Dinstall::UserExtensions"):
204 userext = UserExtension(Cnf["Dinstall::UserExtensions"])
206 userext = UserExtension()
208 functionality = init()
209 modules = [ command for (command, _) in functionality ]
211 if len(sys.argv) == 0:
212 daklib.utils.fubar("err, argc == 0? how is that possible?")
213 elif (len(sys.argv) == 1
214 or (len(sys.argv) == 2 and
215 (sys.argv[1] == "--help" or sys.argv[1] == "-h"))):
218 # First see if we were invoked with/as the name of a module
219 cmdname = sys.argv[0]
220 cmdname = cmdname[cmdname.rfind("/")+1:]
221 if cmdname in modules:
223 # Otherwise the argument is the module
225 cmdname = sys.argv[1]
226 sys.argv = [sys.argv[0] + " " + sys.argv[1]] + sys.argv[2:]
227 if cmdname not in modules:
230 if name.startswith(cmdname):
235 daklib.utils.warn("ambiguous command '%s' - could be %s" \
236 % (cmdname, ", ".join(match)))
237 usage(functionality, 1)
239 daklib.utils.warn("unknown command '%s'" % (cmdname))
240 usage(functionality, 1)
243 module = __import__(cmdname.replace("-","_"))
245 module.dak_userext = userext
246 userext.dak_module = module
248 daklib.extensions.init(cmdname, module, userext)
249 if userext.init is not None: userext.init(cmdname)
253 ################################################################################
255 if __name__ == "__main__":