3 Builder class for a netboot build.
7 from catalyst.support import *
8 from generic_stage import *
10 from catalyst.error import *
11 from catalyst.spawn import *
13 class netboot_target(generic_stage_target):
14 def __init__(self,spec,addlargs):
16 "netboot/kernel/sources",
17 "netboot/kernel/config",
18 "netboot/kernel/prebuilt",
20 "netboot/busybox_config",
22 "netboot/extra_files",
25 self.required_values=[]
28 if "netboot/packages" in addlargs:
29 if type(addlargs["netboot/packages"]) == types.StringType:
30 loopy=[addlargs["netboot/packages"]]
32 loopy=addlargs["netboot/packages"]
35 # self.required_values.append("netboot/packages/"+x+"/files")
37 raise CatalystError,"configuration error in netboot/packages."
42 generic_stage_target.__init__(self,spec,addlargs)
43 self.set_build_kernel_vars(addlargs)
44 if "netboot/busybox_config" in addlargs:
45 file_locate(self.settings, ["netboot/busybox_config"])
47 # Custom Kernel Tarball --- use that instead ...
49 # unless the user wants specific CFLAGS/CXXFLAGS, let's use -Os
51 for envvar in "CFLAGS", "CXXFLAGS":
52 if not envvar in os.environ and not envvar in addlargs:
53 self.settings[envvar] = "-Os -pipe"
56 def set_root_path(self):
57 # ROOT= variable for emerges
58 self.settings["root_path"]=catalyst.util.normpath("/tmp/image")
59 print "netboot root path is "+self.settings["root_path"]
61 # def build_packages(self):
63 # if "netboot/packages" in self.settings:
64 # mypack = catalyst.util.list_bashify(self.settings["netboot/packages"])
66 # cmd("/bin/bash "+self.settings["controller_file"]+" packages "+mypack,env=self.env)
67 # except CatalystError:
69 # raise CatalystError,"netboot build aborting due to error."
71 def build_busybox(self):
73 if "netboot/busybox_config" in self.settings:
74 mycmd = self.settings["netboot/busybox_config"]
78 cmd("/bin/bash "+self.settings["controller_file"]+" busybox "+ mycmd,env=self.env)
81 raise CatalystError,"netboot build aborting due to error."
84 def copy_files_to_image(self):
87 if "netboot/packages" in self.settings:
88 if type(self.settings["netboot/packages"]) == types.StringType:
89 loopy=[self.settings["netboot/packages"]]
91 loopy=self.settings["netboot/packages"]
94 if "netboot/packages/"+x+"/files" in self.settings:
95 if type(self.settings["netboot/packages/"+x+"/files"]) == types.ListType:
96 myfiles.extend(self.settings["netboot/packages/"+x+"/files"])
98 myfiles.append(self.settings["netboot/packages/"+x+"/files"])
100 if "netboot/extra_files" in self.settings:
101 if type(self.settings["netboot/extra_files"]) == types.ListType:
102 myfiles.extend(self.settings["netboot/extra_files"])
104 myfiles.append(self.settings["netboot/extra_files"])
107 cmd("/bin/bash "+self.settings["controller_file"]+\
108 " image " + catalyst.util.list_bashify(myfiles),env=self.env)
109 except CatalystError:
111 raise CatalystError,"netboot build aborting due to error."
114 def create_netboot_files(self):
117 cmd("/bin/bash "+self.settings["controller_file"]+" finish",env=self.env)
118 except CatalystError:
120 raise CatalystError,"netboot build aborting due to error."
123 print "netboot: build finished !"
126 def set_action_sequence(self):
127 self.settings["action_sequence"]=["unpack","unpack_snapshot",
128 "config_profile_link","setup_confdir","bind","chroot_setup",\
129 "setup_environment","build_packages","build_busybox",\
130 "build_kernel","copy_files_to_image",\
131 "clean","create_netboot_files","unbind","clear_autoresume"]
133 __target_map = {"netboot":netboot_target}