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
|
"""
LiveCD stage2 target, builds upon previous LiveCD stage1 tarball
"""
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
from catalyst.support import (normpath, file_locate, CatalystError)
from catalyst.fileops import clear_dir
from catalyst.base.stagebase import StageBase
class livecd_stage2(StageBase):
"""
Builder class for a LiveCD stage2 build.
"""
required_values = frozenset([
"boot/kernel",
])
valid_values = required_values | frozenset([
"livecd/bootargs",
"livecd/cdtar",
"livecd/depclean",
"livecd/empty",
"livecd/fsops",
"livecd/fsscript",
"livecd/fstype",
"livecd/gk_mainargs",
"livecd/iso",
"livecd/linuxrc",
"livecd/modblacklist",
"livecd/motd",
"livecd/overlay",
"livecd/rcadd",
"livecd/rcdel",
"livecd/readme",
"livecd/rm",
"livecd/root_overlay",
"livecd/type",
"livecd/unmerge",
"livecd/users",
"livecd/verify",
"livecd/volid",
"livecd/xdm",
"livecd/xinitrc",
"livecd/xsession",
"portage_overlay",
])
def __init__(self, spec, addlargs):
StageBase.__init__(self, spec, addlargs)
if "livecd/type" not in self.settings:
self.settings["livecd/type"] = "generic-livecd"
file_locate(self.settings, ["cdtar", "controller_file"])
def set_spec_prefix(self):
self.settings["spec_prefix"] = "livecd"
def set_target_path(self):
'''Set the target path for the finished stage.
This method runs the StageBase.set_target_path mehtod,
and additionally creates a staging directory for assembling
the final components needed to produce the iso image.
'''
super(livecd_stage2, self).set_target_path()
clear_dir(self.settings['target_path'])
def run_local(self):
# what modules do we want to blacklist?
if "livecd/modblacklist" in self.settings:
path = normpath(self.settings["chroot_path"] +
"/etc/modprobe.d/blacklist.conf")
try:
with open(path, "a") as myf:
myf.write("\n#Added by Catalyst:")
# workaround until config.py is using configparser
if isinstance(self.settings["livecd/modblacklist"], str):
self.settings["livecd/modblacklist"] = self.settings[
"livecd/modblacklist"].split()
for x in self.settings["livecd/modblacklist"]:
myf.write("\nblacklist "+x)
except Exception as e:
raise CatalystError("Couldn't open " +
self.settings["chroot_path"] +
"/etc/modprobe.d/blacklist.conf.",
print_traceback=True) from e
def set_action_sequence(self):
self.build_sequence.extend([
self.run_local,
self.build_kernel
])
if "fetch" not in self.settings["options"]:
self.build_sequence.extend([
self.bootloader,
self.preclean,
self.livecd_update,
self.root_overlay,
self.fsscript,
self.rcupdate,
self.unmerge,
])
self.finish_sequence.extend([
self.remove,
self.empty,
self.clean,
self.target_setup,
self.setup_overlay,
self.create_iso,
])
self.finish_sequence.append(self.clear_autoresume)
|