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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
import string
import os
from bootloaderInfo import *
import fsset
import iutil
import rhpl
class ppcBootloaderInfo(bootloaderInfo):
def getBootDevs(self, fs, bl):
import fsset
devs = []
machine = rhpl.getPPCMachine()
if machine == 'pSeries':
for entry in fs.entries:
if isinstance(entry.fsystem, fsset.prepbootFileSystem) \
and entry.format:
devs.append('/dev/%s' % (entry.device.getDevice(),))
elif machine == 'PMac':
for entry in fs.entries:
if isinstance(entry.fsystem, fsset.applebootstrapFileSystem) \
and entry.format:
devs.append('/dev/%s' % (entry.device.getDevice(),))
if len(devs) == 0:
# Try to get a boot device; bplan OF understands ext3
if machine == 'Pegasos' or machine == 'Efika':
try:
device = storage.fsset.mountpoints["/boot"]
except KeyError:
try:
# Try / if we don't have this we're not going to work
device = storage.fsset.mountpoints["/"]
except KeyError:
return devs
devs.append(device.path)
else:
if bl.getDevice():
devs.append("/dev/%s" % bl.getDevice())
return devs
def writeYaboot(self, instRoot, bl, kernelList,
chainList, defaultDev, justConfigFile):
yabootTarget = string.join(self.getBootDevs(bl))
try:
bootDev = storage.fsset.mountpoints["/boot"]
cf = "/boot/etc/yaboot.conf"
cfPath = ""
if not os.path.isdir(instRoot + "/boot/etc"):
os.mkdir(instRoot + "/boot/etc")
except KeyError:
bootDev = storage.fsset.mountpoints["/"]
cfPath = "/boot"
cf = "/etc/yaboot.conf"
f = open(instRoot + cf, "w+")
f.write("# yaboot.conf generated by anaconda\n\n")
f.write("boot=%s\n" %(yabootTarget,))
f.write("init-message=\"Welcome to %s!\\nHit <TAB> for boot options\"\n\n"
% productName)
(name, partNum) = getDiskPart(bootDev)
partno = partNum + 1 # 1 based
f.write("partition=%s\n" %(partno,))
f.write("timeout=%s\n" % (self.timeout or 80))
f.write("install=/usr/lib/yaboot/yaboot\n")
f.write("delay=5\n")
f.write("enablecdboot\n")
f.write("enableofboot\n")
f.write("enablenetboot\n")
yabootProg = "/sbin/mkofboot"
if rhpl.getPPCMachine() == "PMac":
# write out the first hfs/hfs+ partition as being macosx
for (label, longlabel, device) in chainList:
if ((not label) or (label == "")):
continue
f.write("macosx=/dev/%s\n" %(device,))
break
f.write("magicboot=/usr/lib/yaboot/ofboot\n")
elif rhpl.getPPCMachine() == "pSeries":
f.write("nonvram\n")
f.write("fstype=raw\n")
else: # Default non-destructive case for anything else.
f.write("nonvram\n")
f.write("mntpoint=/boot/yaboot\n")
f.write("usemount\n")
if not os.access(instRoot + "/boot/yaboot", os.R_OK):
os.mkdir(instRoot + "/boot/yaboot")
yabootProg = "/sbin/ybin"
if self.password:
f.write("password=%s\n" %(self.password,))
f.write("restricted\n")
f.write("\n")
rootDev = storage.fsset.mountpoints["/"]
for (label, longlabel, version) in kernelList:
kernelTag = "-" + version
kernelFile = "%s/vmlinuz%s" %(cfPath, kernelTag)
f.write("image=%s\n" %(kernelFile,))
f.write("\tlabel=%s\n" %(label,))
f.write("\tread-only\n")
initrd = self.makeInitrd(kernelTag)
if os.access(instRoot + initrd, os.R_OK):
f.write("\tinitrd=%s/initrd%s.img\n" %(cfPath,kernelTag))
append = "%s" %(self.args.get(),)
realroot = getRootDevName(instRoot+initrd, rootDev.path)
if rootIsDevice(realroot):
f.write("\troot=%s\n" %(realroot,))
else:
if len(append) > 0:
append = "%s root=%s" %(append,realroot)
else:
append = "root=%s" %(realroot,)
if len(append) > 0:
f.write("\tappend=\"%s\"\n" %(append,))
f.write("\n")
f.close()
os.chmod(instRoot + cf, 0600)
# FIXME: hack to make sure things are written to disk
import isys
isys.sync()
isys.sync()
isys.sync()
ybinargs = [ yabootProg, "-f", "-C", cf ]
if not flags.test:
iutil.execWithRedirect(ybinargs[0],
ybinargs,
stdout = "/dev/tty5",
stderr = "/dev/tty5",
root = instRoot)
if (not os.access(instRoot + "/etc/yaboot.conf", os.R_OK) and
os.access(instRoot + "/boot/etc/yaboot.conf", os.R_OK)):
os.symlink("../boot/etc/yaboot.conf",
instRoot + "/etc/yaboot.conf")
return ""
def setPassword(self, val, isCrypted = 1):
# yaboot just handles the password and doesn't care if its crypted
# or not
self.password = val
def write(self, instRoot, bl, kernelList, chainList,
defaultDev, justConfig, intf):
if len(kernelList) >= 1:
out = self.writeYaboot(instRoot, bl, kernelList,
chainList, defaultDev, justConfig)
else:
self.noKernelsWarn(intf)
def __init__(self):
bootloaderInfo.__init__(self)
self.useYabootVal = 1
self.kernelLocation = "/boot"
self.configfile = "/etc/yaboot.conf"
|