-# these should never be touched
-required_build_targets = ["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[:]
import os
import sys
-import imp
import getopt
import os.path
__selfpath__ = os.path.abspath(os.path.dirname(__file__))
-sys.path.append(__selfpath__ + "/modules")
import catalyst.config
import catalyst.util
from catalyst.lock import LockInUse
from catalyst.support import CatalystError, find_binary
-from catalyst.defaults import (required_build_targets, valid_build_targets,
- hash_definitions, confdefaults, option_messages
- )
-
+from catalyst.defaults import hash_definitions, confdefaults, option_messages
from hash_utils import HashMap
from defaults import contents_definitions
from contents import ContentsMap
print "Envscript support enabled."
-def import_modules():
- # import catalyst's own modules (i.e. catalyst_support and the arch modules)
- targetmap={}
-
+def import_module(target):
+ """
+ import catalyst's own modules
+ (i.e. targets and the arch modules)
+ """
try:
- module_dir = __selfpath__ + "/targets/"
- for x in required_build_targets:
- try:
- fh = open(module_dir + x + ".py")
- module = imp.load_module(x, fh, "targets/" + x + ".py",
- (".py", "r", imp.PY_SOURCE))
- fh.close()
-
- except IOError:
- raise CatalystError("Can't find " + x + ".py plugin in " +
- module_dir, print_traceback=True)
- for x in valid_build_targets:
- try:
- fh = open(module_dir + x + ".py")
- module = imp.load_module(x, fh, "targets/" + x + ".py",
- (".py", "r", imp.PY_SOURCE))
- module.register(targetmap)
- fh.close()
-
- except IOError:
- raise CatalystError("Can't find " + x + ".py plugin in " +
- module_dir, print_traceback=True)
-
+ mod_name = "catalyst.targets." + target
+ module = __import__(mod_name, [],[], ["not empty"])
except ImportError as e:
- print "!!! catalyst: Python modules not found in "+\
- module_dir + "; exiting."
- print e
+ print "!!! catalyst: Python module import error: %s " % target + \
+ "in catalyst/targets/ ... exiting."
+ print "ERROR was: ", e
sys.exit(1)
+ return module
- return targetmap
-def build_target(addlargs, targetmap):
+def build_target(addlargs):
try:
- if addlargs["target"] not in targetmap:
- raise CatalystError(
- "Target \"%s\" not available." % addlargs["target"],
- print_traceback=True)
-
- mytarget=targetmap[addlargs["target"]](conf_values, addlargs)
-
- mytarget.run()
+ module = import_module(addlargs["target"])
+ target = getattr(module, addlargs["target"])(conf_values, addlargs)
+ except AttributeError:
+ raise CatalystError(
+ "Target \"%s\" not available." % addlargs["target"],
+ print_traceback=True)
+ try:
+ target.run()
except:
- print "Python traceback output follows:"
+ print "Target run() exception: Python traceback output follows:"
catalyst.util.print_traceback()
print
print "!!! catalyst: Error encountered during run of target " + \
sys.exit(1)
def main():
- targetmap={}
version()
if os.getuid() != 0:
print "Catalyst aborting...."
sys.exit(2)
- # import the rest of the catalyst modules
- targetmap=import_modules()
-
addlargs={}
if myspecfile:
# everything is setup, so the build is a go
try:
- build_target(addlargs, targetmap)
+ build_target(addlargs)
except CatalystError:
print
def set_root_path(self):
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
"config_profile_link","setup_confdir","portage_overlay","bind","chroot_setup",\
"setup_environment","run_local","unbind",\
"generate_digests","clear_autoresume"]
-
-def register(foo):
- foo.update({"grp":grp_target})
- return foo
self.settings["pkgcache_path"]=normpath(string.join(self.settings["pkgcache_path"]))
else:
StageBase.set_pkgcache_path(self)
-
-def register(foo):
- foo.update({"livecd-stage1":livecd_stage1_target})
- return foo
"unbind","remove","empty","target_setup",\
"setup_overlay","create_iso"]
self.settings["action_sequence"].append("clear_autoresume")
-
-def register(foo):
- foo.update({"livecd-stage2":livecd_stage2_target})
- return foo
"setup_environment","build_packages","root_overlay",\
"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
"setup_environment","build_packages","build_busybox",\
"build_kernel","copy_files_to_image",\
"clean","create_netboot_files","unbind","clear_autoresume"]
-
-def register(foo):
- foo.update({"netboot":netboot_target})
- return foo
from catalyst.base.targetbase import TargetBase
from catalyst.base.genbase import GenBase
-class snapshot_target(TargetBase, GenBase):
+class snapshot(TargetBase, GenBase):
"""
Builder class for snapshots.
"""
os.makedirs(myemp,0755)
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
# alter the mount mappings to bind mount proc onto it
self.mounts.append("/tmp/stage1root/proc")
self.mountmap["/tmp/stage1root/proc"]="/proc"
-
-def register(foo):
- foo.update({"stage1":stage1_target})
- return foo
print "\tUsing an portage overlay for earlier stages could cause build issues."
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
def set_cleanables(self):
StageBase.set_cleanables(self)
-
-def register(foo):
- foo.update({"stage3":stage3_target})
- return foo
if "fetch" not in self.settings['options']:
self.settings["action_sequence"].append("capture")
self.settings["action_sequence"].append("clear_autoresume")
-
-def register(foo):
- foo.update({"stage4":stage4_target})
- return foo
-
"config_profile_link","setup_confdir","bind","chroot_setup",\
"setup_environment","run_local","preclean","unbind","clean",\
"clear_autoresume"]
-
-def register(foo):
- foo.update({"tinderbox":tinderbox_target})
- return foo