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