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 ################################################################################
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 """Setup the list of modules and brief explanation of what they
62 "Show which suites packages are in"),
64 "Query/change the overrides"),
66 "Archive sanity checks"),
68 "Produce a report on NEW and BYHAND packages"),
70 "Output html for packages in NEW"),
73 "Remove packages from suites"),
76 "Process NEW and BYHAND packages"),
78 "Process packages in queue/unchecked"),
80 "Install packages into the pool"),
82 ("make-suite-file-list",
83 "Generate lists of packages per suite for apt-ftparchive"),
85 "Generate Release files"),
86 ("generate-index-diffs",
87 "Generate .diff/Index files"),
89 "Clean unused/superseded packages from the archive"),
91 "Clean cruft from incoming"),
92 ("clean-proposed-updates",
93 "Remove obsolete .changes from proposed-updates"),
96 "Override cruft checks"),
97 ("check-proposed-updates",
98 "Dependency checking for proposed-updates"),
100 "Show fixable discrepencies between suites"),
101 ("control-overrides",
102 "Manipulate/list override entries in bulk"),
104 "Manipulate suites in bulk"),
106 "Check for obsolete or duplicated packages"),
108 "Display contents of a .dak file"),
110 "Show information useful for NEW processing"),
111 ("find-null-maintainers",
112 "Check for users with no packages in the archive"),
114 "Populate SQL database based from an archive tree"),
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 "Update the database to match the conf file"),
124 "Initial setup of the archive"),
126 "Generates Maintainers file for BTS etc"),
128 "Generates override files"),
130 "Split the pool/ by architecture groups"),
132 "Move packages from dists/ to pool/"),
133 ("reject-proposed-updates",
134 "Manually reject from proposed-updates"),
136 "Install a security upload into the archive"),
137 ("new-security-install",
138 "New way to install a security upload into the archive"),
140 "Split queue/done into a date-based hierarchy"),
142 "Generate statistics"),
144 "Generate compatability symlinks from dists/ into pool/"),
148 ################################################################################
150 def usage(functionality, exit_code=0):
151 """Print a usage message and exit with 'exit_code'."""
153 print """Usage: dak COMMAND [...]
154 Run DAK commands. (Will also work if invoked as COMMAND.)
156 Availble commands:"""
157 for (command, description) in functionality:
158 print " %-23s %s" % (command, description)
161 ################################################################################
164 """Launch dak functionality."""
166 Cnf = daklib.utils.get_conf()
168 if Cnf.has_key("Dinstall::UserExtensions"):
169 userext = UserExtension(Cnf["Dinstall::UserExtensions"])
171 userext = UserExtension()
173 functionality = init()
174 modules = [ command for (command, _) in functionality ]
176 if len(sys.argv) == 0:
177 daklib.utils.fubar("err, argc == 0? how is that possible?")
178 elif (len(sys.argv) == 1
179 or (len(sys.argv) == 2 and
180 (sys.argv[1] == "--help" or sys.argv[1] == "-h"))):
183 # First see if we were invoked with/as the name of a module
184 cmdname = sys.argv[0]
185 cmdname = cmdname[cmdname.rfind("/")+1:]
186 if cmdname in modules:
188 # Otherwise the argument is the module
190 cmdname = sys.argv[1]
191 sys.argv = [sys.argv[0] + " " + sys.argv[1]] + sys.argv[2:]
192 if cmdname not in modules:
195 if name.startswith(cmdname):
200 daklib.utils.warn("ambiguous command '%s' - could be %s" \
201 % (cmdname, ", ".join(match)))
202 usage(functionality, 1)
204 daklib.utils.warn("unknown command '%s'" % (cmdname))
205 usage(functionality, 1)
208 module = __import__(cmdname.replace("-","_"))
210 module.dak_userext = userext
211 userext.dak_module = module
212 if userext.init is not None: userext.init(cmdname)
216 ################################################################################
218 if __name__ == "__main__":