Gentoo Archives: gentoo-catalyst

From: Brian Dolbec <dolsen@g.o>
To: gentoo-catalyst@l.g.o
Subject: [gentoo-catalyst] [PATCH 1/5] Some options cleanup, unifying their use, reducing redundancy.
Date: Thu, 11 Sep 2014 03:43:53
Message-Id: 1410407024-2445-2-git-send-email-dolsen@gentoo.org
In Reply to: [gentoo-catalyst] [PATCH 0/5] Next group of 5 patches by Brian Dolbec
1 fix options being reset by a config file
2 ---
3 catalyst/defaults.py | 22 ++++-
4 catalyst/main.py | 96 ++++++---------------
5 catalyst/targets/generic_stage_target.py | 142 ++++++++++++++++++-------------
6 catalyst/targets/grp_target.py | 2 +-
7 catalyst/targets/livecd_stage1_target.py | 2 +-
8 catalyst/targets/livecd_stage2_target.py | 8 +-
9 catalyst/targets/netboot2_target.py | 10 +--
10 catalyst/targets/snapshot_target.py | 4 +-
11 catalyst/targets/stage2_target.py | 2 +-
12 catalyst/targets/stage4_target.py | 4 +-
13 10 files changed, 142 insertions(+), 150 deletions(-)
14
15 diff --git a/catalyst/defaults.py b/catalyst/defaults.py
16 index b83e4f5..b36eff7 100644
17 --- a/catalyst/defaults.py
18 +++ b/catalyst/defaults.py
19 @@ -13,10 +13,9 @@ valid_build_targets = ["stage1_target", "stage2_target", "stage3_target",
20 required_config_file_values = ["storedir", "sharedir", "distdir", "portdir"]
21
22 valid_config_file_values = required_config_file_values[:]
23 -valid_config_file_values.extend(["PKGCACHE", "KERNCACHE", "CCACHE", "DISTCC",
24 - "ICECREAM", "ENVSCRIPT", "AUTORESUME", "FETCH", "CLEAR_AUTORESUME",
25 - "options", "DEBUG", "VERBOSE", "PURGE", "PURGEONLY", "SNAPCACHE",
26 - "snapshot_cache", "hash_function", "digests", "contents", "SEEDCACHE"
27 +valid_config_file_values.extend([ "distcc", "envscript",
28 + "options", "DEBUG", "VERBOSE",
29 + "snapshot_cache", "hash_function", "digests", "contents"
30 ])
31
32 verbosity = 1
33 @@ -65,3 +64,18 @@ SOURCE_MOUNT_DEFAULTS = {
34 "shm": "shmfs",
35 }
36
37 +# legend: key: message
38 +option_messages = {
39 + "autoresume": "Autoresuming support enabled.",
40 + "ccache": "Compiler cache support enabled.",
41 + "clear-autoresume": "Cleaning autoresume flags support enabled.",
42 + #"compress": "Compression enabled.",
43 + "distcc": "Distcc support enabled.",
44 + "icecream": "Icecream compiler cluster support enabled.",
45 + "kerncache": "Kernel cache support enabled.",
46 + "pkgcache": "Package cache support enabled.",
47 + "purge": "Purge support enabled.",
48 + "seedcache": "Seed cache support enabled.",
49 + "snapcache": "Snapshot cache support enabled.",
50 + #"tarball": "Tarball creation enabled.",
51 + }
52 diff --git a/catalyst/main.py b/catalyst/main.py
53 index 5748d31..81d48b5 100644
54 --- a/catalyst/main.py
55 +++ b/catalyst/main.py
56 @@ -22,13 +22,12 @@ from . import __version__
57 import catalyst.config
58 import catalyst.util
59 from catalyst.support import CatalystError, find_binary, LockInUse
60 -from catalyst.defaults import (required_build_targets, valid_build_targets,
61 - confdefaults)
62 +from catalyst.defaults import (confdefaults, option_messages,
63 + required_build_targets, valid_build_targets)
64 from hash_utils import HashMap, HASH_DEFINITIONS
65 from contents import ContentsMap, CONTENTS_DEFINITIONS
66
67
68 -
69 conf_values={}
70
71 def usage():
72 @@ -106,7 +105,10 @@ def parse_config(myconfig):
73 for x in list(confdefaults):
74 if x in myconf:
75 print "Setting",x,"to config file value \""+myconf[x]+"\""
76 - conf_values[x]=myconf[x]
77 + if x == 'options':
78 + conf_values[x] = set(myconf[x].split())
79 + else:
80 + conf_values[x]=myconf[x]
81 else:
82 print "Setting",x,"to default value \""+confdefaults[x]+"\""
83 conf_values[x]=confdefaults[x]
84 @@ -114,74 +116,23 @@ def parse_config(myconfig):
85 # add our python base directory to use for loading target arch's
86 conf_values["PythonDir"] = __selfpath__
87
88 - # parse out the rest of the options from the config file
89 - if "autoresume" in string.split(conf_values["options"]):
90 - print "Autoresuming support enabled."
91 - conf_values["AUTORESUME"]="1"
92 -
93 - if "bindist" in string.split(conf_values["options"]):
94 - print "Binary redistribution enabled"
95 - conf_values["BINDIST"]="1"
96 - else:
97 - print "Bindist is not enabled in catalyst.conf"
98 - print "Binary redistribution of generated stages/isos may be prohibited by law."
99 - print "Please see the use description for bindist on any package you are including."
100 -
101 - if "ccache" in string.split(conf_values["options"]):
102 - print "Compiler cache support enabled."
103 - conf_values["CCACHE"]="1"
104 -
105 - if "clear-autoresume" in string.split(conf_values["options"]):
106 - print "Cleaning autoresume flags support enabled."
107 - conf_values["CLEAR_AUTORESUME"]="1"
108 -
109 - if "distcc" in string.split(conf_values["options"]):
110 - print "Distcc support enabled."
111 - conf_values["DISTCC"]="1"
112 -
113 - if "icecream" in string.split(conf_values["options"]):
114 - print "Icecream compiler cluster support enabled."
115 - conf_values["ICECREAM"]="1"
116 -
117 - if "kerncache" in string.split(conf_values["options"]):
118 - print "Kernel cache support enabled."
119 - conf_values["KERNCACHE"]="1"
120
121 - if "pkgcache" in string.split(conf_values["options"]):
122 - print "Package cache support enabled."
123 - conf_values["PKGCACHE"]="1"
124 + # print out any options messages
125 + for opt in conf_values['options']:
126 + if opt in option_messages:
127 + print option_messages[opt]
128
129 - if "preserve_libs" in string.split(conf_values["options"]):
130 - print "Preserving libs during unmerge."
131 - conf_values["PRESERVE_LIBS"]="1"
132 + for key in ["digests", "envscript", "var_tmpfs_portage", "port_logdir"]:
133 + if key in myconf:
134 + conf_values[key] = myconf[key]
135
136 - if "purge" in string.split(conf_values["options"]):
137 - print "Purge support enabled."
138 - conf_values["PURGE"]="1"
139 -
140 - if "seedcache" in string.split(conf_values["options"]):
141 - print "Seed cache support enabled."
142 - conf_values["SEEDCACHE"]="1"
143 -
144 - if "snapcache" in string.split(conf_values["options"]):
145 - print "Snapshot cache support enabled."
146 - conf_values["SNAPCACHE"]="1"
147 -
148 - if "digests" in myconf:
149 - conf_values["digests"]=myconf["digests"]
150 if "contents" in myconf:
151 # replace '-' with '_' (for compatibility with existing configs)
152 conf_values["contents"] = myconf["contents"].replace("-", '_')
153
154 if "envscript" in myconf:
155 print "Envscript support enabled."
156 - conf_values["ENVSCRIPT"]=myconf["envscript"]
157 -
158 - if "var_tmpfs_portage" in myconf:
159 - conf_values["var_tmpfs_portage"]=myconf["var_tmpfs_portage"];
160
161 - if "port_logdir" in myconf:
162 - conf_values["port_logdir"]=myconf["port_logdir"];
163
164 def import_modules():
165 # import catalyst's own modules
166 @@ -272,6 +223,8 @@ def main():
167 usage()
168 sys.exit(2)
169
170 + options = set()
171 +
172 run = False
173 for o, a in opts:
174 if o in ("-h", "--help"):
175 @@ -283,8 +236,8 @@ def main():
176 sys.exit(1)
177
178 if o in ("-d", "--debug"):
179 - conf_values["DEBUG"]="1"
180 - conf_values["VERBOSE"]="1"
181 + conf_values["DEBUG"] = True
182 + conf_values["VERBOSE"] = True
183
184 if o in ("-c", "--config"):
185 myconfig=a
186 @@ -301,7 +254,7 @@ def main():
187 myspecfile=a
188
189 if o in ("-F", "--fetchonly"):
190 - conf_values["FETCH"]="1"
191 + options.add("fetch")
192
193 if o in ("-v", "--verbose"):
194 conf_values["VERBOSE"]="1"
195 @@ -317,16 +270,18 @@ def main():
196 mycmdline.append("version_stamp="+a)
197
198 if o in ("-p", "--purge"):
199 - conf_values["PURGE"] = "1"
200 + options.add("purge")
201
202 if o in ("-P", "--purgeonly"):
203 - conf_values["PURGEONLY"] = "1"
204 + options.add("purgeonly")
205
206 if o in ("-T", "--purgetmponly"):
207 - conf_values["PURGETMPONLY"] = "1"
208 + options.add("purgetmponly")
209
210 if o in ("-a", "--clear-autoresume"):
211 - conf_values["CLEAR_AUTORESUME"] = "1"
212 + options.add("clear-autoresume")
213 +
214 + #print "MAIN: cli options =", options
215
216 if not run:
217 print "!!! catalyst: please specify one of either -f or -C\n"
218 @@ -336,6 +291,9 @@ def main():
219 # import configuration file and import our main module using those settings
220 parse_config(myconfig)
221
222 + conf_values["options"].update(options)
223 + #print "MAIN: conf_values['options'] =", conf_values["options"]
224 +
225 # initialize our contents generator
226 contents_map = ContentsMap(CONTENTS_DEFINITIONS)
227 conf_values["contents_map"] = contents_map
228 diff --git a/catalyst/targets/generic_stage_target.py b/catalyst/targets/generic_stage_target.py
229 index 1f26e65..0b506e2 100644
230 --- a/catalyst/targets/generic_stage_target.py
231 +++ b/catalyst/targets/generic_stage_target.py
232 @@ -189,7 +189,7 @@ class generic_stage_target(generic_target):
233 self.mountmap = SOURCE_MOUNT_DEFAULTS.copy()
234 # update them from settings
235 self.mountmap["distdir"] = self.settings["distdir"]
236 - if "SNAPCACHE" not in self.settings:
237 + if "snapcache" not in self.settings["options"]:
238 self.mounts.remove("portdir")
239 self.mountmap["portdir"] = None
240 else:
241 @@ -207,21 +207,21 @@ class generic_stage_target(generic_target):
242 Configure any user specified options (either in catalyst.conf or on
243 the command line).
244 """
245 - if "PKGCACHE" in self.settings:
246 + if "pkgcache" in self.settings["options"]:
247 self.set_pkgcache_path()
248 print "Location of the package cache is "+\
249 self.settings["pkgcache_path"]
250 self.mounts.append("packagedir")
251 self.mountmap["packagedir"] = self.settings["pkgcache_path"]
252
253 - if "KERNCACHE" in self.settings:
254 + if "kerncache" in self.settings["options"]:
255 self.set_kerncache_path()
256 print "Location of the kerncache is "+\
257 self.settings["kerncache_path"]
258 self.mounts.append("kerncache")
259 self.mountmap["kerncache"] = self.settings["kerncache_path"]
260
261 - if "CCACHE" in self.settings:
262 + if "ccache" in self.settings["options"]:
263 if "CCACHE_DIR" in os.environ:
264 ccdir=os.environ["CCACHE_DIR"]
265 del os.environ["CCACHE_DIR"]
266 @@ -236,7 +236,7 @@ class generic_stage_target(generic_target):
267 """ for the chroot: """
268 self.env["CCACHE_DIR"] = self.target_mounts["ccache"]
269
270 - if "ICECREAM" in self.settings:
271 + if "icecream" in self.settings["options"]:
272 self.mounts.append("icecream")
273 self.mountmap["icecream"] = self.settings["icecream"]
274 self.env["PATH"] = self.target_mounts["icecream"] + ":" + \
275 @@ -314,7 +314,7 @@ class generic_stage_target(generic_target):
276 "/builds/"+self.settings["target_subpath"]+".tar.bz2")
277 setup_target_path_resume = pjoin(self.settings["autoresume_path"],
278 "setup_target_path")
279 - if "AUTORESUME" in self.settings and \
280 + if "autoresume" in self.settings["options"] and \
281 os.path.exists(setup_target_path_resume):
282 print \
283 "Resume point detected, skipping target path setup operation..."
284 @@ -391,7 +391,7 @@ class generic_stage_target(generic_target):
285 del self.settings[self.settings["spec_prefix"]+"/fsops"]
286
287 def set_source_path(self):
288 - if "SEEDCACHE" in self.settings\
289 + if "seedcache" in self.settings["options"]\
290 and os.path.isdir(normpath(self.settings["storedir"]+"/tmp/"+\
291 self.settings["source_subpath"]+"/")):
292 self.settings["source_path"]=normpath(self.settings["storedir"]+\
293 @@ -450,7 +450,7 @@ class generic_stage_target(generic_target):
294 verbose = False)
295
296 def set_snapcache_path(self):
297 - if "SNAPCACHE" in self.settings:
298 + if "snapcache" in self.settings["options"]:
299 self.settings["snapshot_cache_path"] = \
300 normpath(self.settings["snapshot_cache"] + "/" +
301 self.settings["snapshot"])
302 @@ -474,7 +474,7 @@ class generic_stage_target(generic_target):
303 %(self.settings["target"], self.settings["subarch"],
304 self.settings["version_stamp"])
305 ))
306 - if "AUTORESUME" in self.settings:
307 + if "autoresume" in self.settings["options"]:
308 print "The autoresume path is " + self.settings["autoresume_path"]
309 if not os.path.exists(self.settings["autoresume_path"]):
310 os.makedirs(self.settings["autoresume_path"],0755)
311 @@ -501,8 +501,8 @@ class generic_stage_target(generic_target):
312 "base_dirs","bind","chroot_setup","setup_environment",\
313 "run_local","preclean","unbind","clean"]
314 # if "TARBALL" in self.settings or \
315 -# "FETCH" not in self.settings:
316 - if "FETCH" not in self.settings:
317 +# "fetch" not in self.settings["options"]:
318 + if "fetch" not in self.settings["options"]:
319 self.settings["action_sequence"].append("capture")
320 self.settings["action_sequence"].append("clear_autoresume")
321
322 @@ -662,7 +662,7 @@ class generic_stage_target(generic_target):
323 unpack_resume = pjoin(self.settings["autoresume_path"], "unpack")
324 clst_unpack_hash=read_from_clst(unpack_resume)
325
326 - if "SEEDCACHE" in self.settings:
327 + if "seedcache" in self.settings["options"]:
328 if os.path.isdir(self.settings["source_path"]):
329 """ SEEDCACHE Is a directory, use rsync """
330 unpack_cmd="rsync -a --delete "+self.settings["source_path"]+\
331 @@ -704,7 +704,7 @@ class generic_stage_target(generic_target):
332 error_msg="Tarball extraction of "+self.settings["source_path"]+\
333 " to "+self.settings["chroot_path"]+" failed."
334
335 - if "AUTORESUME" in self.settings:
336 + if "autoresume" in self.settings["options"]:
337 if os.path.isdir(self.settings["source_path"]) \
338 and os.path.exists(unpack_resume):
339 """ Autoresume is valid, SEEDCACHE is valid """
340 @@ -730,7 +730,7 @@ class generic_stage_target(generic_target):
341 invalid_snapshot=True
342 else:
343 """ No autoresume, SEEDCACHE """
344 - if "SEEDCACHE" in self.settings:
345 + if "seedcache" in self.settings["options"]:
346 """ SEEDCACHE so let's run rsync and let it clean up """
347 if os.path.isdir(self.settings["source_path"]):
348 unpack=True
349 @@ -754,7 +754,7 @@ class generic_stage_target(generic_target):
350 self.mount_safety_check()
351
352 if invalid_snapshot:
353 - if "AUTORESUME" in self.settings:
354 + if "autoresume" in self.settings["options"]:
355 print "No Valid Resume point detected, cleaning up..."
356
357 self.clear_autoresume()
358 @@ -766,11 +766,11 @@ class generic_stage_target(generic_target):
359 if not os.path.exists(self.settings["chroot_path"]+"/tmp"):
360 os.makedirs(self.settings["chroot_path"]+"/tmp",1777)
361
362 - if "PKGCACHE" in self.settings:
363 + if "pkgcache" in self.settings["options"]:
364 if not os.path.exists(self.settings["pkgcache_path"]):
365 os.makedirs(self.settings["pkgcache_path"],0755)
366
367 - if "KERNCACHE" in self.settings:
368 + if "kerncache" in self.settings["options"]:
369 if not os.path.exists(self.settings["kerncache_path"]):
370 os.makedirs(self.settings["kerncache_path"],0755)
371
372 @@ -792,7 +792,7 @@ class generic_stage_target(generic_target):
373 "unpack_portage")
374 snapshot_hash=read_from_clst(unpack_portage_resume)
375
376 - if "SNAPCACHE" in self.settings:
377 + if "snapcache" in self.settings["options"]:
378 snapshot_cache_hash=\
379 read_from_clst(self.settings["snapshot_cache_path"] + "/" +
380 "catalyst-hash")
381 @@ -824,7 +824,7 @@ class generic_stage_target(generic_target):
382 self.settings["chroot_path"]+"/usr"
383 unpack_errmsg="Error unpacking snapshot"
384
385 - if "AUTORESUME" in self.settings \
386 + if "autoresume" in self.settings["options"] \
387 and os.path.exists(self.settings["chroot_path"]+\
388 self.settings["portdir"]) \
389 and os.path.exists(unpack_portage_resume) \
390 @@ -834,7 +834,7 @@ class generic_stage_target(generic_target):
391 unpack=False
392
393 if unpack:
394 - if "SNAPCACHE" in self.settings:
395 + if "snapcache" in self.settings["options"]:
396 self.snapshot_lock_object.write_lock()
397 if os.path.exists(destdir):
398 print cleanup_msg
399 @@ -846,7 +846,7 @@ class generic_stage_target(generic_target):
400 print "Unpacking portage tree (This can take a long time) ..."
401 cmd(unpack_cmd,unpack_errmsg,env=self.env)
402
403 - if "SNAPCACHE" in self.settings:
404 + if "snapcache" in self.settings["options"]:
405 myf=open(self.settings["snapshot_cache_path"] +
406 "/" + "catalyst-hash","w")
407 myf.write(self.settings["snapshot_path_hash"])
408 @@ -857,13 +857,13 @@ class generic_stage_target(generic_target):
409 myf.write(self.settings["snapshot_path_hash"])
410 myf.close()
411
412 - if "SNAPCACHE" in self.settings:
413 + if "snapcache" in self.settings["options"]:
414 self.snapshot_lock_object.unlock()
415
416 def config_profile_link(self):
417 config_protect_link_resume = pjoin(self.settings["autoresume_path"],
418 "config_profile_link")
419 - if "AUTORESUME" in self.settings \
420 + if "autoresume" in self.settings["options"] \
421 and os.path.exists(config_protect_link_resume):
422 print \
423 "Resume point detected, skipping config_profile_link operation..."
424 @@ -883,7 +883,7 @@ class generic_stage_target(generic_target):
425 def setup_confdir(self):
426 setup_confdir_resume = pjoin(self.settings["autoresume_path"],
427 "setup_confdir")
428 - if "AUTORESUME" in self.settings \
429 + if "autoresume" in self.settings["options"] \
430 and os.path.exists(setup_confdir_resume):
431 print "Resume point detected, skipping setup_confdir operation..."
432 else:
433 @@ -935,7 +935,7 @@ class generic_stage_target(generic_target):
434
435 src=self.mountmap[x]
436 #print "bind(); src =", src
437 - if "SNAPCACHE" in self.settings and x == "portdir":
438 + if "snapcache" in self.settings["options"] and x == "portdir":
439 self.snapshot_lock_object.read_lock()
440 if os.uname()[0] == "FreeBSD":
441 if src == "/dev":
442 @@ -989,7 +989,7 @@ class generic_stage_target(generic_target):
443 ouch=1
444 warn("Couldn't umount bind mount: " + target)
445
446 - if "SNAPCACHE" in self.settings and x == "/usr/portage":
447 + if "snapcache" in self.settings["options"] and x == "/usr/portage":
448 try:
449 """
450 It's possible the snapshot lock object isn't created yet.
451 @@ -1018,7 +1018,8 @@ class generic_stage_target(generic_target):
452 self.override_ldflags()
453 chroot_setup_resume = pjoin(self.settings["autoresume_path"],
454 "chroot_setup")
455 - if "AUTORESUME" in self.settings and os.path.exists(chroot_setup_resume):
456 + if "autoresume" in self.settings["options"] \
457 + and os.path.exists(chroot_setup_resume):
458 print "Resume point detected, skipping chroot_setup operation..."
459 else:
460 print "Setting up chroot..."
461 @@ -1029,10 +1030,10 @@ class generic_stage_target(generic_target):
462 "Could not copy resolv.conf into place.",env=self.env)
463
464 """ Copy over the envscript, if applicable """
465 - if "ENVSCRIPT" in self.settings:
466 - if not os.path.exists(self.settings["ENVSCRIPT"]):
467 + if "envscript" in self.settings:
468 + if not os.path.exists(self.settings["envscript"]):
469 raise CatalystError,\
470 - "Can't find envscript "+self.settings["ENVSCRIPT"]
471 + "Can't find envscript "+self.settings["envscript"]
472
473 print "\nWarning!!!!"
474 print "\tOverriding certain env variables may cause catastrophic failure."
475 @@ -1042,7 +1043,7 @@ class generic_stage_target(generic_target):
476 print "\tCatalyst Maintainers use VERY minimal envscripts if used at all"
477 print "\tYou have been warned\n"
478
479 - cmd("cp "+self.settings["ENVSCRIPT"]+" "+\
480 + cmd("cp "+self.settings["envscript"]+" "+\
481 self.settings["chroot_path"]+"/tmp/envscript",\
482 "Could not copy envscript into place.",env=self.env)
483
484 @@ -1118,7 +1119,8 @@ class generic_stage_target(generic_target):
485
486 def fsscript(self):
487 fsscript_resume = pjoin(self.settings["autoresume_path"], "fsscript")
488 - if "AUTORESUME" in self.settings and os.path.exists(fsscript_resume):
489 + if "autoresume" in self.settings["options"] \
490 + and os.path.exists(fsscript_resume):
491 print "Resume point detected, skipping fsscript operation..."
492 else:
493 if "fsscript" in self.settings:
494 @@ -1129,7 +1131,7 @@ class generic_stage_target(generic_target):
495
496 def rcupdate(self):
497 rcupdate_resume = pjoin(self.settings["autoresume_path"], "rcupdate")
498 - if "AUTORESUME" in self.settings \
499 + if "autoresume" in self.settings["options"] \
500 and os.path.exists(rcupdate_resume):
501 print "Resume point detected, skipping rcupdate operation..."
502 else:
503 @@ -1140,7 +1142,7 @@ class generic_stage_target(generic_target):
504
505 def clean(self):
506 clean_resume = pjoin(self.settings["autoresume_path"], "clean")
507 - if "AUTORESUME" in self.settings \
508 + if "autoresume" in self.settings["options"] \
509 and os.path.exists(clean_resume):
510 print "Resume point detected, skipping clean operation..."
511 else:
512 @@ -1176,7 +1178,8 @@ class generic_stage_target(generic_target):
513
514 def empty(self):
515 empty_resume = pjoin(self.settings["autoresume_path"], "empty")
516 - if "AUTORESUME" in self.settings and os.path.exists(empty_resume):
517 + if "autoresume" in self.settings["options"] \
518 + and os.path.exists(empty_resume):
519 print "Resume point detected, skipping empty operation..."
520 else:
521 if self.settings["spec_prefix"]+"/empty" in self.settings:
522 @@ -1204,7 +1207,8 @@ class generic_stage_target(generic_target):
523
524 def remove(self):
525 remove_resume = pjoin(self.settings["autoresume_path"], "remove")
526 - if "AUTORESUME" in self.settings and os.path.exists(remove_resume):
527 + if "autoresume" in self.settings["options"] \
528 + and os.path.exists(remove_resume):
529 print "Resume point detected, skipping remove operation..."
530 else:
531 if self.settings["spec_prefix"]+"/rm" in self.settings:
532 @@ -1226,7 +1230,8 @@ class generic_stage_target(generic_target):
533
534 def preclean(self):
535 preclean_resume = pjoin(self.settings["autoresume_path"], "preclean")
536 - if "AUTORESUME" in self.settings and os.path.exists(preclean_resume):
537 + if "autoresume" in self.settings["options"] \
538 + and os.path.exists(preclean_resume):
539 print "Resume point detected, skipping preclean operation..."
540 else:
541 try:
542 @@ -1241,7 +1246,8 @@ class generic_stage_target(generic_target):
543
544 def capture(self):
545 capture_resume = pjoin(self.settings["autoresume_path"], "capture")
546 - if "AUTORESUME" in self.settings and os.path.exists(capture_resume):
547 + if "autoresume" in self.settings["options"] \
548 + and os.path.exists(capture_resume):
549 print "Resume point detected, skipping capture operation..."
550 else:
551 """ Capture target in a tarball """
552 @@ -1266,7 +1272,8 @@ class generic_stage_target(generic_target):
553
554 def run_local(self):
555 run_local_resume = pjoin(self.settings["autoresume_path"], "run_local")
556 - if "AUTORESUME" in self.settings and os.path.exists(run_local_resume):
557 + if "autoresume" in self.settings["options"] \
558 + and os.path.exists(run_local_resume):
559 print "Resume point detected, skipping run_local operation..."
560 else:
561 try:
562 @@ -1285,7 +1292,14 @@ class generic_stage_target(generic_target):
563 fixed. We need this to use the os.system() call since we can't
564 specify our own environ
565 """
566 - for x in self.settings.keys():
567 + #print "setup_environment(); settings =", list(self.settings)
568 + for x in list(self.settings):
569 + #print "setup_environment(); processing:", x
570 + if x == "options":
571 + #self.env['clst_' + x] = ' '.join(self.settings[x])
572 + for opt in self.settings[x]:
573 + self.env['clst_' + opt.upper()] = "true"
574 + continue
575 """ Sanitize var names by doing "s|/-.|_|g" """
576 varname="clst_"+string.replace(x,"/","_")
577 varname=string.replace(varname,"-","_")
578 @@ -1314,10 +1328,10 @@ class generic_stage_target(generic_target):
579 """ Check for mounts right away and abort if we cannot unmount them """
580 self.mount_safety_check()
581
582 - if "CLEAR_AUTORESUME" in self.settings:
583 + if "clear-autoresume" in self.settings["options"]:
584 self.clear_autoresume()
585
586 - if "PURGETMPONLY" in self.settings:
587 + if "purgetmponly" in self.settings["options"]:
588 self.purge()
589 return
590
591 @@ -1325,7 +1339,7 @@ class generic_stage_target(generic_target):
592 self.purge()
593 return
594
595 - if "PURGE" in self.settings:
596 + if "purge" in self.settings["options"]:
597 self.purge()
598
599 for x in self.settings["action_sequence"]:
600 @@ -1341,7 +1355,8 @@ class generic_stage_target(generic_target):
601
602 def unmerge(self):
603 unmerge_resume = pjoin(self.settings["autoresume_path"], "unmerge")
604 - if "AUTORESUME" in self.settings and os.path.exists(unmerge_resume):
605 + if "autoresume" in self.settings["options"] \
606 + and os.path.exists(unmerge_resume):
607 print "Resume point detected, skipping unmerge operation..."
608 else:
609 if self.settings["spec_prefix"]+"/unmerge" in self.settings:
610 @@ -1374,7 +1389,8 @@ class generic_stage_target(generic_target):
611 def target_setup(self):
612 target_setup_resume = pjoin(self.settings["autoresume_path"],
613 "target_setup")
614 - if "AUTORESUME" in self.settings and os.path.exists(target_setup_resume):
615 + if "autoresume" in self.settings["options"] \
616 + and os.path.exists(target_setup_resume):
617 print "Resume point detected, skipping target_setup operation..."
618 else:
619 print "Setting up filesystems per filesystem type"
620 @@ -1386,8 +1402,8 @@ class generic_stage_target(generic_target):
621 def setup_overlay(self):
622 setup_overlay_resume = pjoin(self.settings["autoresume_path"],
623 "setup_overlay")
624 - if "AUTORESUME" in self.settings and \
625 - os.path.exists(setup_overlay_resume):
626 + if "autoresume" in self.settings["options"] \
627 + and os.path.exists(setup_overlay_resume):
628 print "Resume point detected, skipping setup_overlay operation..."
629 else:
630 if self.settings["spec_prefix"]+"/overlay" in self.settings:
631 @@ -1401,7 +1417,8 @@ class generic_stage_target(generic_target):
632
633 def create_iso(self):
634 create_iso_resume = pjoin(self.settings["autoresume_path"], "create_iso")
635 - if "AUTORESUME" in self.settings and os.path.exists(create_iso_resume):
636 + if "autoresume" in self.settings["options"] \
637 + and os.path.exists(create_iso_resume):
638 print "Resume point detected, skipping create_iso operation..."
639 else:
640 """ Create the ISO """
641 @@ -1419,12 +1436,12 @@ class generic_stage_target(generic_target):
642 def build_packages(self):
643 build_packages_resume = pjoin(self.settings["autoresume_path"],
644 "build_packages")
645 - if "AUTORESUME" in self.settings and \
646 - os.path.exists(build_packages_resume):
647 + if "autoresume" in self.settings["options"] \
648 + and os.path.exists(build_packages_resume):
649 print "Resume point detected, skipping build_packages operation..."
650 else:
651 if self.settings["spec_prefix"]+"/packages" in self.settings:
652 - if "AUTORESUME" in self.settings \
653 + if "autoresume" in self.settings["options"] \
654 and os.path.exists(self.settings["autoresume_path"]+\
655 "build_packages"):
656 print "Resume point detected, skipping build_packages operation..."
657 @@ -1443,10 +1460,11 @@ class generic_stage_target(generic_target):
658 "build aborting due to error."
659
660 def build_kernel(self):
661 - "Build all configured kernels"
662 + '''Build all configured kernels'''
663 build_kernel_resume = pjoin(self.settings["autoresume_path"],
664 "build_kernel")
665 - if "AUTORESUME" in self.settings and os.path.exists(build_kernel_resume):
666 + if "autoresume" in self.settings["options"] \
667 + and os.path.exists(build_kernel_resume):
668 print "Resume point detected, skipping build_kernel operation..."
669 else:
670 if "boot/kernel" in self.settings:
671 @@ -1472,7 +1490,8 @@ class generic_stage_target(generic_target):
672 "Build a single configured kernel by name"
673 kname_resume = pjoin(self.settings["autoresume_path"],
674 "build_kernel_" + kname)
675 - if "AUTORESUME" in self.settings and os.path.exists(kname_resume):
676 + if "autoresume" in self.settings["options"] \
677 + and os.path.exists(kname_resume):
678 print "Resume point detected, skipping build_kernel for "+kname+" operation..."
679 return
680 self._copy_kernel_config(kname=kname)
681 @@ -1568,7 +1587,8 @@ class generic_stage_target(generic_target):
682
683 def bootloader(self):
684 bootloader_resume = pjoin(self.settings["autoresume_path"], "bootloader")
685 - if "AUTORESUME" in self.settings and os.path.exists(bootloader_resume):
686 + if "autoresume" in self.settings["options"] \
687 + and os.path.exists(bootloader_resume):
688 print "Resume point detected, skipping bootloader operation..."
689 else:
690 try:
691 @@ -1583,7 +1603,7 @@ class generic_stage_target(generic_target):
692 def livecd_update(self):
693 livecd_update_resume = pjoin(self.settings["autoresume_path"],
694 "livecd_update")
695 - if "AUTORESUME" in self.settings \
696 + if "autoresume" in self.settings["options"] \
697 and os.path.exists(livecd_update_resume):
698 print "Resume point detected, skipping build_packages operation..."
699 else:
700 @@ -1615,7 +1635,7 @@ class generic_stage_target(generic_target):
701 os.chmod(myemp,mystat[ST_MODE])
702
703 def clear_packages(self):
704 - if "PKGCACHE" in self.settings:
705 + if "pkgcache" in self.settings["options"]:
706 print "purging the pkgcache ..."
707
708 myemp=self.settings["pkgcache_path"]
709 @@ -1633,7 +1653,7 @@ class generic_stage_target(generic_target):
710 os.chmod(myemp,mystat[ST_MODE])
711
712 def clear_kerncache(self):
713 - if "KERNCACHE" in self.settings:
714 + if "kerncache" in self.settings["options"]:
715 print "purging the kerncache ..."
716
717 myemp=self.settings["kerncache_path"]
718 @@ -1652,11 +1672,11 @@ class generic_stage_target(generic_target):
719
720 def clear_autoresume(self):
721 """ Clean resume points since they are no longer needed """
722 - if "AUTORESUME" in self.settings:
723 + if "autoresume" in self.settings["options"]:
724 print "Removing AutoResume Points: ..."
725 myemp=self.settings["autoresume_path"]
726 if os.path.isdir(myemp):
727 - if "AUTORESUME" in self.settings:
728 + if "autoresume" in self.settings["options"]:
729 print "Emptying directory",myemp
730 """
731 stat the dir, delete the dir, recreate the dir and set
732 @@ -1720,7 +1740,7 @@ class generic_stage_target(generic_target):
733
734 def purge(self):
735 countdown(10,"Purging Caches ...")
736 - if any(k in self.settings for k in ("PURGE","PURGEONLY","PURGETMPONLY")):
737 + if any(k in self.settings["options"] for k in ("purge","purgeonly","purgetmponly")):
738 print "clearing autoresume ..."
739 self.clear_autoresume()
740
741 diff --git a/catalyst/targets/grp_target.py b/catalyst/targets/grp_target.py
742 index 8e70042..a8309a8 100644
743 --- a/catalyst/targets/grp_target.py
744 +++ b/catalyst/targets/grp_target.py
745 @@ -36,7 +36,7 @@ class grp_target(generic_stage_target):
746
747 def set_target_path(self):
748 self.settings["target_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["target_subpath"]+"/")
749 - if "AUTORESUME" in self.settings \
750 + if "autoresume" in self.settings["options"] \
751 and os.path.exists(self.settings["autoresume_path"]+"setup_target_path"):
752 print "Resume point detected, skipping target path setup operation..."
753 else:
754 diff --git a/catalyst/targets/livecd_stage1_target.py b/catalyst/targets/livecd_stage1_target.py
755 index ac846ec..6273c9e 100644
756 --- a/catalyst/targets/livecd_stage1_target.py
757 +++ b/catalyst/targets/livecd_stage1_target.py
758 @@ -25,7 +25,7 @@ class livecd_stage1_target(generic_stage_target):
759
760 def set_target_path(self):
761 self.settings["target_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["target_subpath"])
762 - if "AUTORESUME" in self.settings \
763 + if "autoresume" in self.settings["options"] \
764 and os.path.exists(self.settings["autoresume_path"]+"setup_target_path"):
765 print "Resume point detected, skipping target path setup operation..."
766 else:
767 diff --git a/catalyst/targets/livecd_stage2_target.py b/catalyst/targets/livecd_stage2_target.py
768 index e784844..11b1219 100644
769 --- a/catalyst/targets/livecd_stage2_target.py
770 +++ b/catalyst/targets/livecd_stage2_target.py
771 @@ -48,7 +48,7 @@ class livecd_stage2_target(generic_stage_target):
772
773 def set_target_path(self):
774 self.settings["target_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["target_subpath"]+"/")
775 - if "AUTORESUME" in self.settings \
776 + if "autoresume" in self.settings["options"] \
777 and os.path.exists(self.settings["autoresume_path"]+"setup_target_path"):
778 print "Resume point detected, skipping target path setup operation..."
779 else:
780 @@ -90,7 +90,7 @@ class livecd_stage2_target(generic_stage_target):
781 error_msg="Rsync of "+self.settings["source_path"]+" to "+self.settings["chroot_path"]+" failed."
782 invalid_snapshot=False
783
784 - if "AUTORESUME" in self.settings:
785 + if "autoresume" in self.settings["options"]:
786 if os.path.isdir(self.settings["source_path"]) and \
787 os.path.exists(self.settings["autoresume_path"]+"unpack"):
788 print "Resume point detected, skipping unpack operation..."
789 @@ -114,7 +114,7 @@ class livecd_stage2_target(generic_stage_target):
790 if not os.path.exists(self.settings["chroot_path"]+"/tmp"):
791 os.makedirs(self.settings["chroot_path"]+"/tmp",1777)
792
793 - if "PKGCACHE" in self.settings:
794 + if "pkgcache" in self.settings["options"]:
795 if not os.path.exists(self.settings["pkgcache_path"]):
796 os.makedirs(self.settings["pkgcache_path"],0755)
797
798 @@ -136,7 +136,7 @@ class livecd_stage2_target(generic_stage_target):
799 "config_profile_link","setup_confdir","portage_overlay",\
800 "bind","chroot_setup","setup_environment","run_local",\
801 "build_kernel"]
802 - if "FETCH" not in self.settings:
803 + if "fetch" not in self.settings["options"]:
804 self.settings["action_sequence"] += ["bootloader","preclean",\
805 "livecd_update","root_overlay","fsscript","rcupdate","unmerge",\
806 "unbind","remove","empty","target_setup",\
807 diff --git a/catalyst/targets/netboot2_target.py b/catalyst/targets/netboot2_target.py
808 index 2b3cd20..8809dd0 100644
809 --- a/catalyst/targets/netboot2_target.py
810 +++ b/catalyst/targets/netboot2_target.py
811 @@ -45,7 +45,7 @@ class netboot2_target(generic_stage_target):
812 def set_target_path(self):
813 self.settings["target_path"]=normpath(self.settings["storedir"]+"/builds/"+\
814 self.settings["target_subpath"]+"/")
815 - if "AUTORESUME" in self.settings \
816 + if "autoresume" in self.settings["options"] \
817 and os.path.exists(self.settings["autoresume_path"]+"setup_target_path"):
818 print "Resume point detected, skipping target path setup operation..."
819 else:
820 @@ -63,7 +63,7 @@ class netboot2_target(generic_stage_target):
821 myfiles=[]
822
823 # check for autoresume point
824 - if "AUTORESUME" in self.settings \
825 + if "autoresume" in self.settings["options"] \
826 and os.path.exists(self.settings["autoresume_path"]+"copy_files_to_image"):
827 print "Resume point detected, skipping target path setup operation..."
828 else:
829 @@ -96,7 +96,7 @@ class netboot2_target(generic_stage_target):
830 touch(self.settings["autoresume_path"]+"copy_files_to_image")
831
832 def setup_overlay(self):
833 - if "AUTORESUME" in self.settings \
834 + if "autoresume" in self.settings["options"] \
835 and os.path.exists(self.settings["autoresume_path"]+"setup_overlay"):
836 print "Resume point detected, skipping setup_overlay operation..."
837 else:
838 @@ -120,7 +120,7 @@ class netboot2_target(generic_stage_target):
839 raise CatalystError,"Failed to move kernel images!"
840
841 def remove(self):
842 - if "AUTORESUME" in self.settings \
843 + if "autoresume" in self.settings["options"] \
844 and os.path.exists(self.settings["autoresume_path"]+"remove"):
845 print "Resume point detected, skipping remove operation..."
846 else:
847 @@ -132,7 +132,7 @@ class netboot2_target(generic_stage_target):
848 os.system("rm -rf " + self.settings["chroot_path"] + self.settings["merge_path"] + x)
849
850 def empty(self):
851 - if "AUTORESUME" in self.settings \
852 + if "autoresume" in self.settings["options"] \
853 and os.path.exists(self.settings["autoresume_path"]+"empty"):
854 print "Resume point detected, skipping empty operation..."
855 else:
856 diff --git a/catalyst/targets/snapshot_target.py b/catalyst/targets/snapshot_target.py
857 index d1b9e40..50133ec 100644
858 --- a/catalyst/targets/snapshot_target.py
859 +++ b/catalyst/targets/snapshot_target.py
860 @@ -32,11 +32,11 @@ class snapshot_target(generic_stage_target):
861 pass
862
863 def run(self):
864 - if "PURGEONLY" in self.settings:
865 + if "purgeonly" in self.settings["options"]:
866 self.purge()
867 return
868
869 - if "PURGE" in self.settings:
870 + if "purge" in self.settings["options"]:
871 self.purge()
872
873 self.setup()
874 diff --git a/catalyst/targets/stage2_target.py b/catalyst/targets/stage2_target.py
875 index 6377f5d..94d4a1e 100644
876 --- a/catalyst/targets/stage2_target.py
877 +++ b/catalyst/targets/stage2_target.py
878 @@ -16,7 +16,7 @@ class stage2_target(generic_stage_target):
879 generic_stage_target.__init__(self,spec,addlargs)
880
881 def set_source_path(self):
882 - if "SEEDCACHE" in self.settings and os.path.isdir(normpath(self.settings["storedir"]+"/tmp/"+self.settings["source_subpath"]+"/tmp/stage1root/")):
883 + if "seedcache" in self.settings["options"] and os.path.isdir(normpath(self.settings["storedir"]+"/tmp/"+self.settings["source_subpath"]+"/tmp/stage1root/")):
884 self.settings["source_path"]=normpath(self.settings["storedir"]+"/tmp/"+self.settings["source_subpath"]+"/tmp/stage1root/")
885 else:
886 self.settings["source_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["source_subpath"]+".tar.bz2")
887 diff --git a/catalyst/targets/stage4_target.py b/catalyst/targets/stage4_target.py
888 index 9168f2e..e2b8a79 100644
889 --- a/catalyst/targets/stage4_target.py
890 +++ b/catalyst/targets/stage4_target.py
891 @@ -32,8 +32,8 @@ class stage4_target(generic_stage_target):
892 "clean"]
893
894 # if "TARBALL" in self.settings or \
895 -# "FETCH" not in self.settings:
896 - if "FETCH" not in self.settings:
897 +# "fetch" not in self.settings['options']:
898 + if "fetch" not in self.settings['options']:
899 self.settings["action_sequence"].append("capture")
900 self.settings["action_sequence"].append("clear_autoresume")
901
902 --
903 2.1.0

Replies