From ec82f98cb6c8199041838496bce41ce515232314 Mon Sep 17 00:00:00 2001 From: Andrew Gaffney Date: Mon, 6 Apr 2009 21:44:11 -0500 Subject: [PATCH] Get rid of addlargs in the main script Initial basics for multiple target support Move targetmap into global config object --- ChangeLog | 5 +++++ catalyst | 40 +++++++++++++++++++------------------- modules/catalyst/config.py | 10 ++++++++++ 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 38815e45..5810e857 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,11 @@ # Copyright 2002-2009 Gentoo Foundation; 2008-2009 Various authors (see AUTHORS) # Distributed under the GPL v2 + 07 Apr 2009; Andrew Gaffney catalyst, + modules/catalyst/config.py: + Get rid of addlargs in the main script Initial basics for multiple target + support Move targetmap into global config object + 07 Apr 2009; Andrew Gaffney modules/catalyst/target/stage1.py: Clean up cleanables diff --git a/catalyst b/catalyst index 217be8e2..61efc16e 100755 --- a/catalyst +++ b/catalyst @@ -142,21 +142,27 @@ def parse_config(myconfig): msg("Envscript support enabled.") conf_values["ENVSCRIPT"] = myconf["envscript"] -def build_target(addlargs, targetmap): - try: - if not addlargs["target"] in targetmap: - raise CatalystError,"Target \""+addlargs["target"]+"\" not available." +def build_targets(): + spec_values = config.get_spec().get_values() + targetmap = config.get_targetmap() - config.get_spec().set_target(addlargs["target"]) -# mytarget=targetmap[addlargs["target"]](conf_values, addlargs) - mytarget=targetmap[addlargs["target"]]() + if not "targets" in spec_values or not spec_values['targets']: + raise CatalystError, "No target(s) specified." - mytarget.run() + for x in spec_values['targets']: + if not x in targetmap: + raise CatalystError("Target \"" + x + "\" is not a known target.") - except: - catalyst.util.print_traceback() - warn("Error encountered during run of target " + addlargs["target"]) - raise + for x in spec_values['targets']: + try: + config.get_spec().set_target(x) + mytarget = targetmap[x]() + mytarget.run() + + except: + catalyst.util.print_traceback() + warn("Error encountered during run of target " + x) + raise def verify_digest_and_hash_functions(): # Start checking that digests are valid now that the hash_map was imported from catalyst_support @@ -292,14 +298,11 @@ if __name__ == "__main__": verify_digest_and_hash_functions() targetmap = catalyst.target.build_target_map() - - addlargs = {} spec = catalyst.config.Spec() if myspecfile: specparser = catalyst.config.SpecParser(myspecfile) spec_values = specparser.get_values() - addlargs.update(spec_values) spec.parse_values(spec_values) if mycmdline: @@ -307,20 +310,17 @@ if __name__ == "__main__": cmdline = catalyst.config.ConfigParser() cmdline.parse_lines(mycmdline) cmdline_values = cmdline.get_values() - addlargs.update(cmdline.get_values()) spec.parse_values(cmdline_values) except CatalystError: die("Could not parse commandline, exiting.") config.set_spec(spec) config.set_conf(conf_values) - - if not "target" in addlargs: - raise CatalystError, "Required value \"target\" not specified." + config.set_targetmap(targetmap) # everything is setup, so the build is a go try: - build_target(addlargs, targetmap) + build_targets() except CatalystError: msg() diff --git a/modules/catalyst/config.py b/modules/catalyst/config.py index 212520a2..b6f0a7fb 100644 --- a/modules/catalyst/config.py +++ b/modules/catalyst/config.py @@ -164,6 +164,9 @@ class Spec: if not parts[0] in self.values: self.values[parts[0]] = {} self.values[parts[0]]['/'.join(parts[1:])] = values[x] + if 'target' in self.values['global']: + self.values['global']['targets'] = set((self.values['global']['target'], )) + del self.values['global']['target'] def set_target(self, target): self.target = target @@ -214,6 +217,7 @@ class config: if not hasattr(self, 'spec'): self.spec = None self.conf = {} + self.targetmap = None def set_spec(self, spec): self.spec = spec @@ -229,3 +233,9 @@ class config: def get_conf(self): return self.conf + + def set_targetmap(self, targetmap): + self.targetmap = targetmap + + def get_targetmap(self): + return self.targetmap -- 2.26.2