3 """Wrapper to launch dak functionality"""
4 # Copyright (C) 2005, 2006 Anthony Towns <ajt@debian.org>
5 # Copyright (C) 2006 James Troup <james@nocrew.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 ################################################################################
23 # well I don't know where you're from but in AMERICA, there's a little
24 # thing called "abstinent until proven guilty."
25 # -- http://harrietmiers.blogspot.com/2005/10/wow-i-feel-loved.html
27 # (if James had a blog, I bet I could find a funny quote in it to use!)
29 ################################################################################
32 import daklib.utils, daklib.extensions
34 ################################################################################
37 def __init__(self, user_extension = None):
39 m = imp.load_source("dak_userext", user_extension)
43 self.__dict__["_module"] = m
44 self.__dict__["_d"] = d
46 def __getattr__(self, a):
47 if a in self.__dict__: return self.__dict__[a]
48 if a[0] == "_": raise AttributeError, a
49 return self._d.get(a, None)
51 def __setattr__(self, a, v):
54 ################################################################################
57 def __init__(self, user_extension = None):
59 m = imp.load_source("dak_userext", user_extension)
63 self.__dict__["_module"] = m
64 self.__dict__["_d"] = d
66 def __getattr__(self, a):
67 if a in self.__dict__: return self.__dict__[a]
68 if a[0] == "_": raise AttributeError, a
69 return self._d.get(a, None)
71 def __setattr__(self, a, v):
74 ################################################################################
77 """Setup the list of modules and brief explanation of what they
82 "Show which suites packages are in"),
84 "Query/change the overrides"),
86 "Archive sanity checks"),
88 "Produce a report on NEW and BYHAND packages"),
90 "Output html for packages in NEW"),
92 "Output html and symlinks for packages in DEFERRED"),
95 "Remove packages from suites"),
98 "Process NEW and BYHAND packages"),
100 "Process packages in queue/unchecked"),
102 "Install packages into the pool"),
104 ("make-suite-file-list",
105 "Generate lists of packages per suite for apt-ftparchive"),
106 ("generate-releases",
107 "Generate Release files"),
108 ("generate-contents",
109 "Generate contest files"),
110 ("generate-index-diffs",
111 "Generate .diff/Index files"),
113 "Clean unused/superseded packages from the archive"),
115 "Clean cruft from incoming"),
116 ("clean-proposed-updates",
117 "Remove obsolete .changes from proposed-updates"),
120 "Manage the release transition file"),
122 "Override cruft checks"),
123 ("check-proposed-updates",
124 "Dependency checking for proposed-updates"),
126 "Show fixable discrepencies between suites"),
127 ("control-overrides",
128 "Manipulate/list override entries in bulk"),
130 "Manipulate suites in bulk"),
132 "Check for obsolete or duplicated packages"),
134 "Display contents of a .dak file"),
136 "Show information useful for NEW processing"),
137 ("find-null-maintainers",
138 "Check for users with no packages in the archive"),
140 "Populate SQL database based from an archive tree"),
142 "Populate SQL database with Contents files"),
144 "Populate fingerprint/uid table based on a new/updated keyring"),
145 ("import-ldap-fingerprints",
146 "Syncs fingerprint and uid tables with Debian LDAP db"),
147 ("import-users-from-passwd",
148 "Sync PostgreSQL users with passwd file"),
150 "Update the database to match the conf file"),
152 "Updates databae schema to latest revision"),
154 "Initial setup of the archive"),
156 "Generates Maintainers file for BTS etc"),
158 "Generates override files"),
160 "Split the pool/ by architecture groups"),
162 "Move packages from dists/ to pool/"),
163 ("reject-proposed-updates",
164 "Manually reject from proposed-updates"),
165 ("new-security-install",
166 "New way to install a security upload into the archive"),
168 "Split queue/done into a date-based hierarchy"),
170 "Generate statistics"),
174 ################################################################################
176 def usage(functionality, exit_code=0):
177 """Print a usage message and exit with 'exit_code'."""
179 print """Usage: dak COMMAND [...]
180 Run DAK commands. (Will also work if invoked as COMMAND.)
182 Available commands:"""
183 for (command, description) in functionality:
184 print " %-23s %s" % (command, description)
187 ################################################################################
190 """Launch dak functionality."""
192 Cnf = daklib.utils.get_conf()
194 if Cnf.has_key("Dinstall::UserExtensions"):
195 userext = UserExtension(Cnf["Dinstall::UserExtensions"])
197 userext = UserExtension()
199 functionality = init()
200 modules = [ command for (command, _) in functionality ]
202 if len(sys.argv) == 0:
203 daklib.utils.fubar("err, argc == 0? how is that possible?")
204 elif (len(sys.argv) == 1
205 or (len(sys.argv) == 2 and
206 (sys.argv[1] == "--help" or sys.argv[1] == "-h"))):
209 # First see if we were invoked with/as the name of a module
210 cmdname = sys.argv[0]
211 cmdname = cmdname[cmdname.rfind("/")+1:]
212 if cmdname in modules:
214 # Otherwise the argument is the module
216 cmdname = sys.argv[1]
217 sys.argv = [sys.argv[0] + " " + sys.argv[1]] + sys.argv[2:]
218 if cmdname not in modules:
221 if name.startswith(cmdname):
226 daklib.utils.warn("ambiguous command '%s' - could be %s" \
227 % (cmdname, ", ".join(match)))
228 usage(functionality, 1)
230 daklib.utils.warn("unknown command '%s'" % (cmdname))
231 usage(functionality, 1)
234 module = __import__(cmdname.replace("-","_"))
236 module.dak_userext = userext
237 userext.dak_module = module
239 daklib.extensions.init(cmdname, module, userext)
240 if userext.init is not None: userext.init(cmdname)
244 ################################################################################
246 if __name__ == "__main__":