Add target map in each target module and remove register() function
authorAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 01:30:24 +0000 (19:30 -0600)
committerAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 01:30:24 +0000 (19:30 -0600)
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

15 files changed:
ChangeLog
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

index 7cab21fce58d2e90a19e64ad2c92d5f5f86c052f..758c6a1b0d3b37c7ff1c6822f2e8ee79e555468b 100644 (file)
--- 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 <agaffney@gentoo.org> 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 <agaffney@gentoo.org>
   +modules/catalyst/target/__init__.py,
   +modules/catalyst/target/embedded_target.py,
index 43bc47d162550b225e5df123415a0b4642551e59..4de6fe48609258497fb4405fbaf428f6f827e856 100755 (executable)
--- 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
 
index 2ab8cc5a243ece31226a296c1fd2d7e02b76f169..f1b244c9e9bf71683a273ddd4f186ac4ab50875f 100644 (file)
@@ -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}
index b077d9c855b7f420df9dc1b0747d60b6b308f3ae..f0806bdbf5405168263e02f16d413880fef012ad 100644 (file)
@@ -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}
index 0d5c97c8a129eefdf4fa41dfbd6b38f40c1da099..9f75cea9c72d5972ccdd6fc463a346ce91d74d00 100644 (file)
@@ -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}
index 147148f7d8cde0b0b91e8e13e5b329cad810c540..237108ba8fc9c4d0c98992c038f2dd2a174f845f 100644 (file)
@@ -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}
index 444f873c098324e71c4b69934e0e2562bbf4465d..fd29e48727764218c6c901e26205cefa0c0d079a 100644 (file)
@@ -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}
index 92c1b0452918b3035763049370b66ca4363a31a7..b0b55f00e3d58da5b8c0f5f839f7b14b64b419cd 100644 (file)
@@ -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}
index 0609377b8c1e9a9b5e562ccd8cc2110de1247a71..a8873cfa7ea40ef7e8c582fa4b8a42d978a07f4c 100644 (file)
@@ -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}
index a6eb435201c6e1a77a1ccda7b9bf1f687568ec8c..aa5360f8c5273922daccefcc06e3f73bcb5f527d 100644 (file)
@@ -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}
index a5135b250c95dcc0df4033903c35116950106635..428d98efb1eaa3e11c858cee46dd3ca874084cc3 100644 (file)
@@ -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}
index 7e087cb25813151aad8ffa51b177af7daf3a95f6..e7d6632e18972cc83273031532395cc2a4b39972 100644 (file)
@@ -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}
index cc8e6c0287e12e98628fa030273977d70ce14b90..486ad60bf32da005e706297be04e3a68c30c022c 100644 (file)
@@ -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}
 
index 42ad6eb8a656fec5a1a7fbe6720ffe3b5fa6d329..c4618db623bff3dcbee604dfe84d07c4d6cbcbbb 100644 (file)
@@ -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}
index 20d8b6f5545a146c86d2c511c560e0ab7b5dbfd5..5f51d6cac1bbfb3afa3254d19d82d404d84ced75 100644 (file)
@@ -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")