/[smeserver]/rpms/booty/sme7/0001-Backport-RHEL5-boot-installer.patch
ViewVC logotype

Contents of /rpms/booty/sme7/0001-Backport-RHEL5-boot-installer.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Tue Oct 27 04:23:18 2009 UTC (15 years, 1 month ago) by slords
Branch: MAIN
CVS Tags: HEAD
Updates

1 From 93fcd3224a342b905b31d40da2058d3ea910eb0c Mon Sep 17 00:00:00 2001
2 From: Shad L. Lords <slords@mail.com>
3 Date: Mon, 26 Oct 2009 22:16:17 -0600
4 Subject: [PATCH] Backport RHEL5 boot installer
5
6 ---
7 bootloaderInfo.py | 884 +++++++++++++++++++++++++++++-----------------------
8 checkbootloader.py | 85 ++++--
9 2 files changed, 559 insertions(+), 410 deletions(-)
10
11 diff --git a/bootloaderInfo.py b/bootloaderInfo.py
12 index 57caaf9..3668ee8 100644
13 --- a/bootloaderInfo.py
14 +++ b/bootloaderInfo.py
15 @@ -4,8 +4,9 @@
16 #
17 # Jeremy Katz <katzj@redhat.com>
18 # Erik Troan <ewt@redhat.com>
19 +# Peter Jones <pjones@redhat.com>
20 #
21 -# Copyright 2002 Red Hat, Inc.
22 +# Copyright 2005 Red Hat, Inc.
23 #
24 # This software may be freely redistributed under the terms of the GNU
25 # library public license.
26 @@ -76,10 +77,10 @@ class BootyNoKernelWarning:
27 class KernelArguments:
28
29 def get(self):
30 - return self.args
31 + return self.args
32
33 def set(self, args):
34 - self.args = args
35 + self.args = args
36
37 def chandevget(self):
38 return self.cargs
39 @@ -135,13 +136,13 @@ class KernelArguments:
40 class BootImages:
41 # returns dictionary of (label, longlabel, devtype) pairs indexed by device
42 def getImages(self):
43 - # return a copy so users can modify it w/o affecting us
44 + # return a copy so users can modify it w/o affecting us
45
46 - dict = {}
47 - for key in self.images.keys():
48 - dict[key] = self.images[key]
49 + dict = {}
50 + for key in self.images.keys():
51 + dict[key] = self.images[key]
52
53 - return dict
54 + return dict
55
56 def setImageLabel(self, dev, label, setLong = 0):
57 if setLong:
58 @@ -154,25 +155,25 @@ class BootImages:
59
60 # default is a device
61 def setDefault(self, default):
62 - self.default = default
63 + self.default = default
64
65 def getDefault(self):
66 - return self.default
67 + return self.default
68
69 # XXX this has internal anaconda-ish knowledge. ick
70 def setup(self, diskSet, fsset):
71 - devices = {}
72 - devs = self.availableBootDevices(diskSet, fsset)
73 - for (dev, type) in devs:
74 - devices[dev] = 1
75 -
76 - # These partitions have disappeared
77 - for dev in self.images.keys():
78 - if not devices.has_key(dev): del self.images[dev]
79 -
80 - # These have appeared
81 - for (dev, type) in devs:
82 - if not self.images.has_key(dev):
83 + devices = {}
84 + devs = self.availableBootDevices(diskSet, fsset)
85 + for (dev, type) in devs:
86 + devices[dev] = 1
87 +
88 + # These partitions have disappeared
89 + for dev in self.images.keys():
90 + if not devices.has_key(dev): del self.images[dev]
91 +
92 + # These have appeared
93 + for (dev, type) in devs:
94 + if not self.images.has_key(dev):
95 if type in dosFilesystems:
96 self.images[dev] = ("Other", "Other", type)
97 elif type in ("hfs", "hfs+") and butil.getPPCMachine() == "PMac":
98 @@ -181,12 +182,12 @@ class BootImages:
99 self.images[dev] = (None, None, type)
100
101
102 - if not self.images.has_key(self.default):
103 - entry = fsset.getEntryByMountPoint('/')
104 - self.default = entry.device.getDevice()
105 - (label, longlabel, type) = self.images[self.default]
106 - if not label:
107 - self.images[self.default] = ("linux",
108 + if not self.images.has_key(self.default):
109 + entry = fsset.getEntryByMountPoint('/')
110 + self.default = entry.device.getDevice()
111 + (label, longlabel, type) = self.images[self.default]
112 + if not label:
113 + self.images[self.default] = ("linux",
114 butil.getProductName(), type)
115
116 # XXX more internal anaconda knowledge
117 @@ -208,7 +209,7 @@ class BootImages:
118 devs.append((dev, type))
119 foundDos = 1
120 except Exception, e:
121 - log("exception checking %s: %s" %(dev, e))
122 + #log("exception checking %s: %s" %(dev, e))
123 pass
124 elif ((type == 'ntfs' or type =='hpfs') and not foundDos
125 and doesDualBoot()):
126 @@ -222,7 +223,7 @@ class BootImages:
127
128 part = partedUtils.get_partition_by_name(diskSet.disks, dev)
129 if partedUtils.get_flags(part) != "boot":
130 - devs.append((dev, type))
131 + devs.append((dev, type))
132
133 slash = fsset.getEntryByMountPoint('/')
134 if not slash or not slash.device or not slash.fsystem:
135 @@ -237,16 +238,16 @@ class BootImages:
136
137
138 def __init__(self):
139 - self.default = None
140 - self.images = {}
141 + self.default = None
142 + self.images = {}
143
144
145 class bootloaderInfo:
146 def setUseGrub(self, val):
147 - pass
148 + pass
149
150 def useGrub(self):
151 - return self.useGrubVal
152 + return self.useGrubVal
153
154 def setForceLBA(self, val):
155 pass
156 @@ -276,62 +277,62 @@ class bootloaderInfo:
157 # dictionary of mounted filesystems since that's what we care about
158 def getBootloaderConfig(self, instRoot, fsset, bl, langs, kernelList,
159 chainList, defaultDev):
160 - images = bl.images.getImages()
161 + images = bl.images.getImages()
162
163 # on upgrade read in the lilo config file
164 - lilo = LiloConfigFile ()
165 - self.perms = 0600
166 + lilo = LiloConfigFile ()
167 + self.perms = 0600
168 if os.access (instRoot + self.configfile, os.R_OK):
169 - self.perms = os.stat(instRoot + self.configfile)[0] & 0777
170 - lilo.read (instRoot + self.configfile)
171 - os.rename(instRoot + self.configfile,
172 - instRoot + self.configfile + '.rpmsave')
173 + self.perms = os.stat(instRoot + self.configfile)[0] & 0777
174 + lilo.read (instRoot + self.configfile)
175 + os.rename(instRoot + self.configfile,
176 + instRoot + self.configfile + '.rpmsave')
177 # if it's an absolute symlink, just get it out of our way
178 elif (os.path.islink(instRoot + self.configfile) and
179 os.readlink(instRoot + self.configfile)[0] == '/'):
180 os.rename(instRoot + self.configfile,
181 instRoot + self.configfile + '.rpmsave')
182
183 - # Remove any invalid entries that are in the file; we probably
184 - # just removed those kernels.
185 - for label in lilo.listImages():
186 - (fsType, sl, path, other) = lilo.getImage(label)
187 - if fsType == "other": continue
188 + # Remove any invalid entries that are in the file; we probably
189 + # just removed those kernels.
190 + for label in lilo.listImages():
191 + (fsType, sl, path, other) = lilo.getImage(label)
192 + if fsType == "other": continue
193
194 - if not os.access(instRoot + sl.getPath(), os.R_OK):
195 - lilo.delImage(label)
196 + if not os.access(instRoot + sl.getPath(), os.R_OK):
197 + lilo.delImage(label)
198
199 - lilo.addEntry("prompt", replace = 0)
200 - lilo.addEntry("timeout", "20", replace = 0)
201 + lilo.addEntry("prompt", replace = 0)
202 + lilo.addEntry("timeout", "20", replace = 0)
203
204 rootDev = fsset.getEntryByMountPoint("/").device.getDevice()
205 - if not rootDev:
206 + if not rootDev:
207 raise RuntimeError, "Installing lilo, but there is no root device"
208
209 - if rootDev == defaultDev:
210 - lilo.addEntry("default", kernelList[0][0])
211 - else:
212 - lilo.addEntry("default", chainList[0][0])
213 + if rootDev == defaultDev:
214 + lilo.addEntry("default", kernelList[0][0])
215 + else:
216 + lilo.addEntry("default", chainList[0][0])
217
218 - for (label, longlabel, version) in kernelList:
219 - kernelTag = "-" + version
220 - kernelFile = self.kernelLocation + "vmlinuz" + kernelTag
221 + for (label, longlabel, version) in kernelList:
222 + kernelTag = "-" + version
223 + kernelFile = self.kernelLocation + "vmlinuz" + kernelTag
224
225 - try:
226 - lilo.delImage(label)
227 - except IndexError, msg:
228 - pass
229 + try:
230 + lilo.delImage(label)
231 + except IndexError, msg:
232 + pass
233
234 - sl = LiloConfigFile(imageType = "image", path = kernelFile)
235 + sl = LiloConfigFile(imageType = "image", path = kernelFile)
236
237 - initrd = booty.makeInitrd (kernelTag, instRoot)
238 + initrd = booty.makeInitrd (kernelTag, instRoot)
239
240 - sl.addEntry("label", label)
241 - if os.access (instRoot + initrd, os.R_OK):
242 - sl.addEntry("initrd", "%sinitrd%s.img" %(self.kernelLocation,
243 + sl.addEntry("label", label)
244 + if os.access (instRoot + initrd, os.R_OK):
245 + sl.addEntry("initrd", "%sinitrd%s.img" %(self.kernelLocation,
246 kernelTag))
247
248 - sl.addEntry("read-only")
249 + sl.addEntry("read-only")
250
251 append = "%s" %(self.args.get(),)
252 realroot = getRootDevName(initrd, fsset, rootDev, instRoot)
253 @@ -343,57 +344,57 @@ class bootloaderInfo:
254 else:
255 append = "root=%s" %(realroot,)
256
257 - if len(append) > 0:
258 - sl.addEntry('append', '"%s"' % (append,))
259 -
260 - lilo.addImage (sl)
261 + if len(append) > 0:
262 + sl.addEntry('append', '"%s"' % (append,))
263
264 - for (label, longlabel, device) in chainList:
265 + lilo.addImage (sl)
266 +
267 + for (label, longlabel, device) in chainList:
268 if ((not label) or (label == "")):
269 continue
270 - try:
271 - (fsType, sl, path, other) = lilo.getImage(label)
272 - lilo.delImage(label)
273 - except IndexError:
274 - sl = LiloConfigFile(imageType = "other",
275 + try:
276 + (fsType, sl, path, other) = lilo.getImage(label)
277 + lilo.delImage(label)
278 + except IndexError:
279 + sl = LiloConfigFile(imageType = "other",
280 path = "/dev/%s" %(device))
281 - sl.addEntry("optional")
282 -
283 - sl.addEntry("label", label)
284 - lilo.addImage (sl)
285 -
286 - # Sanity check #1. There could be aliases in sections which conflict
287 - # with the new images we just created. If so, erase those aliases
288 - imageNames = {}
289 - for label in lilo.listImages():
290 - imageNames[label] = 1
291 -
292 - for label in lilo.listImages():
293 - (fsType, sl, path, other) = lilo.getImage(label)
294 - if sl.testEntry('alias'):
295 - alias = sl.getEntry('alias')
296 - if imageNames.has_key(alias):
297 - sl.delEntry('alias')
298 - imageNames[alias] = 1
299 -
300 - # Sanity check #2. If single-key is turned on, go through all of
301 - # the image names (including aliases) (we just built the list) and
302 - # see if single-key will still work.
303 - if lilo.testEntry('single-key'):
304 - singleKeys = {}
305 - turnOff = 0
306 - for label in imageNames.keys():
307 - l = label[0]
308 - if singleKeys.has_key(l):
309 - turnOff = 1
310 - singleKeys[l] = 1
311 - if turnOff:
312 - lilo.delEntry('single-key')
313 + sl.addEntry("optional")
314 +
315 + sl.addEntry("label", label)
316 + lilo.addImage (sl)
317 +
318 + # Sanity check #1. There could be aliases in sections which conflict
319 + # with the new images we just created. If so, erase those aliases
320 + imageNames = {}
321 + for label in lilo.listImages():
322 + imageNames[label] = 1
323 +
324 + for label in lilo.listImages():
325 + (fsType, sl, path, other) = lilo.getImage(label)
326 + if sl.testEntry('alias'):
327 + alias = sl.getEntry('alias')
328 + if imageNames.has_key(alias):
329 + sl.delEntry('alias')
330 + imageNames[alias] = 1
331 +
332 + # Sanity check #2. If single-key is turned on, go through all of
333 + # the image names (including aliases) (we just built the list) and
334 + # see if single-key will still work.
335 + if lilo.testEntry('single-key'):
336 + singleKeys = {}
337 + turnOff = 0
338 + for label in imageNames.keys():
339 + l = label[0]
340 + if singleKeys.has_key(l):
341 + turnOff = 1
342 + singleKeys[l] = 1
343 + if turnOff:
344 + lilo.delEntry('single-key')
345
346 return lilo
347
348 def write(self, instRoot, fsset, bl, langs, kernelList, chainList,
349 - defaultDev, justConfig, intf = None):
350 + defaultDev, justConfig, intf = None):
351 if len(kernelList) >= 1:
352 config = self.getBootloaderConfig(instRoot, fsset, bl, langs,
353 kernelList, chainList,
354 @@ -419,6 +420,7 @@ class bootloaderInfo:
355 return args
356
357 args.append("--location=%s" % (self.defaultDevice,))
358 + args.append("--driveorder=%s" % (",".join(self.drivelist)))
359
360 if self.args.get():
361 args.append("--append=\"%s\"" %(self.args.get()))
362 @@ -437,7 +439,7 @@ class bootloaderInfo:
363 import isys
364 import flags
365 drives = isys.hardDriveDict().keys()
366 - drives.sort (isys.compareDrives)
367 + drives.sort(isys.compareDrives)
368
369 # now filter out all of the removable media unless expert mode
370 rc = []
371 @@ -447,16 +449,16 @@ class bootloaderInfo:
372 return rc
373
374 def __init__(self):
375 - self.args = KernelArguments()
376 - self.images = BootImages()
377 - self.device = None
378 + self.args = KernelArguments()
379 + self.images = BootImages()
380 + self.device = None
381 self.useLinear = 1 # only used for kickstart compatibility
382 self.defaultDevice = None # XXX hack, used by kickstart
383 self.useGrubVal = 0 # only used on x86
384 self.configfile = None
385 self.kernelLocation = "/boot/"
386 self.forceLBA32 = 0
387 - self.password = None
388 + self.password = None
389 self.pure = None
390 self.above1024 = 0
391
392 @@ -559,12 +561,12 @@ class ia64BootloaderInfo(bootloaderInfo):
393 chainList, defaultDev, justConfig):
394 config = self.getBootloaderConfig(instRoot, fsset, bl, langs,
395 kernelList, chainList, defaultDev)
396 - config.write(instRoot + self.configfile, perms = self.perms)
397 + config.write(instRoot + self.configfile, perms = self.perms)
398
399 - return ""
400 + return ""
401
402 def write(self, instRoot, fsset, bl, langs, kernelList, chainList,
403 - defaultDev, justConfig, intf):
404 + defaultDev, justConfig, intf):
405 if len(kernelList) >= 1:
406 str = self.writeLilo(instRoot, fsset, bl, langs, kernelList,
407 chainList, defaultDev, justConfig)
408 @@ -603,11 +605,11 @@ class ia64BootloaderInfo(bootloaderInfo):
409
410 def __init__(self):
411 bootloaderInfo.__init__(self)
412 - self.useGrubVal = 1
413 + self.useGrubVal = 1
414 self.kernelLocation = ""
415 self.configfile = "/boot/efi/EFI/redhat/elilo.conf"
416
417 -
418 +
419 class x86BootloaderInfo(bootloaderInfo):
420 def setPassword(self, val, isCrypted = 1):
421 if not val:
422 @@ -616,7 +618,7 @@ class x86BootloaderInfo(bootloaderInfo):
423 return
424
425 if isCrypted and self.useGrubVal == 0:
426 - log("requested crypted password with lilo; ignoring")
427 + #log("requested crypted password with lilo; ignoring")
428 self.pure = None
429 return
430 elif isCrypted:
431 @@ -626,9 +628,9 @@ class x86BootloaderInfo(bootloaderInfo):
432 salt = "$1$"
433 saltLen = 8
434
435 - for i in range(saltLen):
436 + for i in range(saltLen):
437 salt = salt + whrandom.choice (string.letters +
438 - string.digits + './')
439 + string.digits + './')
440
441 self.password = crypt.crypt (val, salt)
442 self.pure = val
443 @@ -640,14 +642,36 @@ class x86BootloaderInfo(bootloaderInfo):
444 self.forceLBA32 = val
445
446 def setUseGrub(self, val):
447 - self.useGrubVal = val
448 + self.useGrubVal = val
449 +
450 + def getPhysicalDevices(self, device):
451 + # This finds a list of devices on which the given device name resides.
452 + # Accepted values for "device" are raid1 md devices (i.e. "md0"),
453 + # physical disks ("hda"), and real partitions on physical disks
454 + # ("hda1"). Volume groups/logical volumes are not accepted.
455 + #
456 + # XXX this has internal anaconda-ish knowledge. ick.
457 + import isys
458 + import lvm
459 +
460 + if string.split(device, '/', 1)[0] in map (lambda vg: vg[0],
461 + lvm.vglist()):
462 + return []
463 +
464 + if device.startswith('md'):
465 + bootable = 0
466 + parts = checkbootloader.getRaidDisks(device, 1, stripPart=0)
467 + parts.sort()
468 + return parts
469 +
470 + return [device]
471
472 def writeGrub(self, instRoot, fsset, bl, langs, kernelList, chainList,
473 - defaultDev, justConfigFile):
474 + defaultDev, justConfigFile):
475 if len(kernelList) < 1:
476 return ""
477
478 - images = bl.images.getImages()
479 + images = bl.images.getImages()
480 rootDev = fsset.getEntryByMountPoint("/").device.getDevice()
481
482 if not os.path.isdir(instRoot + '/boot/grub/'):
483 @@ -655,46 +679,54 @@ class x86BootloaderInfo(bootloaderInfo):
484
485 # XXX old config file should be read here for upgrade
486
487 - cf = '/boot/grub/grub.conf'
488 - self.perms = 0600
489 + cf = '/boot/grub/grub.conf'
490 + self.perms = 0600
491 if os.access (instRoot + cf, os.R_OK):
492 - self.perms = os.stat(instRoot + cf)[0] & 0777
493 - os.rename(instRoot + cf,
494 - instRoot + cf + '.rpmsave')
495 + self.perms = os.stat(instRoot + cf)[0] & 0777
496 + os.rename(instRoot + cf,
497 + instRoot + cf + '.rpmsave')
498
499 grubTarget = bl.getDevice()
500 - # XXX wouldn't it be nice if grub really understood raid? :)
501 - if grubTarget.startswith('md'):
502 - ent = fsset.getEntryByDeviceName(grubTarget)
503 - grubTarget = ent.device.members[0]
504 -
505 - f = open(instRoot + cf, "w+")
506 + target = "mbr"
507 + if (grubTarget.startswith('rd/') or grubTarget.startswith('ida/') or
508 + grubTarget.startswith('cciss/') or
509 + grubTarget.startswith('sx8/') or
510 + grubTarget.startswith('mapper/')):
511 + if grubTarget[-1].isdigit():
512 + if grubTarget[-2] == 'p' or \
513 + (grubTarget[-2].isdigit() and grubTarget[-3] == 'p'):
514 + target = "partition"
515 + elif grubTarget[-1].isdigit() and not grubTarget.startswith('md'):
516 + target = "partition"
517 +
518 + f = open(instRoot + cf, "w+")
519
520 f.write("# grub.conf generated by anaconda\n")
521 f.write("#\n")
522 f.write("# Note that you do not have to rerun grub "
523 "after making changes to this file\n")
524
525 - bootDev = fsset.getEntryByMountPoint("/boot")
526 - grubPath = "/grub"
527 - cfPath = "/"
528 - if not bootDev:
529 - bootDev = fsset.getEntryByMountPoint("/")
530 - grubPath = "/boot/grub"
531 - cfPath = "/boot/"
532 + bootDev = fsset.getEntryByMountPoint("/boot")
533 + grubPath = "/grub"
534 + cfPath = "/"
535 + if not bootDev:
536 + bootDev = fsset.getEntryByMountPoint("/")
537 + grubPath = "/boot/grub"
538 + cfPath = "/boot/"
539 f.write("# NOTICE: You do not have a /boot partition. "
540 "This means that\n")
541 f.write("# all kernel and initrd paths are relative "
542 "to /, eg.\n")
543 - else:
544 + else:
545 f.write("# NOTICE: You have a /boot partition. This means "
546 "that\n")
547 f.write("# all kernel and initrd paths are relative "
548 "to /boot/, eg.\n")
549
550 - bootDev = bootDev.device.getDevice(asBoot = 1)
551 + bootDevs = self.getPhysicalDevices(bootDev.device.getDevice())
552 + bootDev = bootDev.device.getDevice()
553
554 - f.write('# root %s\n' % self.grubbyPartitionName(bootDev))
555 + f.write('# root %s\n' % self.grubbyPartitionName(bootDevs[0]))
556 f.write("# kernel %svmlinuz-version ro "
557 "root=/dev/%s\n" % (cfPath, rootDev))
558 f.write("# initrd %sinitrd-version.img\n" % (cfPath))
559 @@ -741,46 +773,46 @@ class x86BootloaderInfo(bootloaderInfo):
560 # we only want splashimage if they're not using a serial console
561 if os.access("%s/boot/grub/splash.xpm.gz" %(instRoot,), os.R_OK):
562 f.write('splashimage=%s%sgrub/splash.xpm.gz\n'
563 - % (self.grubbyPartitionName(bootDev), cfPath))
564 + % (self.grubbyPartitionName(bootDevs[0]), cfPath))
565 f.write("hiddenmenu\n")
566
567 - usedDevs[bootDev] = 1
568 - usedDevs[grubTarget] = 1
569 -
570 + for dev in self.getPhysicalDevices(grubTarget):
571 + usedDevs[dev] = 1
572 +
573 if self.password:
574 f.write('password --md5 %s\n' %(self.password))
575
576 - for (label, longlabel, version) in kernelList:
577 - kernelTag = "-" + version
578 - kernelFile = "%svmlinuz%s" % (cfPath, kernelTag)
579 + for (label, longlabel, version) in kernelList:
580 + kernelTag = "-" + version
581 + kernelFile = "%svmlinuz%s" % (cfPath, kernelTag)
582
583 - initrd = booty.makeInitrd (kernelTag, instRoot)
584 + initrd = booty.makeInitrd (kernelTag, instRoot)
585
586 - f.write('title %s (%s)\n' % (longlabel, version))
587 - f.write('\troot %s\n' % self.grubbyPartitionName(bootDev))
588 + f.write('title %s (%s)\n' % (longlabel, version))
589 + f.write('\troot %s\n' % self.grubbyPartitionName(bootDevs[0]))
590
591 realroot = getRootDevName(initrd, fsset, rootDev, instRoot)
592 realroot = " root=%s" %(realroot,)
593
594 f.write('\tkernel %s ro%s' % (kernelFile, realroot))
595 - if self.args.get():
596 - f.write(' %s' % self.args.get())
597 - f.write('\n')
598 + if self.args.get():
599 + f.write(' %s' % self.args.get())
600 + f.write('\n')
601
602 - if os.access (instRoot + initrd, os.R_OK):
603 - f.write('\tinitrd %sinitrd%s.img\n' % (cfPath, kernelTag))
604 + if os.access (instRoot + initrd, os.R_OK):
605 + f.write('\tinitrd %sinitrd%s.img\n' % (cfPath, kernelTag))
606
607 - for (label, longlabel, device) in chainList:
608 + for (label, longlabel, device) in chainList:
609 if ((not longlabel) or (longlabel == "")):
610 continue
611 - f.write('title %s\n' % (longlabel))
612 - f.write('\trootnoverify %s\n' % self.grubbyPartitionName(device))
613 + f.write('title %s\n' % (longlabel))
614 + f.write('\trootnoverify %s\n' % self.grubbyPartitionName(device))
615 # f.write('\tmakeactive\n')
616 f.write('\tchainloader +1')
617 - f.write('\n')
618 + f.write('\n')
619 usedDevs[device] = 1
620
621 - f.close()
622 + f.close()
623 os.chmod(instRoot + "/boot/grub/grub.conf", self.perms)
624
625 try:
626 @@ -801,32 +833,39 @@ class x86BootloaderInfo(bootloaderInfo):
627 except:
628 pass
629
630 + for dev in self.getPhysicalDevices(rootDev) + bootDevs:
631 + usedDevs[dev] = 1
632
633 if not os.access(instRoot + "/boot/grub/device.map", os.R_OK):
634 f = open(instRoot + "/boot/grub/device.map", "w+")
635 f.write("# this device map was generated by anaconda\n")
636 - f.write("(fd0) /dev/fd0\n")
637 devs = usedDevs.keys()
638 - devs.sort()
639 usedDevs = {}
640 for dev in devs:
641 drive = getDiskPart(dev)[0]
642 if usedDevs.has_key(drive):
643 continue
644 - f.write("(%s) /dev/%s\n" % (self.grubbyDiskName(drive),
645 - drive))
646 usedDevs[drive] = 1
647 + devs = usedDevs.keys()
648 + devs.sort()
649 + for drive in devs:
650 + # XXX hack city. If they're not the sort of thing that'll
651 + # be in the device map, they shouldn't still be in the list.
652 + if not drive.startswith('md'):
653 + f.write("(%s) /dev/%s\n" % (self.grubbyDiskName(drive),
654 + drive))
655 f.close()
656
657 - args = "--stage2=/boot/grub/stage2 "
658 if self.forceLBA32:
659 - args = "%s--force-lba " % (args,)
660 + forcelba = "--force-lba "
661 + else:
662 + forcelba = ""
663
664 sysconf = '/etc/sysconfig/grub'
665 if os.access (instRoot + sysconf, os.R_OK):
666 - self.perms = os.stat(instRoot + sysconf)[0] & 0777
667 - os.rename(instRoot + sysconf,
668 - instRoot + sysconf + '.rpmsave')
669 + self.perms = os.stat(instRoot + sysconf)[0] & 0777
670 + os.rename(instRoot + sysconf,
671 + instRoot + sysconf + '.rpmsave')
672 # if it's an absolute symlink, just get it out of our way
673 elif (os.path.islink(instRoot + sysconf) and
674 os.readlink(instRoot + sysconf)[0] == '/'):
675 @@ -834,20 +873,33 @@ class x86BootloaderInfo(bootloaderInfo):
676 instRoot + sysconf + '.rpmsave')
677 f = open(instRoot + sysconf, 'w+')
678 f.write("boot=/dev/%s\n" %(grubTarget,))
679 + # XXX forcelba never gets read back...
680 if self.forceLBA32:
681 f.write("forcelba=1\n")
682 else:
683 f.write("forcelba=0\n")
684 f.close()
685
686 - part = self.grubbyPartitionName(bootDev)
687 - prefix = "%s/%s" % (self.grubbyPartitionName(bootDev), grubPath)
688 - cmd = "root %s\ninstall %s%s/stage1 d %s %s/stage2 p %s%s/grub.conf" % \
689 - (part, args, grubPath, self.grubbyPartitionName(grubTarget),
690 - grubPath, part, grubPath)
691 + cmds = []
692 + for bootDev in bootDevs:
693 + gtDisk = self.grubbyPartitionName(getDiskPart(bootDev)[0])
694 + bPart = self.grubbyPartitionName(bootDev)
695
696 + stage1Target = gtDisk
697 + if target == "partition":
698 + stage1Target = self.grubbyPartitionName(bootDev)
699 +
700 + cmd = "root %s\nsetup %s" % (bPart, stage1Target)
701 + cmds.append(cmd)
702 +
703 if not justConfigFile:
704 - log("GRUB command %s", cmd)
705 + #log("GRUB commands:")
706 + #for cmd in cmds:
707 + # log("\t%s\n", cmd)
708 + if cfPath == "/":
709 + syncDataToDisk(bootDev, "/boot", instRoot)
710 + else:
711 + syncDataToDisk(bootDev, "/", instRoot)
712
713 # copy the stage files over into /boot
714 rhpl.executil.execWithRedirect( "/sbin/grub-install",
715 @@ -855,27 +907,29 @@ class x86BootloaderInfo(bootloaderInfo):
716 stdout = "/dev/tty5", stderr = "/dev/tty5",
717 root = instRoot)
718
719 -
720 -
721 - # FIXME: hack to try to make sure everything is written to the disk
722 - if cfPath == "/":
723 - syncDataToDisk(bootDev, "/boot", instRoot)
724 - else:
725 - syncDataToDisk(bootDev, "/", instRoot)
726 -
727 # really install the bootloader
728 - p = os.pipe()
729 - os.write(p[1], cmd + '\n')
730 - os.close(p[1])
731 - rhpl.executil.execWithRedirect('/sbin/grub' ,
732 - [ "grub", "--batch", "--no-floppy",
733 + for cmd in cmds:
734 + p = os.pipe()
735 + os.write(p[1], cmd + '\n')
736 + os.close(p[1])
737 + import time
738 +
739 + # FIXME: hack to try to make sure everything is written
740 + # to the disk
741 + if cfPath == "/":
742 + syncDataToDisk(bootDev, "/boot", instRoot)
743 + else:
744 + syncDataToDisk(bootDev, "/", instRoot)
745 +
746 + rhpl.executil.execWithRedirect('/sbin/grub' ,
747 + [ "grub", "--batch", "--no-floppy",
748 "--device-map=/boot/grub/device.map" ],
749 stdin = p[0],
750 - stdout = "/dev/tty5", stderr = "/dev/tty5",
751 - root = instRoot)
752 - os.close(p[0])
753 + stdout = "/dev/tty5", stderr = "/dev/tty5",
754 + root = instRoot)
755 + os.close(p[0])
756
757 - return ""
758 + return ""
759
760 def grubbyDiskName(self, name):
761 return "hd%d" % self.drivelist.index(name)
762 @@ -895,11 +949,11 @@ class x86BootloaderInfo(bootloaderInfo):
763 kernelList, chainList,
764 defaultDev)
765
766 - liloTarget = bl.getDevice()
767 + liloTarget = bl.getDevice()
768
769 - config.addEntry("boot", '/dev/' + liloTarget, replace = 0)
770 - config.addEntry("map", "/boot/map", replace = 0)
771 - config.addEntry("install", "/boot/boot.b", replace = 0)
772 + config.addEntry("boot", '/dev/' + liloTarget, replace = 0)
773 + config.addEntry("map", "/boot/map", replace = 0)
774 + config.addEntry("install", "/boot/boot.b", replace = 0)
775 message = "/boot/message"
776
777 if self.pure is not None and not self.useGrubVal:
778 @@ -1013,7 +1067,6 @@ class x86BootloaderInfo(bootloaderInfo):
779 f.close()
780 for line in lines:
781 if line.startswith(stanza):
782 - import checkbootloader
783 theDev = checkbootloader.getBootDevString(line)
784 break
785 if theDev is not None:
786 @@ -1028,6 +1081,7 @@ class x86BootloaderInfo(bootloaderInfo):
787 if not os.access(instRoot + sysconf, os.R_OK):
788 f = open(instRoot + sysconf, "w+")
789 f.write("boot=%s\n" %(theDev,))
790 + # XXX forcelba never gets read back at all...
791 if self.forceLBA32:
792 f.write("forcelba=1\n")
793 else:
794 @@ -1037,54 +1091,77 @@ class x86BootloaderInfo(bootloaderInfo):
795 # more suckage. grub-install can't work without a valid /etc/mtab
796 # so we have to do shenanigans to get updated grub installed...
797 # steal some more code above
798 - bootDev = fsset.getEntryByMountPoint("/boot")
799 - grubPath = "/grub"
800 - cfPath = "/"
801 - if not bootDev:
802 - bootDev = fsset.getEntryByMountPoint("/")
803 - grubPath = "/boot/grub"
804 - cfPath = "/boot/"
805 - bootDev = bootDev.device.getDevice(asBoot = 1)
806 + bootDev = fsset.getEntryByMountPoint("/boot")
807 + grubPath = "/grub"
808 + cfPath = "/"
809 + if not bootDev:
810 + bootDev = fsset.getEntryByMountPoint("/")
811 + grubPath = "/boot/grub"
812 + cfPath = "/boot/"
813 +
814 + masterBootDev = bootDev.device.getDevice(asBoot = 0)
815 + if masterBootDev[0:2] == 'md':
816 + rootDevs = checkbootloader.getRaidDisks(masterBootDev, raidLevel=1,
817 + stripPart = 0)
818 + else:
819 + rootDevs = [masterBootDev]
820 +
821 + if theDev[5:7] == 'md':
822 + stage1Devs = checkbootloader.getRaidDisks(theDev[5:], raidLevel=1)
823 + else:
824 + stage1Devs = [theDev[5:]]
825
826 - part = self.grubbyPartitionName(bootDev)
827 - prefix = "%s/%s" % (self.grubbyPartitionName(bootDev), grubPath)
828 - args = "--stage2=/boot/grub/stage2 "
829 - cmd = "root %s\ninstall %s%s/stage1 d %s %s/stage2 p %s%s/grub.conf" % \
830 - (part, args, grubPath, self.grubbyPartitionName(theDev[5:]),
831 - grubPath, part, grubPath)
832 + for stage1Dev in stage1Devs:
833 + # cross fingers; if we can't find a root device on the same
834 + # hardware as this boot device, we just blindly hope the first
835 + # thing in the list works.
836 +
837 + grubbyStage1Dev = self.grubbyPartitionName(stage1Dev)
838 +
839 + grubbyRootPart = self.grubbyPartitionName(rootDevs[0])
840 +
841 + for rootDev in rootDevs:
842 + testGrubbyRootDev = getDiskPart(rootDev)[0]
843 + testGrubbyRootDev = self.grubbyPartitionName(testGrubbyRootDev)
844 +
845 + if grubbyStage1Dev == testGrubbyRootDev:
846 + grubbyRootPart = self.grubbyPartitionName(rootDev)
847 + break
848 +
849 + cmd = "root %s\nsetup %s" % (grubbyRootPart, grubbyStage1Dev)
850
851 - if not justConfigFile:
852 - log("GRUB command %s", cmd)
853 + if not justConfigFile:
854 + #log("GRUB command %s", cmd)
855
856 - # copy the stage files over into /boot
857 - rhpl.executil.execWithRedirect( "/sbin/grub-install",
858 + # copy the stage files over into /boot
859 + rhpl.executil.execWithRedirect( "/sbin/grub-install",
860 ["/sbin/grub-install", "--just-copy"],
861 stdout = "/dev/tty5", stderr = "/dev/tty5",
862 root = instRoot)
863
864 - # get the stage files synced to disk
865 - import isys
866 - isys.sync()
867 - isys.sync()
868 - isys.sync()
869 + # get the stage files synced to disk
870 + import isys
871 + isys.sync()
872 + isys.sync()
873 + isys.sync()
874
875 - # really install the bootloader
876 - p = os.pipe()
877 - os.write(p[1], cmd + '\n')
878 - os.close(p[1])
879 - rhpl.executil.execWithRedirect('/sbin/grub' ,
880 + # really install the bootloader
881 + p = os.pipe()
882 + os.write(p[1], cmd + '\n')
883 + os.close(p[1])
884 + rhpl.executil.execWithRedirect('/sbin/grub' ,
885 [ "grub", "--batch", "--no-floppy",
886 "--device-map=/boot/grub/device.map" ],
887 stdin = p[0],
888 stdout = "/dev/tty5", stderr = "/dev/tty5",
889 root = instRoot)
890 - os.close(p[0])
891 -
892 - return ""
893 + os.close(p[0])
894 +
895 + return ""
896
897
898 def write(self, instRoot, fsset, bl, langs, kernelList, chainList,
899 - defaultDev, justConfig, intf):
900 + defaultDev, justConfig, intf):
901 # XXX HACK ALERT - see declaration above
902 if self.doUpgradeOnly:
903 if not self.useGrubVal:
904 @@ -1098,7 +1175,7 @@ class x86BootloaderInfo(bootloaderInfo):
905
906 # and the hacks continue. with 2.6, ide-scsi isn't used
907 # anymore (#116622)
908 - import isys
909 + import isys
910 cdrw = isys.ideCdRwList()
911 torem = []
912 for device in cdrw:
913 @@ -1154,7 +1231,7 @@ class x86BootloaderInfo(bootloaderInfo):
914 def __init__(self):
915 bootloaderInfo.__init__(self)
916 # XXX use checkbootloader to determine what to default to
917 - self.useGrubVal = 1
918 + self.useGrubVal = 1
919 self.kernelLocation = "/boot/"
920 self.configfile = "/etc/lilo.conf"
921 self.password = None
922 @@ -1163,170 +1240,170 @@ class x86BootloaderInfo(bootloaderInfo):
923 class s390BootloaderInfo(bootloaderInfo):
924 def getBootloaderConfig(self, instRoot, fsset, bl, langs, kernelList,
925 chainList, defaultDev):
926 - images = bl.images.getImages()
927 + images = bl.images.getImages()
928
929 # on upgrade read in the lilo config file
930 - lilo = LiloConfigFile ()
931 - self.perms = 0600
932 + lilo = LiloConfigFile ()
933 + self.perms = 0600
934 if os.access (instRoot + self.configfile, os.R_OK):
935 - self.perms = os.stat(instRoot + self.configfile)[0] & 0777
936 - lilo.read (instRoot + self.configfile)
937 - os.rename(instRoot + self.configfile,
938 - instRoot + self.configfile + '.rpmsave')
939 + self.perms = os.stat(instRoot + self.configfile)[0] & 0777
940 + lilo.read (instRoot + self.configfile)
941 + os.rename(instRoot + self.configfile,
942 + instRoot + self.configfile + '.rpmsave')
943
944 - # Remove any invalid entries that are in the file; we probably
945 - # just removed those kernels.
946 - for label in lilo.listImages():
947 - (fsType, sl, path, other) = lilo.getImage(label)
948 - if fsType == "other": continue
949 + # Remove any invalid entries that are in the file; we probably
950 + # just removed those kernels.
951 + for label in lilo.listImages():
952 + (fsType, sl, path, other) = lilo.getImage(label)
953 + if fsType == "other": continue
954
955 - if not os.access(instRoot + sl.getPath(), os.R_OK):
956 - lilo.delImage(label)
957 + if not os.access(instRoot + sl.getPath(), os.R_OK):
958 + lilo.delImage(label)
959
960 rootDev = fsset.getEntryByMountPoint("/").device.getDevice()
961 - if not rootDev:
962 + if not rootDev:
963 raise RuntimeError, "Installing zipl, but there is no root device"
964
965 - if rootDev == defaultDev:
966 - lilo.addEntry("default", kernelList[0][0])
967 - else:
968 - lilo.addEntry("default", chainList[0][0])
969 + if rootDev == defaultDev:
970 + lilo.addEntry("default", kernelList[0][0])
971 + else:
972 + lilo.addEntry("default", chainList[0][0])
973
974 - for (label, longlabel, version) in kernelList:
975 - kernelTag = "-" + version
976 - kernelFile = self.kernelLocation + "vmlinuz" + kernelTag
977 + for (label, longlabel, version) in kernelList:
978 + kernelTag = "-" + version
979 + kernelFile = self.kernelLocation + "vmlinuz" + kernelTag
980
981 - try:
982 - lilo.delImage(label)
983 - except IndexError, msg:
984 - pass
985 + try:
986 + lilo.delImage(label)
987 + except IndexError, msg:
988 + pass
989
990 - sl = LiloConfigFile(imageType = "image", path = kernelFile)
991 + sl = LiloConfigFile(imageType = "image", path = kernelFile)
992
993 - initrd = booty.makeInitrd (kernelTag, instRoot)
994 + initrd = booty.makeInitrd (kernelTag, instRoot)
995
996 - sl.addEntry("label", label)
997 - if os.access (instRoot + initrd, os.R_OK):
998 - sl.addEntry("initrd",
999 + sl.addEntry("label", label)
1000 + if os.access (instRoot + initrd, os.R_OK):
1001 + sl.addEntry("initrd",
1002 "%sinitrd%s.img" %(self.kernelLocation, kernelTag))
1003
1004 - sl.addEntry("read-only")
1005 - sl.addEntry("root", '/dev/' + rootDev)
1006 + sl.addEntry("read-only")
1007 + sl.addEntry("root", '/dev/' + rootDev)
1008 sl.addEntry("ipldevice", '/dev/' + rootDev[:-1])
1009
1010 - if self.args.get():
1011 - sl.addEntry('append', '"%s"' % self.args.get())
1012 -
1013 - lilo.addImage (sl)
1014 + if self.args.get():
1015 + sl.addEntry('append', '"%s"' % self.args.get())
1016 +
1017 + lilo.addImage (sl)
1018
1019 - for (label, longlabel, device) in chainList:
1020 + for (label, longlabel, device) in chainList:
1021 if ((not label) or (label == "")):
1022 continue
1023 - try:
1024 - (fsType, sl, path, other) = lilo.getImage(label)
1025 - lilo.delImage(label)
1026 - except IndexError:
1027 - sl = LiloConfigFile(imageType = "other",
1028 + try:
1029 + (fsType, sl, path, other) = lilo.getImage(label)
1030 + lilo.delImage(label)
1031 + except IndexError:
1032 + sl = LiloConfigFile(imageType = "other",
1033 path = "/dev/%s" %(device))
1034 - sl.addEntry("optional")
1035 -
1036 - sl.addEntry("label", label)
1037 - lilo.addImage (sl)
1038 -
1039 - # Sanity check #1. There could be aliases in sections which conflict
1040 - # with the new images we just created. If so, erase those aliases
1041 - imageNames = {}
1042 - for label in lilo.listImages():
1043 - imageNames[label] = 1
1044 -
1045 - for label in lilo.listImages():
1046 - (fsType, sl, path, other) = lilo.getImage(label)
1047 - if sl.testEntry('alias'):
1048 - alias = sl.getEntry('alias')
1049 - if imageNames.has_key(alias):
1050 - sl.delEntry('alias')
1051 - imageNames[alias] = 1
1052 -
1053 - # Sanity check #2. If single-key is turned on, go through all of
1054 - # the image names (including aliases) (we just built the list) and
1055 - # see if single-key will still work.
1056 - if lilo.testEntry('single-key'):
1057 - singleKeys = {}
1058 - turnOff = 0
1059 - for label in imageNames.keys():
1060 - l = label[0]
1061 - if singleKeys.has_key(l):
1062 - turnOff = 1
1063 - singleKeys[l] = 1
1064 - if turnOff:
1065 - lilo.delEntry('single-key')
1066 + sl.addEntry("optional")
1067 +
1068 + sl.addEntry("label", label)
1069 + lilo.addImage (sl)
1070 +
1071 + # Sanity check #1. There could be aliases in sections which conflict
1072 + # with the new images we just created. If so, erase those aliases
1073 + imageNames = {}
1074 + for label in lilo.listImages():
1075 + imageNames[label] = 1
1076 +
1077 + for label in lilo.listImages():
1078 + (fsType, sl, path, other) = lilo.getImage(label)
1079 + if sl.testEntry('alias'):
1080 + alias = sl.getEntry('alias')
1081 + if imageNames.has_key(alias):
1082 + sl.delEntry('alias')
1083 + imageNames[alias] = 1
1084 +
1085 + # Sanity check #2. If single-key is turned on, go through all of
1086 + # the image names (including aliases) (we just built the list) and
1087 + # see if single-key will still work.
1088 + if lilo.testEntry('single-key'):
1089 + singleKeys = {}
1090 + turnOff = 0
1091 + for label in imageNames.keys():
1092 + l = label[0]
1093 + if singleKeys.has_key(l):
1094 + turnOff = 1
1095 + singleKeys[l] = 1
1096 + if turnOff:
1097 + lilo.delEntry('single-key')
1098
1099 return lilo
1100
1101 def writeChandevConf(self, bl, instroot): # S/390 only
1102 - cf = "/etc/chandev.conf"
1103 - self.perms = 0644
1104 + cf = "/etc/chandev.conf"
1105 + self.perms = 0644
1106 if bl.args.chandevget():
1107 - fd = os.open(instroot + "/etc/chandev.conf",
1108 + fd = os.open(instroot + "/etc/chandev.conf",
1109 os.O_WRONLY | os.O_CREAT)
1110 os.write(fd, "noauto\n")
1111 - for cdev in bl.args.chandevget():
1112 - os.write(fd,'%s\n' % cdev)
1113 - os.close(fd)
1114 - return ""
1115 -
1116 + for cdev in bl.args.chandevget():
1117 + os.write(fd,'%s\n' % cdev)
1118 + os.close(fd)
1119 + return ""
1120 +
1121
1122 def writeZipl(self, instRoot, fsset, bl, langs, kernelList, chainList,
1123 - defaultDev, justConfigFile):
1124 - images = bl.images.getImages()
1125 + defaultDev, justConfigFile):
1126 + images = bl.images.getImages()
1127 rootDev = fsset.getEntryByMountPoint("/").device.getDevice()
1128
1129 - cf = '/etc/zipl.conf'
1130 - self.perms = 0600
1131 + cf = '/etc/zipl.conf'
1132 + self.perms = 0600
1133 if os.access (instRoot + cf, os.R_OK):
1134 - self.perms = os.stat(instRoot + cf)[0] & 0777
1135 - os.rename(instRoot + cf,
1136 - instRoot + cf + '.rpmsave')
1137 + self.perms = os.stat(instRoot + cf)[0] & 0777
1138 + os.rename(instRoot + cf,
1139 + instRoot + cf + '.rpmsave')
1140
1141 - f = open(instRoot + cf, "w+")
1142 + f = open(instRoot + cf, "w+")
1143
1144 - f.write('[defaultboot]\n')
1145 - f.write('default=' + kernelList[0][0] + '\n')
1146 - f.write('target=%s\n' % (self.kernelLocation))
1147 + f.write('[defaultboot]\n')
1148 + f.write('default=' + kernelList[0][0] + '\n')
1149 + f.write('target=%s\n' % (self.kernelLocation))
1150
1151 cfPath = "/boot/"
1152 - for (label, longlabel, version) in kernelList:
1153 - kernelTag = "-" + version
1154 - kernelFile = "%svmlinuz%s" % (cfPath, kernelTag)
1155 -
1156 - initrd = booty.makeInitrd (kernelTag, instRoot)
1157 - f.write('[%s]\n' % (label))
1158 - f.write('\timage=%s\n' % (kernelFile))
1159 - if os.access (instRoot + initrd, os.R_OK):
1160 - f.write('\tramdisk=%sinitrd%s.img\n' %(self.kernelLocation,
1161 + for (label, longlabel, version) in kernelList:
1162 + kernelTag = "-" + version
1163 + kernelFile = "%svmlinuz%s" % (cfPath, kernelTag)
1164 +
1165 + initrd = booty.makeInitrd (kernelTag, instRoot)
1166 + f.write('[%s]\n' % (label))
1167 + f.write('\timage=%s\n' % (kernelFile))
1168 + if os.access (instRoot + initrd, os.R_OK):
1169 + f.write('\tramdisk=%sinitrd%s.img\n' %(self.kernelLocation,
1170 kernelTag))
1171 realroot = getRootDevName(initrd, fsset, rootDev, instRoot)
1172 - f.write('\tparameters="root=%s' %(realroot,))
1173 - if bl.args.get():
1174 - f.write(' %s' % (bl.args.get()))
1175 - f.write('"\n')
1176 + f.write('\tparameters="root=%s' %(realroot,))
1177 + if bl.args.get():
1178 + f.write(' %s' % (bl.args.get()))
1179 + f.write('"\n')
1180
1181 - f.close()
1182 + f.close()
1183
1184 - if not justConfigFile:
1185 + if not justConfigFile:
1186 argv = [ "/sbin/zipl" ]
1187 rhpl.executil.execWithRedirect(argv[0], argv, root = instRoot,
1188 stdout = "/dev/stdout",
1189 stderr = "/dev/stderr")
1190
1191 - return ""
1192 + return ""
1193
1194 def write(self, instRoot, fsset, bl, langs, kernelList, chainList,
1195 - defaultDev, justConfig, intf):
1196 + defaultDev, justConfig, intf):
1197 str = self.writeZipl(instRoot, fsset, bl, langs, kernelList,
1198 chainList, defaultDev,
1199 justConfig | (not self.useZiplVal))
1200 - str = self.writeChandevConf(bl, instRoot)
1201 + str = self.writeChandevConf(bl, instRoot)
1202
1203 def __init__(self):
1204 bootloaderInfo.__init__(self)
1205 @@ -1424,7 +1501,7 @@ class alphaBootloaderInfo(bootloaderInfo):
1206 # We get all the kernels we need to know about in kernelList.
1207
1208 for (kernel, tag, kernelTag) in kernelList:
1209 - kernelFile = "%svmlinuz-%s" %(kernelPath, kernelTag)
1210 + kernelFile = "%svmlinuz-%s" %(kernelPath, kernelTag)
1211
1212 f.write("%d:%d%s" %(lines, bpn, kernelFile))
1213
1214 @@ -1458,7 +1535,7 @@ class alphaBootloaderInfo(bootloaderInfo):
1215 # to and the second argument is a path to the bootstrap loader
1216 # file.
1217 args = ("swriteboot", ("/dev/%s" % wbd), "/boot/bootlx")
1218 - log("swriteboot command: %s" %(args,))
1219 + #log("swriteboot command: %s" %(args,))
1220 rhpl.executil.execWithRedirect ('/sbin/swriteboot', args,
1221 root = instRoot,
1222 stdout = "/dev/tty5",
1223 @@ -1470,7 +1547,7 @@ class alphaBootloaderInfo(bootloaderInfo):
1224 # It's always the boot partition whether it's / or /boot (with
1225 # the mount point being omitted.)
1226 args = ("abootconf", ("/dev/%s" % wbd), str (bdpn))
1227 - log("abootconf command: %s" %(args,))
1228 + #log("abootconf command: %s" %(args,))
1229 rhpl.executil.execWithRedirect ('/sbin/abootconf', args,
1230 root = instRoot,
1231 stdout = "/dev/tty5",
1232 @@ -1478,7 +1555,7 @@ class alphaBootloaderInfo(bootloaderInfo):
1233
1234
1235 def write(self, instRoot, fsset, bl, langs, kernelList, chainList,
1236 - defaultDev, justConfig, intf):
1237 + defaultDev, justConfig, intf):
1238 if len(kernelList) < 1:
1239 self.noKernelsWarn(intf)
1240
1241 @@ -1495,7 +1572,7 @@ class alphaBootloaderInfo(bootloaderInfo):
1242
1243 def __init__(self):
1244 bootloaderInfo.__init__(self)
1245 - self.useGrubVal = 0
1246 + self.useGrubVal = 0
1247 self.configfile = "/etc/aboot.conf"
1248 # self.kernelLocation is already set to what we need.
1249 self.password = None
1250 @@ -1526,10 +1603,11 @@ class ppcBootloaderInfo(bootloaderInfo):
1251
1252 return devs
1253
1254 +
1255 def writeYaboot(self, instRoot, fsset, bl, langs, kernelList,
1256 chainList, defaultDev, justConfigFile):
1257
1258 - from flags import flags
1259 + from flags import flags
1260
1261 yabootTarget = string.join(self.getBootDevs(fsset, bl))
1262
1263 @@ -1554,26 +1632,49 @@ class ppcBootloaderInfo(bootloaderInfo):
1264 %(butil.getProductName(),))
1265
1266 (name, partNum) = getDiskPart(bootDev)
1267 - partno = partNum + 1 # 1 based
1268 + if rhpl.getPPCMachine() == "Pegasos":
1269 + partno = partNum # Pegasos firmware is broken
1270 + else:
1271 + partno = partNum + 1 # 1 based
1272 f.write("partition=%s\n" %(partno,))
1273
1274 - f.write("timeout=20\n")
1275 + f.write("timeout=80\n")
1276 f.write("install=/usr/lib/yaboot/yaboot\n")
1277 f.write("delay=5\n")
1278 -
1279 - if butil.getPPCMachine() == "PMac":
1280 + f.write("enablecdboot\n")
1281 + f.write("enableofboot\n")
1282 + f.write("enablenetboot\n")
1283 +
1284 + yabootProg = "/sbin/mkofboot"
1285 + if rhpl.getPPCMachine() == "PMac":
1286 + # write out the first hfs/hfs+ partition as being macosx
1287 + for (label, longlabel, device) in chainList:
1288 + if ((not label) or (label == "")):
1289 + continue
1290 + f.write("macosx=/dev/%s\n" %(device,))
1291 + break
1292 +
1293 f.write("magicboot=/usr/lib/yaboot/ofboot\n")
1294
1295 - if butil.getPPCMachine() == "pSeries":
1296 + if rhpl.getPPCMachine() == "pSeries":
1297 f.write("nonvram\n")
1298 + f.write("fstype=raw\n")
1299 +
1300 + if rhpl.getPPCMachine() == "Pegasos":
1301 + f.write("nonvram\n")
1302 + f.write("mntpoint=/boot/yaboot\n")
1303 + f.write("usemount\n")
1304 + if not os.access(instRoot + "/boot/yaboot", os.R_OK):
1305 + os.mkdir(instRoot + "/boot/yaboot")
1306 + yabootProg = "/sbin/ybin"
1307
1308 if self.password:
1309 f.write("password=%s\n" %(self.password,))
1310 f.write("restricted\n")
1311 -
1312 +
1313 f.write("\n")
1314
1315 - rootDev = fsset.getEntryByMountPoint("/").device.getDevice()
1316 + rootDev = fsset.getEntryByMountPoint("/").device.getDevice()
1317
1318 for (label, longlabel, version) in kernelList:
1319 kernelTag = "-" + version
1320 @@ -1611,14 +1712,11 @@ class ppcBootloaderInfo(bootloaderInfo):
1321 isys.sync()
1322 isys.sync()
1323
1324 - ybinargs = [ "/sbin/mkofboot", "-f", "-C", cf ]
1325 - if butil.getPPCMachine() == "pSeries":
1326 - ybinargs.extend(["--filesystem", "raw"])
1327 + ybinargs = [ yabootProg, "-f", "-C", cf ]
1328
1329 -
1330 - log("running: %s" %(ybinargs,))
1331 - if not flags.test:
1332 - rhpl.executil.execWithRedirect(ybinargs[0],
1333 + #log("running: %s" %(ybinargs,))
1334 + if not flags.test:
1335 + rhpl.executil.execWithRedirect(ybinargs[0],
1336 ybinargs,
1337 stdout = "/dev/tty5",
1338 stderr = "/dev/tty5",
1339 @@ -1629,7 +1727,7 @@ class ppcBootloaderInfo(bootloaderInfo):
1340 os.symlink("../boot/etc/yaboot.conf",
1341 instRoot + "/etc/yaboot.conf")
1342
1343 - return ""
1344 + return ""
1345
1346 def setPassword(self, val, isCrypted = 1):
1347 # yaboot just handles the password and doesn't care if its crypted
1348 @@ -1637,7 +1735,7 @@ class ppcBootloaderInfo(bootloaderInfo):
1349 self.password = val
1350
1351 def write(self, instRoot, fsset, bl, langs, kernelList, chainList,
1352 - defaultDev, justConfig, intf):
1353 + defaultDev, justConfig, intf):
1354 if len(kernelList) >= 1:
1355 str = self.writeYaboot(instRoot, fsset, bl, langs, kernelList,
1356 chainList, defaultDev, justConfig)
1357 @@ -1673,10 +1771,10 @@ class iseriesBootloaderInfo(bootloaderInfo):
1358 if len(kernelList) < 1:
1359 self.noKernelsWarn(intf)
1360 return
1361 - if len(kernelList) > 1:
1362 - # FIXME: how can this happen?
1363 - log("more than one kernel on iSeries. bailing and just using "
1364 - "the first")
1365 + #if len(kernelList) > 1:
1366 + # # FIXME: how can this happen?
1367 + # log("more than one kernel on iSeries. bailing and just using "
1368 + # "the first")
1369
1370 # iseries is Weird (tm) -- here's the basic theory
1371 # a) have /boot/vmlinitrd-$(version)
1372 @@ -1709,23 +1807,24 @@ class iseriesBootloaderInfo(bootloaderInfo):
1373 # OS/400 will load as NWSSTG
1374 bootDev = bl.getDevice()
1375 if bootDev:
1376 - log("Writing kernel %s to PReP partition %s" %(kernelFile,
1377 - bootDev))
1378 + #log("Writing kernel %s to PReP partition %s" %(kernelFile, bootDev))
1379 try:
1380 self.ddFile(instRoot + kernelFile, "%s/dev/%s" %(instRoot,
1381 bootDev))
1382 except Exception, e:
1383 # FIXME: should this be more fatal
1384 - log("Failed to write kernel: %s" %(e,))
1385 + #log("Failed to write kernel: %s" %(e,))
1386 + pass
1387 else:
1388 - log("No PReP boot partition, not writing kernel for NWSSTG")
1389 + #log("No PReP boot partition, not writing kernel for NWSSTG")
1390 + pass
1391
1392
1393 # now, it's a lot faster to boot if we don't make people go back
1394 # into OS/400, so set up side C (used by default for NWSSTG) with
1395 # our current bits
1396 for side in ("C", "B"):
1397 - log("Writing kernel and cmdline to side %s" %(side,))
1398 + #log("Writing kernel and cmdline to side %s" %(side,))
1399 wrotekernel = 0
1400 try:
1401 self.ddFile(instRoot + kernelFile,
1402 @@ -1733,7 +1832,8 @@ class iseriesBootloaderInfo(bootloaderInfo):
1403 wrotekernel = 1
1404 except Exception, e:
1405 # FIXME: should this be more fatal?
1406 - log("Failed to write kernel to side %s: %s" %(side, e))
1407 + #log("Failed to write kernel to side %s: %s" %(side, e))
1408 + pass
1409
1410 if wrotekernel == 1:
1411 try:
1412 @@ -1749,10 +1849,11 @@ class iseriesBootloaderInfo(bootloaderInfo):
1413 "%s/proc/iSeries/mf/%s/cmdline" %(instRoot,
1414 side))
1415 except Exception, e:
1416 - log("Failed to write kernel command line to side %s: %s"
1417 - %(side, e))
1418 + #log("Failed to write kernel command line to side %s: %s"
1419 + # %(side, e))
1420 + pass
1421
1422 - log("Setting default side to C")
1423 + #log("Setting default side to C")
1424 f = open(instRoot + "/proc/iSeries/mf/side", "w")
1425 f.write("C")
1426 f.close()
1427 @@ -1770,7 +1871,8 @@ class iseriesBootloaderInfo(bootloaderInfo):
1428 def getDiskPart(dev):
1429 cut = len(dev)
1430 if (dev.startswith('rd/') or dev.startswith('ida/') or
1431 - dev.startswith('cciss/') or dev.startswith('sx8/')):
1432 + dev.startswith('cciss/') or dev.startswith('sx8/') or
1433 + dev.startswith('mapper/')):
1434 if dev[-2] == 'p':
1435 cut = -1
1436 elif dev[-3] == 'p':
1437 @@ -1785,10 +1887,10 @@ def getDiskPart(dev):
1438
1439 # hack off the trailing 'p' from /dev/cciss/*, for example
1440 if name[-1] == 'p':
1441 - for letter in name:
1442 - if letter not in string.letters and letter != "/":
1443 - name = name[:-1]
1444 - break
1445 + for letter in name:
1446 + if letter not in string.letters and letter != "/":
1447 + name = name[:-1]
1448 + break
1449
1450 if cut < 0:
1451 partNum = int(dev[cut:]) - 1
1452 diff --git a/checkbootloader.py b/checkbootloader.py
1453 index 604d3fd..4b51056 100644
1454 --- a/checkbootloader.py
1455 +++ b/checkbootloader.py
1456 @@ -4,8 +4,9 @@
1457 # being used on the system.
1458 #
1459 # Jeremy Katz <katzj@redhat.com>
1460 +# Peter Jones <pjones@redhat.com>
1461 #
1462 -# Copyright 2001 Red Hat, Inc.
1463 +# Copyright 2001,2005 Red Hat, Inc.
1464 #
1465 # This software may be freely redistributed under the terms of the GNU
1466 # library public license.
1467 @@ -14,12 +15,13 @@
1468 # along with this program; if not, write to the Free Software
1469 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1470
1471 -import os,sys
1472 +import os
1473 import string
1474
1475 grubConfigFile = "/boot/grub/grub.conf"
1476 liloConfigFile = "/etc/lilo.conf"
1477 yabootConfigFile = "/etc/yaboot.conf"
1478 +siloConfigFile = "/etc/silo.conf"
1479
1480
1481 # XXX: this is cut and pasted directly from booty/bootloaderInfo.py
1482 @@ -43,10 +45,10 @@ def getDiskPart(dev):
1483
1484 # hack off the trailing 'p' from /dev/cciss/*, for example
1485 if name[-1] == 'p':
1486 - for letter in name:
1487 - if letter not in string.letters and letter != "/":
1488 - name = name[:-1]
1489 - break
1490 + for letter in name:
1491 + if letter not in string.letters and letter != "/":
1492 + name = name[:-1]
1493 + break
1494
1495 if cut < 0:
1496 partNum = int(dev[cut:]) - 1
1497 @@ -56,8 +58,13 @@ def getDiskPart(dev):
1498 return (name, partNum)
1499
1500
1501 -def getRaidDisks(raidDevice):
1502 +def getRaidDisks(raidDevice, raidLevel=None, stripPart=1):
1503 rc = []
1504 + if raidLevel is not None:
1505 + try:
1506 + raidLevel = "raid%d" % (int(raidLevel),)
1507 + except ValueError:
1508 + pass
1509
1510 try:
1511 f = open("/proc/mdstat", "r")
1512 @@ -69,19 +76,24 @@ def getRaidDisks(raidDevice):
1513 for line in lines:
1514 fields = string.split(line, ' ')
1515 if fields[0] == raidDevice:
1516 + if raidLevel is not None and fields[3] != raidLevel:
1517 + continue
1518 for field in fields[4:]:
1519 if string.find(field, "[") == -1:
1520 continue
1521 dev = string.split(field, '[')[0]
1522 if len(dev) == 0:
1523 continue
1524 - disk = getDiskPart(dev)[0]
1525 - rc.append(disk)
1526 + if stripPart:
1527 + disk = getDiskPart(dev)[0]
1528 + rc.append(disk)
1529 + else:
1530 + rc.append(dev)
1531
1532 return rc
1533
1534
1535 -def getBootBlock(bootDev, instRoot):
1536 +def getBootBlock(bootDev, instRoot, seekBlocks=0):
1537 """Get the boot block from bootDev. Return a 512 byte string."""
1538 block = " " * 512
1539 if bootDev is None:
1540 @@ -101,6 +113,8 @@ def getBootBlock(bootDev, instRoot):
1541 for dev in bootDevs:
1542 try:
1543 fd = os.open("%s/dev/%s" % (instRoot, dev), os.O_RDONLY)
1544 + if seekBlocks > 0:
1545 + os.lseek(fd, seekBlocks * 512, 0)
1546 block = os.read(fd, 512)
1547 os.close(fd)
1548 return block
1549 @@ -117,10 +131,19 @@ def getBootDevString(line):
1550 dev = string.replace(dev, "'", "")
1551 return dev
1552
1553 +def getBootDevList(line):
1554 + devs = string.split(line, '=')[1]
1555 + rets = []
1556 + for dev in devs:
1557 + dev = getBootDevString("=%s" % (dev,))
1558 + rets.append(dev)
1559 + return string.join(rets)
1560 +
1561 def getBootloaderTypeAndBoot(instRoot = "/"):
1562 haveGrubConf = 1
1563 haveLiloConf = 1
1564 haveYabootConf = 1
1565 + haveSiloConf = 1
1566
1567 bootDev = None
1568
1569 @@ -132,6 +155,8 @@ def getBootloaderTypeAndBoot(instRoot = "/"):
1570 haveLiloConf = 0
1571 if not os.access(instRoot + yabootConfigFile, os.R_OK):
1572 haveYabootConf = 0
1573 + if not os.access(instRoot + siloConfigFile, os.R_OK):
1574 + haveSiloConf = 0
1575
1576 if haveGrubConf:
1577 bootDev = None
1578 @@ -147,7 +172,6 @@ def getBootloaderTypeAndBoot(instRoot = "/"):
1579 f.close()
1580 for line in lines:
1581 if line.startswith(stanza):
1582 - import checkbootloader
1583 bootDev = getBootDevString(line)
1584 break
1585 if bootDev is not None:
1586 @@ -158,17 +182,13 @@ def getBootloaderTypeAndBoot(instRoot = "/"):
1587 # XXX I don't like this, but it's what the maintainer suggested :(
1588 if string.find(block, "GRUB") >= 0:
1589 return ("GRUB", bootDev)
1590 - elif instRoot != "/":
1591 - block = getBootBlock(bootDev, "/")
1592 - if string.find(block, "GRUB") >= 0:
1593 - return("GRUB", bootDev)
1594
1595 if haveLiloConf:
1596 f = open(instRoot + liloConfigFile, "r")
1597 lines = f.readlines()
1598 for line in lines:
1599 if line[0:5] == "boot=":
1600 - bootDev = getBootDevString(line)
1601 + bootDev = getBootDevString(line)
1602 break
1603
1604 block = getBootBlock(bootDev, instRoot)
1605 @@ -181,10 +201,37 @@ def getBootloaderTypeAndBoot(instRoot = "/"):
1606 lines = f.readlines()
1607 for line in lines:
1608 if line[0:5] == "boot=":
1609 - bootDev = getBootDevString(line)
1610 + bootDev = getBootDevList(line)
1611 +
1612 + if bootDev:
1613 + return ("YABOOT", bootDev)
1614
1615 - if bootDev:
1616 - return ("YABOOT", bootDev)
1617 + if haveSiloConf:
1618 + bootDev = None
1619 + # We've never done the /etc/sysconfig/silo thing, but maybe
1620 + # we should start...
1621 + for (fn, stanza) in [ ("/etc/sysconfig/silo", "boot="),
1622 + (grubConfigFile, "#boot=") ]:
1623 + try:
1624 + f = open(instRoot + fn, "r")
1625 + except:
1626 + continue
1627 +
1628 + lines = f.readlines()
1629 + f.close()
1630 + for line in lines:
1631 + if line.startswith(stanza):
1632 + bootDev = getBootDevString(line)
1633 + break
1634 + if bootDev is not None:
1635 + break
1636 +
1637 + if bootDev is not None:
1638 + # XXX SILO sucks just like grub.
1639 + if getDiskPart(bootDev)[1] != 3:
1640 + block = getBootBlock(bootDev, instRoot, 1)
1641 + if block[24:28] == "SILO":
1642 + return ("SILO", bootDev)
1643
1644 return (None, None)
1645
1646 --
1647 1.5.5.6
1648

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed