1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
"""
netboot target, version 1
"""
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
import os
import types
from catalyst import log
from catalyst.support import (CatalystError, normpath,
cmd, list_bashify, file_locate)
from catalyst.base.stagebase import StageBase
class netboot(StageBase):
"""
Builder class for a netboot build.
"""
def __init__(self,spec,addlargs):
self.valid_values = [
"netboot/kernel/sources",
"netboot/kernel/config",
"netboot/kernel/prebuilt",
"netboot/busybox_config",
"netboot/extra_files",
"netboot/packages"
]
self.required_values=[]
try:
# XXX: This code does nothing because the for loop below is disabled.
if "netboot/packages" in addlargs:
if type(addlargs["netboot/packages"]) == types.StringType:
_loopy = [addlargs["netboot/packages"]]
else:
_loopy = addlargs["netboot/packages"]
# for x in loopy:
# self.required_values.append("netboot/packages/"+x+"/files")
except:
raise CatalystError("configuration error in netboot/packages.")
StageBase.__init__(self,spec,addlargs)
if "netboot/busybox_config" in addlargs:
file_locate(self.settings, ["netboot/busybox_config"])
# Custom Kernel Tarball --- use that instead ...
# unless the user wants specific CFLAGS/CXXFLAGS, let's use -Os
for envvar in "CFLAGS", "CXXFLAGS":
if envvar not in os.environ and envvar not in addlargs:
self.settings[envvar] = "-Os -pipe"
def set_root_path(self):
# ROOT= variable for emerges
self.settings["root_path"]=normpath("/tmp/image")
log.info('netboot root path is %s', self.settings['root_path'])
# def build_packages(self):
# # build packages
# if "netboot/packages" in self.settings:
# mypack=list_bashify(self.settings["netboot/packages"])
# try:
# cmd(self.settings["controller_file"]+" packages "+mypack,env=self.env)
# except CatalystError:
# self.unbind()
# raise CatalystError("netboot build aborting due to error.",
# print_traceback=True)
def build_busybox(self):
# build busybox
if "netboot/busybox_config" in self.settings:
mycmd = self.settings["netboot/busybox_config"]
else:
mycmd = ""
try:
cmd(self.settings["controller_file"]+" busybox "+ mycmd,env=self.env)
except CatalystError:
self.unbind()
raise CatalystError("netboot build aborting due to error.",
print_traceback=True)
def copy_files_to_image(self):
# create image
myfiles=[]
if "netboot/packages" in self.settings:
if type(self.settings["netboot/packages"]) == types.StringType:
loopy=[self.settings["netboot/packages"]]
else:
loopy=self.settings["netboot/packages"]
for x in loopy:
if "netboot/packages/"+x+"/files" in self.settings:
if type(self.settings["netboot/packages/"+x+"/files"]) == types.ListType:
myfiles.extend(self.settings["netboot/packages/"+x+"/files"])
else:
myfiles.append(self.settings["netboot/packages/"+x+"/files"])
if "netboot/extra_files" in self.settings:
if type(self.settings["netboot/extra_files"]) == types.ListType:
myfiles.extend(self.settings["netboot/extra_files"])
else:
myfiles.append(self.settings["netboot/extra_files"])
try:
cmd(self.settings["controller_file"]+\
" image " + list_bashify(myfiles),env=self.env)
except CatalystError:
self.unbind()
raise CatalystError("netboot build aborting due to error.",
print_traceback=True)
def create_netboot_files(self):
# finish it all up
try:
cmd(self.settings["controller_file"]+" finish",env=self.env)
except CatalystError:
self.unbind()
raise CatalystError("netboot build aborting due to error.",
print_traceback=True)
# end
log.notice('netboot: build finished !')
def set_action_sequence(self):
self.settings["action_sequence"]=["unpack","unpack_snapshot",
"config_profile_link","setup_confdir","bind","chroot_setup",\
"setup_environment","build_packages","build_busybox",\
"build_kernel","copy_files_to_image",\
"clean","create_netboot_files","unbind","clear_autoresume"]
|