From: Andrew Gaffney Date: Sun, 11 Jan 2009 01:30:24 +0000 (-0600) Subject: Add target map in each target module and remove register() function X-Git-Tag: CATALYST-2.0.10~3^2~234 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6567981f3bcc15c9bddbd09d84f4998accdfa6e2;p=catalyst.git Add target map in each target module and remove register() function Change catalyst program to load target modules with catalyst.target.targets class Remove required_build_targets and valid_build_targets from catalyst_support.py, since we can scan the dir now --- diff --git a/ChangeLog b/ChangeLog index 7cab21fc..758c6a1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,25 @@ # Copyright 2002-2009 Gentoo Foundation; 2008-2009 Various authors (see AUTHORS) # Distributed under the GPL v2 + 11 Jan 2009; Andrew Gaffney catalyst, + modules/catalyst/target/embedded_target.py, + modules/catalyst/target/grp_target.py, + modules/catalyst/target/livecd_stage1_target.py, + modules/catalyst/target/livecd_stage2_target.py, + modules/catalyst/target/netboot2_target.py, + modules/catalyst/target/netboot_target.py, + modules/catalyst/target/snapshot_target.py, + modules/catalyst/target/stage1_target.py, + modules/catalyst/target/stage2_target.py, + modules/catalyst/target/stage3_target.py, + modules/catalyst/target/stage4_target.py, + modules/catalyst/target/tinderbox_target.py, modules/catalyst_support.py: + Add target map in each target module and remove register() function + Change catalyst program to load target modules with catalyst.target.targets + class + Remove required_build_targets and valid_build_targets from catalyst_support.py, + since we can scan the dir now + 11 Jan 2009; Andrew Gaffney +modules/catalyst/target/__init__.py, +modules/catalyst/target/embedded_target.py, diff --git a/catalyst b/catalyst index 43bc47d1..4de6fe48 100755 --- a/catalyst +++ b/catalyst @@ -169,32 +169,9 @@ def import_modules(): # import catalyst's own modules (i.e. catalyst_support and the arch modules) targetmap={} - try: - for x in required_build_targets: - try: - fh=open(conf_values["sharedir"]+"/modules/"+x+".py") - module=imp.load_module(x,fh,"modules/"+x+".py",(".py","r",imp.PY_SOURCE)) - fh.close() - - except IOError: - raise CatalystError,"Can't find "+x+".py plugin in "+\ - conf_values.settings["sharedir"]+"/modules/" - - for x in valid_build_targets: - try: - fh=open(conf_values["sharedir"]+"/modules/"+x+".py") - module=imp.load_module(x,fh,"modules/"+x+".py",(".py","r",imp.PY_SOURCE)) - module.register(targetmap) - fh.close() - - except IOError: - raise CatalystError,"Can't find "+x+".py plugin in "+\ - conf_values.settings["sharedir"]+"/modules/" - - except ImportError: - print "!!! catalyst: Python modules not found in "+\ - conf_values["sharedir"]+"/modules; exiting." - sys.exit(1) + targets = catalyst.target.targets() + for x in targets.get_targets(): + targetmap.update(x.__target_map) return targetmap diff --git a/modules/catalyst/target/embedded_target.py b/modules/catalyst/target/embedded_target.py index 2ab8cc5a..f1b244c9 100644 --- a/modules/catalyst/target/embedded_target.py +++ b/modules/catalyst/target/embedded_target.py @@ -43,6 +43,4 @@ class embedded_target(generic_stage_target): self.settings["root_path"]=normpath("/tmp/mergeroot") print "embedded root path is "+self.settings["root_path"] -def register(foo): - foo.update({"embedded":embedded_target}) - return foo +__target_map = {"embedded":embedded_target} diff --git a/modules/catalyst/target/grp_target.py b/modules/catalyst/target/grp_target.py index b077d9c8..f0806bdb 100644 --- a/modules/catalyst/target/grp_target.py +++ b/modules/catalyst/target/grp_target.py @@ -109,6 +109,4 @@ class grp_target(generic_stage_target): "setup_environment","run_local","unbind",\ "generate_digests","clear_autoresume"] -def register(foo): - foo.update({"grp":grp_target}) - return foo +__target_map = {"grp":grp_target} diff --git a/modules/catalyst/target/livecd_stage1_target.py b/modules/catalyst/target/livecd_stage1_target.py index 0d5c97c8..9f75cea9 100644 --- a/modules/catalyst/target/livecd_stage1_target.py +++ b/modules/catalyst/target/livecd_stage1_target.py @@ -64,6 +64,4 @@ class livecd_stage1_target(generic_stage_target): else: generic_stage_target.set_pkgcache_path(self) -def register(foo): - foo.update({"livecd-stage1":livecd_stage1_target}) - return foo +__target_map = {"livecd-stage1":livecd_stage1_target} diff --git a/modules/catalyst/target/livecd_stage2_target.py b/modules/catalyst/target/livecd_stage2_target.py index 147148f7..237108ba 100644 --- a/modules/catalyst/target/livecd_stage2_target.py +++ b/modules/catalyst/target/livecd_stage2_target.py @@ -135,6 +135,4 @@ class livecd_stage2_target(generic_stage_target): "setup_overlay","create_iso"] self.settings["action_sequence"].append("clear_autoresume") -def register(foo): - foo.update({"livecd-stage2":livecd_stage2_target}) - return foo +__target_map = {"livecd-stage2":livecd_stage2_target} diff --git a/modules/catalyst/target/netboot2_target.py b/modules/catalyst/target/netboot2_target.py index 444f873c..fd29e487 100644 --- a/modules/catalyst/target/netboot2_target.py +++ b/modules/catalyst/target/netboot2_target.py @@ -158,6 +158,4 @@ class netboot2_target(generic_stage_target): "copy_files_to_image","setup_overlay","build_kernel","move_kernels",\ "remove","empty","unbind","clean","clear_autoresume"] -def register(foo): - foo.update({"netboot2":netboot2_target}) - return foo +__target_map = {"netboot2":netboot2_target} diff --git a/modules/catalyst/target/netboot_target.py b/modules/catalyst/target/netboot_target.py index 92c1b045..b0b55f00 100644 --- a/modules/catalyst/target/netboot_target.py +++ b/modules/catalyst/target/netboot_target.py @@ -127,6 +127,4 @@ class netboot_target(generic_stage_target): "build_kernel","copy_files_to_image",\ "clean","create_netboot_files","unbind","clear_autoresume"] -def register(foo): - foo.update({"netboot":netboot_target}) - return foo +__target_map = {"netboot":netboot_target} diff --git a/modules/catalyst/target/snapshot_target.py b/modules/catalyst/target/snapshot_target.py index 0609377b..a8873cfa 100644 --- a/modules/catalyst/target/snapshot_target.py +++ b/modules/catalyst/target/snapshot_target.py @@ -80,6 +80,4 @@ class snapshot_target(generic_stage_target): os.chown(myemp,mystat[ST_UID],mystat[ST_GID]) os.chmod(myemp,mystat[ST_MODE]) -def register(foo): - foo.update({"snapshot":snapshot_target}) - return foo +__target_map = {"snapshot":snapshot_target} diff --git a/modules/catalyst/target/stage1_target.py b/modules/catalyst/target/stage1_target.py index a6eb4352..aa5360f8 100644 --- a/modules/catalyst/target/stage1_target.py +++ b/modules/catalyst/target/stage1_target.py @@ -93,6 +93,4 @@ class stage1_target(generic_stage_target): self.mountmap["/tmp/stage1root/proc"]="/proc" -def register(foo): - foo.update({"stage1":stage1_target}) - return foo +__target_map = {"stage1":stage1_target} diff --git a/modules/catalyst/target/stage2_target.py b/modules/catalyst/target/stage2_target.py index a5135b25..428d98ef 100644 --- a/modules/catalyst/target/stage2_target.py +++ b/modules/catalyst/target/stage2_target.py @@ -58,6 +58,4 @@ class stage2_target(generic_stage_target): print "\tIf you break it, you buy it. Don't complain to us about it." print "\tDont say we did not warn you\n" -def register(foo): - foo.update({"stage2":stage2_target}) - return foo +__target_map = {"stage2":stage2_target} diff --git a/modules/catalyst/target/stage3_target.py b/modules/catalyst/target/stage3_target.py index 7e087cb2..e7d6632e 100644 --- a/modules/catalyst/target/stage3_target.py +++ b/modules/catalyst/target/stage3_target.py @@ -24,6 +24,4 @@ class stage3_target(generic_stage_target): generic_stage_target.set_cleanables(self) self.settings["cleanables"].extend(["/etc/portage"]) -def register(foo): - foo.update({"stage3":stage3_target}) - return foo +__target_map = {"stage3":stage3_target} diff --git a/modules/catalyst/target/stage4_target.py b/modules/catalyst/target/stage4_target.py index cc8e6c02..486ad60b 100644 --- a/modules/catalyst/target/stage4_target.py +++ b/modules/catalyst/target/stage4_target.py @@ -34,7 +34,5 @@ class stage4_target(generic_stage_target): self.settings["action_sequence"].append("capture") self.settings["action_sequence"].append("clear_autoresume") -def register(foo): - foo.update({"stage4":stage4_target}) - return foo +__target_map = {"stage4":stage4_target} diff --git a/modules/catalyst/target/tinderbox_target.py b/modules/catalyst/target/tinderbox_target.py index 42ad6eb8..c4618db6 100644 --- a/modules/catalyst/target/tinderbox_target.py +++ b/modules/catalyst/target/tinderbox_target.py @@ -35,6 +35,4 @@ class tinderbox_target(generic_stage_target): "setup_environment","run_local","preclean","unbind","clean",\ "clear_autoresume"] -def register(foo): - foo.update({"tinderbox":tinderbox_target}) - return foo +__target_map = {"tinderbox":tinderbox_target} diff --git a/modules/catalyst_support.py b/modules/catalyst_support.py index 20d8b6f5..5f51d6ca 100644 --- a/modules/catalyst_support.py +++ b/modules/catalyst_support.py @@ -192,14 +192,6 @@ def read_from_clst(file): return myline # read_from_clst -# these should never be touched -required_build_targets=["generic_target","generic_stage_target"] - -# new build types should be added here -valid_build_targets=["stage1_target","stage2_target","stage3_target","stage4_target","grp_target", - "livecd_stage1_target","livecd_stage2_target","embedded_target", - "tinderbox_target","snapshot_target","netboot_target","netboot2_target"] - required_config_file_values=["storedir","sharedir","distdir","portdir"] valid_config_file_values=required_config_file_values[:] valid_config_file_values.append("PKGCACHE")