2 netboot target, version 1
4 # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
7 from catalyst_support import *
8 from generic_stage_target import *
10 class netboot_target(generic_stage_target):
12 Builder class for a netboot build.
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."
39 generic_stage_target.__init__(self,spec,addlargs)
40 self.set_build_kernel_vars(addlargs)
41 if "netboot/busybox_config" in addlargs:
42 file_locate(self.settings, ["netboot/busybox_config"])
44 # Custom Kernel Tarball --- use that instead ...
46 # unless the user wants specific CFLAGS/CXXFLAGS, let's use -Os
48 for envvar in "CFLAGS", "CXXFLAGS":
49 if envvar not in os.environ and envvar not in addlargs:
50 self.settings[envvar] = "-Os -pipe"
52 def set_root_path(self):
53 # ROOT= variable for emerges
54 self.settings["root_path"]=normpath("/tmp/image")
55 print "netboot root path is "+self.settings["root_path"]
57 # def build_packages(self):
59 # if "netboot/packages" in self.settings:
60 # mypack=list_bashify(self.settings["netboot/packages"])
62 # cmd("/bin/bash "+self.settings["controller_file"]+" packages "+mypack,env=self.env)
63 # except CatalystError:
65 # raise CatalystError,"netboot build aborting due to error."
67 def build_busybox(self):
69 if "netboot/busybox_config" in self.settings:
70 mycmd = self.settings["netboot/busybox_config"]
74 cmd("/bin/bash "+self.settings["controller_file"]+" busybox "+ mycmd,env=self.env)
77 raise CatalystError,"netboot build aborting due to error."
79 def copy_files_to_image(self):
82 if "netboot/packages" in self.settings:
83 if type(self.settings["netboot/packages"]) == types.StringType:
84 loopy=[self.settings["netboot/packages"]]
86 loopy=self.settings["netboot/packages"]
89 if "netboot/packages/"+x+"/files" in self.settings:
90 if type(self.settings["netboot/packages/"+x+"/files"]) == types.ListType:
91 myfiles.extend(self.settings["netboot/packages/"+x+"/files"])
93 myfiles.append(self.settings["netboot/packages/"+x+"/files"])
95 if "netboot/extra_files" in self.settings:
96 if type(self.settings["netboot/extra_files"]) == types.ListType:
97 myfiles.extend(self.settings["netboot/extra_files"])
99 myfiles.append(self.settings["netboot/extra_files"])
102 cmd("/bin/bash "+self.settings["controller_file"]+\
103 " image " + list_bashify(myfiles),env=self.env)
104 except CatalystError:
106 raise CatalystError,"netboot build aborting due to error."
108 def create_netboot_files(self):
111 cmd("/bin/bash "+self.settings["controller_file"]+" finish",env=self.env)
112 except CatalystError:
114 raise CatalystError,"netboot build aborting due to error."
117 print "netboot: build finished !"
119 def set_action_sequence(self):
120 self.settings["action_sequence"]=["unpack","unpack_snapshot",
121 "config_profile_link","setup_confdir","bind","chroot_setup",\
122 "setup_environment","build_packages","build_busybox",\
123 "build_kernel","copy_files_to_image",\
124 "clean","create_netboot_files","unbind","clear_autoresume"]
127 foo.update({"netboot":netboot_target})