1 |
commit: 756c7cb0859b0e26e5c157032c8b7132036bd147 |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Jan 11 02:56:28 2013 +0000 |
4 |
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
5 |
CommitDate: Tue Dec 31 17:59:06 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=756c7cb0 |
7 |
|
8 |
Initial rearrangement of the python directories |
9 |
|
10 |
New minimal start script, moving the original catalyst script to catalyst/main.py. |
11 |
Add __init__.py's to modules and arch sub-pkgs. |
12 |
skip __init__.py when loading the modules. |
13 |
Update the module loading paths for the new locations. |
14 |
Fix catalyst_support import to new location and specify imported modules. |
15 |
|
16 |
--- |
17 |
bin/catalyst | 46 +++++++++++++++++++++ |
18 |
{modules => catalyst}/__init__.py | 0 |
19 |
catalyst/arch/__init__.py | 1 + |
20 |
{arch => catalyst/arch}/alpha.py | 0 |
21 |
{arch => catalyst/arch}/amd64.py | 0 |
22 |
{arch => catalyst/arch}/arm.py | 0 |
23 |
{arch => catalyst/arch}/hppa.py | 0 |
24 |
{arch => catalyst/arch}/ia64.py | 0 |
25 |
{arch => catalyst/arch}/mips.py | 0 |
26 |
{arch => catalyst/arch}/powerpc.py | 0 |
27 |
{arch => catalyst/arch}/s390.py | 0 |
28 |
{arch => catalyst/arch}/sh.py | 0 |
29 |
{arch => catalyst/arch}/sparc.py | 0 |
30 |
{arch => catalyst/arch}/x86.py | 0 |
31 |
{modules/catalyst => catalyst}/config.py | 0 |
32 |
catalyst => catalyst/main.py | 47 +++++++++++++--------- |
33 |
catalyst/modules/__init__.py | 1 + |
34 |
{modules => catalyst/modules}/builder.py | 0 |
35 |
{modules => catalyst/modules}/catalyst_lock.py | 0 |
36 |
{modules => catalyst/modules}/catalyst_support.py | 0 |
37 |
{modules => catalyst/modules}/embedded_target.py | 0 |
38 |
.../modules}/generic_stage_target.py | 15 +++---- |
39 |
{modules => catalyst/modules}/generic_target.py | 0 |
40 |
{modules => catalyst/modules}/grp_target.py | 0 |
41 |
.../modules}/livecd_stage1_target.py | 0 |
42 |
.../modules}/livecd_stage2_target.py | 0 |
43 |
{modules => catalyst/modules}/netboot2_target.py | 0 |
44 |
{modules => catalyst/modules}/netboot_target.py | 0 |
45 |
{modules => catalyst/modules}/snapshot_target.py | 0 |
46 |
{modules => catalyst/modules}/stage1_target.py | 0 |
47 |
{modules => catalyst/modules}/stage2_target.py | 0 |
48 |
{modules => catalyst/modules}/stage3_target.py | 0 |
49 |
{modules => catalyst/modules}/stage4_target.py | 0 |
50 |
{modules => catalyst/modules}/tinderbox_target.py | 0 |
51 |
{modules/catalyst => catalyst}/util.py | 0 |
52 |
modules/catalyst/__init__.py | 0 |
53 |
36 files changed, 84 insertions(+), 26 deletions(-) |
54 |
|
55 |
diff --git a/bin/catalyst b/bin/catalyst |
56 |
new file mode 100755 |
57 |
index 0000000..a4e55db |
58 |
--- /dev/null |
59 |
+++ b/bin/catalyst |
60 |
@@ -0,0 +1,46 @@ |
61 |
+#!/usr/bin/python -OO |
62 |
+ |
63 |
+# Maintained in full by: |
64 |
+# Catalyst Team <catalyst@g.o> |
65 |
+# Release Engineering Team <releng@g.o> |
66 |
+# Andrew Gaffney <agaffney@g.o> |
67 |
+# Chris Gianelloni <wolf31o2@××××××××.org> |
68 |
+# $Id$ |
69 |
+ |
70 |
+ |
71 |
+from __future__ import print_function |
72 |
+ |
73 |
+import sys |
74 |
+ |
75 |
+__maintainer__="Catalyst <catalyst@g.o>" |
76 |
+__version__="2.0.12.2" |
77 |
+ |
78 |
+ |
79 |
+# This block ensures that ^C interrupts are handled quietly. |
80 |
+try: |
81 |
+ import signal |
82 |
+ |
83 |
+ def exithandler(signum,frame): |
84 |
+ signal.signal(signal.SIGINT, signal.SIG_IGN) |
85 |
+ signal.signal(signal.SIGTERM, signal.SIG_IGN) |
86 |
+ print() |
87 |
+ sys.exit(1) |
88 |
+ |
89 |
+ signal.signal(signal.SIGINT, exithandler) |
90 |
+ signal.signal(signal.SIGTERM, exithandler) |
91 |
+ signal.signal(signal.SIGPIPE, signal.SIG_DFL) |
92 |
+ |
93 |
+except KeyboardInterrupt: |
94 |
+ print() |
95 |
+ sys.exit(1) |
96 |
+ |
97 |
+ |
98 |
+from catalyst.main import main |
99 |
+ |
100 |
+try: |
101 |
+ main() |
102 |
+except KeyboardInterrupt: |
103 |
+ print("Aborted.") |
104 |
+ sys.exit(130) |
105 |
+sys.exit(0) |
106 |
+ |
107 |
|
108 |
diff --git a/modules/__init__.py b/catalyst/__init__.py |
109 |
similarity index 100% |
110 |
rename from modules/__init__.py |
111 |
rename to catalyst/__init__.py |
112 |
|
113 |
diff --git a/catalyst/arch/__init__.py b/catalyst/arch/__init__.py |
114 |
new file mode 100644 |
115 |
index 0000000..8b13789 |
116 |
--- /dev/null |
117 |
+++ b/catalyst/arch/__init__.py |
118 |
@@ -0,0 +1 @@ |
119 |
+ |
120 |
|
121 |
diff --git a/arch/alpha.py b/catalyst/arch/alpha.py |
122 |
similarity index 100% |
123 |
rename from arch/alpha.py |
124 |
rename to catalyst/arch/alpha.py |
125 |
|
126 |
diff --git a/arch/amd64.py b/catalyst/arch/amd64.py |
127 |
similarity index 100% |
128 |
rename from arch/amd64.py |
129 |
rename to catalyst/arch/amd64.py |
130 |
|
131 |
diff --git a/arch/arm.py b/catalyst/arch/arm.py |
132 |
similarity index 100% |
133 |
rename from arch/arm.py |
134 |
rename to catalyst/arch/arm.py |
135 |
|
136 |
diff --git a/arch/hppa.py b/catalyst/arch/hppa.py |
137 |
similarity index 100% |
138 |
rename from arch/hppa.py |
139 |
rename to catalyst/arch/hppa.py |
140 |
|
141 |
diff --git a/arch/ia64.py b/catalyst/arch/ia64.py |
142 |
similarity index 100% |
143 |
rename from arch/ia64.py |
144 |
rename to catalyst/arch/ia64.py |
145 |
|
146 |
diff --git a/arch/mips.py b/catalyst/arch/mips.py |
147 |
similarity index 100% |
148 |
rename from arch/mips.py |
149 |
rename to catalyst/arch/mips.py |
150 |
|
151 |
diff --git a/arch/powerpc.py b/catalyst/arch/powerpc.py |
152 |
similarity index 100% |
153 |
rename from arch/powerpc.py |
154 |
rename to catalyst/arch/powerpc.py |
155 |
|
156 |
diff --git a/arch/s390.py b/catalyst/arch/s390.py |
157 |
similarity index 100% |
158 |
rename from arch/s390.py |
159 |
rename to catalyst/arch/s390.py |
160 |
|
161 |
diff --git a/arch/sh.py b/catalyst/arch/sh.py |
162 |
similarity index 100% |
163 |
rename from arch/sh.py |
164 |
rename to catalyst/arch/sh.py |
165 |
|
166 |
diff --git a/arch/sparc.py b/catalyst/arch/sparc.py |
167 |
similarity index 100% |
168 |
rename from arch/sparc.py |
169 |
rename to catalyst/arch/sparc.py |
170 |
|
171 |
diff --git a/arch/x86.py b/catalyst/arch/x86.py |
172 |
similarity index 100% |
173 |
rename from arch/x86.py |
174 |
rename to catalyst/arch/x86.py |
175 |
|
176 |
diff --git a/modules/catalyst/config.py b/catalyst/config.py |
177 |
similarity index 100% |
178 |
rename from modules/catalyst/config.py |
179 |
rename to catalyst/config.py |
180 |
|
181 |
diff --git a/catalyst b/catalyst/main.py |
182 |
old mode 100755 |
183 |
new mode 100644 |
184 |
similarity index 91% |
185 |
rename from catalyst |
186 |
rename to catalyst/main.py |
187 |
index cb6c022..aebb495 |
188 |
--- a/catalyst |
189 |
+++ b/catalyst/main.py |
190 |
@@ -15,8 +15,14 @@ import getopt |
191 |
import pdb |
192 |
import os.path |
193 |
|
194 |
-import modules.catalyst.config |
195 |
-import modules.catalyst.util |
196 |
+__selfpath__ = os.path.abspath(os.path.dirname(__file__)) |
197 |
+ |
198 |
+sys.path.append(__selfpath__ + "/modules") |
199 |
+ |
200 |
+import catalyst.config |
201 |
+import catalyst.util |
202 |
+from catalyst.modules.catalyst_support import (required_build_targets, |
203 |
+ valid_build_targets, CatalystError, hash_map, find_binary, LockInUse) |
204 |
|
205 |
__maintainer__="Catalyst <catalyst@g.o>" |
206 |
__version__="2.0.15" |
207 |
@@ -102,7 +108,7 @@ def parse_config(myconfig): |
208 |
# now, try and parse the config file "config_file" |
209 |
try: |
210 |
# execfile(config_file, myconf, myconf) |
211 |
- myconfig = modules.catalyst.config.ConfigParser(config_file) |
212 |
+ myconfig = catalyst.config.ConfigParser(config_file) |
213 |
myconf.update(myconfig.get_values()) |
214 |
|
215 |
except: |
216 |
@@ -118,6 +124,9 @@ def parse_config(myconfig): |
217 |
print "Setting",x,"to default value \""+confdefaults[x]+"\"" |
218 |
conf_values[x]=confdefaults[x] |
219 |
|
220 |
+ # add our python base directory to use for loading target arch's |
221 |
+ conf_values["PythonDir"] = __selfpath__ |
222 |
+ |
223 |
# parse out the rest of the options from the config file |
224 |
if "autoresume" in string.split(conf_values["options"]): |
225 |
print "Autoresuming support enabled." |
226 |
@@ -191,30 +200,32 @@ def import_modules(): |
227 |
targetmap={} |
228 |
|
229 |
try: |
230 |
+ module_dir = __selfpath__ + "/modules/" |
231 |
for x in required_build_targets: |
232 |
try: |
233 |
- fh=open(conf_values["sharedir"]+"/modules/"+x+".py") |
234 |
- module=imp.load_module(x,fh,"modules/"+x+".py",(".py","r",imp.PY_SOURCE)) |
235 |
+ fh=open(module_dir + x + ".py") |
236 |
+ module=imp.load_module(x, fh,"modules/" + x + ".py", |
237 |
+ (".py", "r", imp.PY_SOURCE)) |
238 |
fh.close() |
239 |
|
240 |
except IOError: |
241 |
- raise CatalystError,"Can't find "+x+".py plugin in "+\ |
242 |
- conf_values["sharedir"]+"/modules/" |
243 |
- |
244 |
+ raise CatalystError, "Can't find " + x + ".py plugin in " + \ |
245 |
+ module_dir |
246 |
for x in valid_build_targets: |
247 |
try: |
248 |
- fh=open(conf_values["sharedir"]+"/modules/"+x+".py") |
249 |
- module=imp.load_module(x,fh,"modules/"+x+".py",(".py","r",imp.PY_SOURCE)) |
250 |
+ fh=open(module_dir + x + ".py") |
251 |
+ module=imp.load_module(x, fh, "modules/" + x + ".py", |
252 |
+ (".py", "r", imp.PY_SOURCE)) |
253 |
module.register(targetmap) |
254 |
fh.close() |
255 |
|
256 |
except IOError: |
257 |
- raise CatalystError,"Can't find "+x+".py plugin in "+\ |
258 |
- conf_values["sharedir"]+"/modules/" |
259 |
+ raise CatalystError,"Can't find " + x + ".py plugin in " + \ |
260 |
+ module_dir |
261 |
|
262 |
except ImportError: |
263 |
print "!!! catalyst: Python modules not found in "+\ |
264 |
- conf_values["sharedir"]+"/modules; exiting." |
265 |
+ module_dir + "; exiting." |
266 |
sys.exit(1) |
267 |
|
268 |
return targetmap |
269 |
@@ -229,11 +240,11 @@ def build_target(addlargs, targetmap): |
270 |
mytarget.run() |
271 |
|
272 |
except: |
273 |
- modules.catalyst.util.print_traceback() |
274 |
+ catalyst.util.print_traceback() |
275 |
print "!!! catalyst: Error encountered during run of target " + addlargs["target"] |
276 |
sys.exit(1) |
277 |
|
278 |
-if __name__ == "__main__": |
279 |
+def main(): |
280 |
targetmap={} |
281 |
|
282 |
version() |
283 |
@@ -334,8 +345,6 @@ if __name__ == "__main__": |
284 |
|
285 |
# import configuration file and import our main module using those settings |
286 |
parse_config(myconfig) |
287 |
- sys.path.append(conf_values["sharedir"]+"/modules") |
288 |
- from catalyst_support import * |
289 |
|
290 |
# Start checking that digests are valid now that the hash_map was imported |
291 |
# from catalyst_support |
292 |
@@ -382,12 +391,12 @@ if __name__ == "__main__": |
293 |
addlargs={} |
294 |
|
295 |
if myspecfile: |
296 |
- spec = modules.catalyst.config.SpecParser(myspecfile) |
297 |
+ spec = catalyst.config.SpecParser(myspecfile) |
298 |
addlargs.update(spec.get_values()) |
299 |
|
300 |
if mycmdline: |
301 |
try: |
302 |
- cmdline = modules.catalyst.config.ConfigParser() |
303 |
+ cmdline = catalyst.config.ConfigParser() |
304 |
cmdline.parse_lines(mycmdline) |
305 |
addlargs.update(cmdline.get_values()) |
306 |
except CatalystError: |
307 |
|
308 |
diff --git a/catalyst/modules/__init__.py b/catalyst/modules/__init__.py |
309 |
new file mode 100644 |
310 |
index 0000000..8b13789 |
311 |
--- /dev/null |
312 |
+++ b/catalyst/modules/__init__.py |
313 |
@@ -0,0 +1 @@ |
314 |
+ |
315 |
|
316 |
diff --git a/modules/builder.py b/catalyst/modules/builder.py |
317 |
similarity index 100% |
318 |
rename from modules/builder.py |
319 |
rename to catalyst/modules/builder.py |
320 |
|
321 |
diff --git a/modules/catalyst_lock.py b/catalyst/modules/catalyst_lock.py |
322 |
similarity index 100% |
323 |
rename from modules/catalyst_lock.py |
324 |
rename to catalyst/modules/catalyst_lock.py |
325 |
|
326 |
diff --git a/modules/catalyst_support.py b/catalyst/modules/catalyst_support.py |
327 |
similarity index 100% |
328 |
rename from modules/catalyst_support.py |
329 |
rename to catalyst/modules/catalyst_support.py |
330 |
|
331 |
diff --git a/modules/embedded_target.py b/catalyst/modules/embedded_target.py |
332 |
similarity index 100% |
333 |
rename from modules/embedded_target.py |
334 |
rename to catalyst/modules/embedded_target.py |
335 |
|
336 |
diff --git a/modules/generic_stage_target.py b/catalyst/modules/generic_stage_target.py |
337 |
similarity index 99% |
338 |
rename from modules/generic_stage_target.py |
339 |
rename to catalyst/modules/generic_stage_target.py |
340 |
index fcffa23..ddf7499 100644 |
341 |
--- a/modules/generic_stage_target.py |
342 |
+++ b/catalyst/modules/generic_stage_target.py |
343 |
@@ -67,16 +67,18 @@ class generic_stage_target(generic_target): |
344 |
self.archmap = {} |
345 |
self.subarchmap = {} |
346 |
machinemap = {} |
347 |
- for x in [x[:-3] for x in os.listdir(self.settings["sharedir"]+\ |
348 |
- "/arch/") if x.endswith(".py")]: |
349 |
+ arch_dir = self.settings["PythonDir"] + "/arch/" |
350 |
+ for x in [x[:-3] for x in os.listdir(arch_dir) if x.endswith(".py")]: |
351 |
+ if x == "__init__": |
352 |
+ continue |
353 |
try: |
354 |
- fh=open(self.settings["sharedir"]+"/arch/"+x+".py") |
355 |
+ fh=open(arch_dir + x + ".py") |
356 |
""" |
357 |
This next line loads the plugin as a module and assigns it to |
358 |
archmap[x] |
359 |
""" |
360 |
- self.archmap[x]=imp.load_module(x,fh,"arch/"+x+\ |
361 |
- ".py",(".py","r",imp.PY_SOURCE)) |
362 |
+ self.archmap[x]=imp.load_module(x,fh,"../arch/" + x + ".py", |
363 |
+ (".py", "r", imp.PY_SOURCE)) |
364 |
""" |
365 |
This next line registers all the subarches supported in the |
366 |
plugin |
367 |
@@ -94,8 +96,7 @@ class generic_stage_target(generic_target): |
368 |
the dir should load just fine. If it doesn't, it's probably a |
369 |
syntax error in the module |
370 |
""" |
371 |
- msg("Can't find/load "+x+".py plugin in "+\ |
372 |
- self.settings["sharedir"]+"/arch/") |
373 |
+ msg("Can't find/load " + x + ".py plugin in " + arch_dir) |
374 |
|
375 |
if "chost" in self.settings: |
376 |
hostmachine = self.settings["chost"].split("-")[0] |
377 |
|
378 |
diff --git a/modules/generic_target.py b/catalyst/modules/generic_target.py |
379 |
similarity index 100% |
380 |
rename from modules/generic_target.py |
381 |
rename to catalyst/modules/generic_target.py |
382 |
|
383 |
diff --git a/modules/grp_target.py b/catalyst/modules/grp_target.py |
384 |
similarity index 100% |
385 |
rename from modules/grp_target.py |
386 |
rename to catalyst/modules/grp_target.py |
387 |
|
388 |
diff --git a/modules/livecd_stage1_target.py b/catalyst/modules/livecd_stage1_target.py |
389 |
similarity index 100% |
390 |
rename from modules/livecd_stage1_target.py |
391 |
rename to catalyst/modules/livecd_stage1_target.py |
392 |
|
393 |
diff --git a/modules/livecd_stage2_target.py b/catalyst/modules/livecd_stage2_target.py |
394 |
similarity index 100% |
395 |
rename from modules/livecd_stage2_target.py |
396 |
rename to catalyst/modules/livecd_stage2_target.py |
397 |
|
398 |
diff --git a/modules/netboot2_target.py b/catalyst/modules/netboot2_target.py |
399 |
similarity index 100% |
400 |
rename from modules/netboot2_target.py |
401 |
rename to catalyst/modules/netboot2_target.py |
402 |
|
403 |
diff --git a/modules/netboot_target.py b/catalyst/modules/netboot_target.py |
404 |
similarity index 100% |
405 |
rename from modules/netboot_target.py |
406 |
rename to catalyst/modules/netboot_target.py |
407 |
|
408 |
diff --git a/modules/snapshot_target.py b/catalyst/modules/snapshot_target.py |
409 |
similarity index 100% |
410 |
rename from modules/snapshot_target.py |
411 |
rename to catalyst/modules/snapshot_target.py |
412 |
|
413 |
diff --git a/modules/stage1_target.py b/catalyst/modules/stage1_target.py |
414 |
similarity index 100% |
415 |
rename from modules/stage1_target.py |
416 |
rename to catalyst/modules/stage1_target.py |
417 |
|
418 |
diff --git a/modules/stage2_target.py b/catalyst/modules/stage2_target.py |
419 |
similarity index 100% |
420 |
rename from modules/stage2_target.py |
421 |
rename to catalyst/modules/stage2_target.py |
422 |
|
423 |
diff --git a/modules/stage3_target.py b/catalyst/modules/stage3_target.py |
424 |
similarity index 100% |
425 |
rename from modules/stage3_target.py |
426 |
rename to catalyst/modules/stage3_target.py |
427 |
|
428 |
diff --git a/modules/stage4_target.py b/catalyst/modules/stage4_target.py |
429 |
similarity index 100% |
430 |
rename from modules/stage4_target.py |
431 |
rename to catalyst/modules/stage4_target.py |
432 |
|
433 |
diff --git a/modules/tinderbox_target.py b/catalyst/modules/tinderbox_target.py |
434 |
similarity index 100% |
435 |
rename from modules/tinderbox_target.py |
436 |
rename to catalyst/modules/tinderbox_target.py |
437 |
|
438 |
diff --git a/modules/catalyst/util.py b/catalyst/util.py |
439 |
similarity index 100% |
440 |
rename from modules/catalyst/util.py |
441 |
rename to catalyst/util.py |
442 |
|
443 |
diff --git a/modules/catalyst/__init__.py b/modules/catalyst/__init__.py |
444 |
deleted file mode 100644 |
445 |
index e69de29..0000000 |