1
2
3 """
4 Wrapper to launch dak functionality
5
6 G{importgraph}
7
8 """
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 import importlib
37 import os
38 import sys
39 import traceback
40
41 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
42
43 import daklib.utils
44
45 from daklib.daklog import Logger
46
47
48
49
51 """Setup the list of modules and brief explanation of what they
52 do."""
53
54 functionality = [
55 ("ls",
56 "Show which suites packages are in"),
57 ("override",
58 "Query/change the overrides"),
59 ("check-archive",
60 "Archive sanity checks"),
61 ("queue-report",
62 "Produce a report on NEW and BYHAND packages"),
63 ("show-new",
64 "Output html for packages in NEW"),
65 ("show-deferred",
66 "Output html and symlinks for packages in DEFERRED"),
67 ("graph",
68 "Output graphs of number of packages in various queues"),
69
70 ("rm",
71 "Remove packages from suites"),
72
73 ("process-new",
74 "Process NEW and BYHAND packages"),
75 ("process-upload",
76 "Process packages in queue/unchecked"),
77 ("process-commands",
78 "Process command files (*.dak-commands)"),
79 ("process-policy",
80 "Process packages in policy queues from COMMENTS files"),
81
82 ("dominate",
83 "Remove obsolete source and binary associations from suites"),
84 ("export",
85 "Export uploads from policy queues"),
86 ("export-suite",
87 "export a suite to a flat directory structure"),
88 ("make-pkg-file-mapping",
89 "Generate package <-> file mapping"),
90 ("generate-releases",
91 "Generate Release files"),
92 ("generate-packages-sources2",
93 "Generate Packages/Sources files"),
94 ("contents",
95 "Generate content files"),
96 ("metadata",
97 "Load data for packages/sources files"),
98 ("generate-index-diffs",
99 "Generate .diff/Index files"),
100 ("clean-suites",
101 "Clean unused/superseded packages from the archive"),
102 ("manage-build-queues",
103 "Clean and update metadata for build queues"),
104 ("manage-debug-suites",
105 "Clean obsolete packages from debug suites"),
106 ("manage-external-signature-requests",
107 "Maintain external signature requests"),
108 ("clean-queues",
109 "Clean cruft from incoming"),
110 ("archive-dedup-pool",
111 "De-duplicates files in the pool directory"),
112
113 ("transitions",
114 "Manage the release transition file"),
115 ("check-overrides",
116 "Override cruft checks"),
117 ("control-overrides",
118 "Manipulate/list override entries in bulk"),
119 ("control-suite",
120 "Manipulate suites in bulk"),
121 ("update-suite",
122 "Update suite with packages from a different suite"),
123 ("cruft-report",
124 "Check for obsolete or duplicated packages"),
125 ("auto-decruft",
126 "Clean cruft without reverse dependencies automatically"),
127 ("examine-package",
128 "Show information useful for NEW processing"),
129 ("import",
130 "Import existing source and binary packages"),
131 ("import-repository",
132 "Import packages from another repository"),
133 ("import-keyring",
134 "Populate fingerprint/uid table based on a new/updated keyring"),
135 ("import-users-from-passwd",
136 "Sync PostgreSQL users with passwd file"),
137 ("acl",
138 "Manage upload ACLs"),
139 ("admin",
140 "Perform administration on the dak database"),
141 ("update-db",
142 "Updates databae schema to latest revision"),
143 ("init-dirs",
144 "Initial setup of the archive"),
145 ("make-maintainers",
146 "Generates Maintainers file for BTS etc"),
147 ("make-overrides",
148 "Generates override files"),
149 ("new-security-install",
150 "New way to install a security upload into the archive"),
151 ("stats",
152 "Generate statistics"),
153 ("bts-categorize",
154 "Categorize uncategorized bugs filed against ftp.debian.org"),
155 ("add-user",
156 "Add a user to the archive"),
157 ("make-changelog",
158 "Generate changelog between two suites"),
159 ("copy-installer",
160 "Copies the installer from one suite to another"),
161 ("external-overrides",
162 "Modify external overrides"),
163 ("write-sections",
164 "Write out section descriptions"),
165 ]
166 return functionality
167
168
169
170
171 -def usage(functionality, exit_code=0):
172 """Print a usage message and exit with 'exit_code'."""
173
174 print("""Usage: dak COMMAND [...]
175 Run DAK commands. (Will also work if invoked as COMMAND.)
176
177 Available commands:""")
178 for (command, description) in functionality:
179 print(" %-23s %s" % (command, description))
180 sys.exit(exit_code)
181
182
183
184
186 """Launch dak functionality."""
187
188 try:
189 logger = Logger('dak top-level', print_starting=False)
190 except OSError:
191 logger = None
192
193 functionality = init()
194 modules = [command for (command, _) in functionality]
195
196 if len(sys.argv) == 0:
197 daklib.utils.fubar("err, argc == 0? how is that possible?")
198 elif (len(sys.argv) == 1
199 or (len(sys.argv) == 2
200 and (sys.argv[1] == "--help" or sys.argv[1] == "-h"))):
201 usage(functionality)
202
203
204 cmdname = sys.argv[0]
205 cmdname = cmdname[cmdname.rfind("/") + 1:]
206 if cmdname in modules:
207 pass
208
209 else:
210 cmdname = sys.argv[1]
211 sys.argv = [sys.argv[0] + " " + sys.argv[1]] + sys.argv[2:]
212 if cmdname not in modules:
213 match = []
214 for name in modules:
215 if name.startswith(cmdname):
216 match.append(name)
217 if len(match) == 1:
218 cmdname = match[0]
219 elif len(match) > 1:
220 daklib.utils.warn("ambiguous command '%s' - could be %s"
221 % (cmdname, ", ".join(match)))
222 usage(functionality, 1)
223 else:
224 daklib.utils.warn("unknown command '%s'" % (cmdname))
225 usage(functionality, 1)
226
227
228 module = importlib.import_module("dak.{}".format(cmdname.replace("-", "_")))
229
230 try:
231 module.main()
232 except KeyboardInterrupt:
233 msg = 'KeyboardInterrupt caught; exiting'
234 print(msg)
235 if logger:
236 logger.log([msg])
237 sys.exit(1)
238 except SystemExit:
239 raise
240 except:
241 if logger:
242 for line in traceback.format_exc().split('\n')[:-1]:
243 logger.log(['exception', line])
244 raise
245
246
247
248
249 if __name__ == "__main__":
250 os.environ['LANG'] = 'C'
251 os.environ['LC_ALL'] = 'C'
252 main()
253