4 |
# |
# |
5 |
# Jeremy Katz <katzj@redhat.com> |
# Jeremy Katz <katzj@redhat.com> |
6 |
# Erik Troan <ewt@redhat.com> |
# Erik Troan <ewt@redhat.com> |
7 |
|
# Peter Jones <pjones@redhat.com> |
8 |
# |
# |
9 |
# Copyright 2002 Red Hat, Inc. |
# Copyright 2005 Red Hat, Inc. |
10 |
# |
# |
11 |
# This software may be freely redistributed under the terms of the GNU |
# This software may be freely redistributed under the terms of the GNU |
12 |
# library public license. |
# library public license. |
19 |
import isys |
import isys |
20 |
import os, sys |
import os, sys |
21 |
import crypt |
import crypt |
22 |
import whrandom |
import random |
23 |
import butil |
import butil |
24 |
import string |
import string |
25 |
|
|
175 |
# These have appeared |
# These have appeared |
176 |
for (dev, type) in devs: |
for (dev, type) in devs: |
177 |
if not self.images.has_key(dev): |
if not self.images.has_key(dev): |
178 |
if type in dosFilesystems: |
if type in dosFilesystems and doesDualBoot(): |
179 |
|
self.images[dev] = ("Other", "Other", type) |
180 |
|
elif type in ("hfs", "hfs+") and butil.getPPCMachine() == "PMac": |
181 |
self.images[dev] = ("Other", "Other", type) |
self.images[dev] = ("Other", "Other", type) |
182 |
else: |
else: |
183 |
self.images[dev] = (None, None, type) |
self.images[dev] = (None, None, type) |
218 |
# maybe questionable, but the first ntfs or fat is likely to |
# maybe questionable, but the first ntfs or fat is likely to |
219 |
# be the correct one to boot with XP using ntfs |
# be the correct one to boot with XP using ntfs |
220 |
foundDos = 1 |
foundDos = 1 |
221 |
elif (type == 'hfs') and butil.getPPCMachine() == "PMac": |
elif type in ('hfs', 'hfs+') and butil.getPPCMachine() == "PMac": |
222 |
import isys |
import isys |
223 |
import partedUtils |
import partedUtils |
224 |
|
|
|
isys.makeDevInode(dev, '/tmp/' + dev) |
|
225 |
part = partedUtils.get_partition_by_name(diskSet.disks, dev) |
part = partedUtils.get_partition_by_name(diskSet.disks, dev) |
226 |
if partedUtils.get_flags(part) != "boot": |
if partedUtils.get_flags(part) != "boot": |
227 |
devs.append((dev, type)) |
devs.append((dev, type)) |
421 |
return args |
return args |
422 |
|
|
423 |
args.append("--location=%s" % (self.defaultDevice,)) |
args.append("--location=%s" % (self.defaultDevice,)) |
424 |
|
args.append("--driveorder=%s" % (",".join(self.drivelist))) |
425 |
|
|
426 |
if self.args.get(): |
if self.args.get(): |
427 |
args.append("--append=\"%s\"" %(self.args.get())) |
args.append("--append=\"%s\"" %(self.args.get())) |
453 |
self.args = KernelArguments() |
self.args = KernelArguments() |
454 |
self.images = BootImages() |
self.images = BootImages() |
455 |
self.device = None |
self.device = None |
|
self.useLinear = 1 # only used for kickstart compatibility |
|
456 |
self.defaultDevice = None # XXX hack, used by kickstart |
self.defaultDevice = None # XXX hack, used by kickstart |
457 |
self.useGrubVal = 0 # only used on x86 |
self.useGrubVal = 0 # only used on x86 |
458 |
self.configfile = None |
self.configfile = None |
589 |
bootdisk = bootdev[:ind] |
bootdisk = bootdev[:ind] |
590 |
bootpart = bootdev[ind:] |
bootpart = bootdev[ind:] |
591 |
if (bootdisk.startswith('ida/') or bootdisk.startswith('cciss/') or |
if (bootdisk.startswith('ida/') or bootdisk.startswith('cciss/') or |
592 |
bootdisk.startswith('rd/')): |
bootdisk.startswith('rd/') or bootdisk.startswith('sx8/')): |
593 |
bootdisk = bootdisk[:-1] |
bootdisk = bootdisk[:-1] |
594 |
|
|
595 |
self.removeOldEfiEntries(instRoot) |
self.removeOldEfiEntries(instRoot) |
628 |
saltLen = 8 |
saltLen = 8 |
629 |
|
|
630 |
for i in range(saltLen): |
for i in range(saltLen): |
631 |
salt = salt + whrandom.choice (string.letters + |
salt = salt + random.choice (string.letters + |
632 |
string.digits + './') |
string.digits + './') |
633 |
|
|
634 |
self.password = crypt.crypt (val, salt) |
self.password = crypt.crypt (val, salt) |
635 |
self.pure = val |
self.pure = val |
689 |
target = "mbr" |
target = "mbr" |
690 |
if grubTarget[-1].isdigit() and not grubTarget.startswith('md'): |
if grubTarget[-1].isdigit() and not grubTarget.startswith('md'): |
691 |
target = "partition" |
target = "partition" |
692 |
|
|
693 |
f = open(instRoot + cf, "w+") |
f = open(instRoot + cf, "w+") |
694 |
|
|
695 |
f.write("# grub.conf generated by anaconda\n") |
f.write("# grub.conf generated by anaconda\n") |
716 |
|
|
717 |
bootDevs = self.getPhysicalDevices(bootDev.device.getDevice()) |
bootDevs = self.getPhysicalDevices(bootDev.device.getDevice()) |
718 |
bootDev = bootDev.device.getDevice() |
bootDev = bootDev.device.getDevice() |
719 |
|
|
720 |
f.write('# root %s\n' % self.grubbyPartitionName(bootDevs[0])) |
f.write('# root %s\n' % self.grubbyPartitionName(bootDevs[0])) |
721 |
f.write("# kernel %svmlinuz-version ro " |
f.write("# kernel %svmlinuz-version ro " |
722 |
"root=/dev/%s\n" % (cfPath, rootDev)) |
"root=/dev/%s\n" % (cfPath, rootDev)) |
723 |
f.write("# initrd %sinitrd-version.img\n" % (cfPath)) |
f.write("# initrd %sinitrd-version.img\n" % (cfPath)) |
724 |
f.write("#boot=/dev/%s\n" % (grubTarget)) |
f.write("#boot=/dev/%s\n" % (grubTarget)) |
725 |
|
|
726 |
# Check to see if smp kernel should be default or not |
# Check to see if smp kernel should be default or not |
727 |
if isys.smpAvailable() or isys.htavailable(): |
if isys.smpAvailable() or isys.htavailable(): |
728 |
smpCapable=1 |
smpCapable=1 |
729 |
else: |
else: |
730 |
smpCapable=0 |
smpCapable=0 |
731 |
|
|
732 |
# get the default image to boot... we have to walk and find it |
# get the default image to boot... we have to walk and find it |
781 |
|
|
782 |
for dev in self.getPhysicalDevices(grubTarget): |
for dev in self.getPhysicalDevices(grubTarget): |
783 |
usedDevs[dev] = 1 |
usedDevs[dev] = 1 |
784 |
|
|
785 |
if self.password: |
if self.password: |
786 |
f.write('password --md5 %s\n' %(self.password)) |
f.write('password --md5 %s\n' %(self.password)) |
787 |
|
|
857 |
# be in the device map, they shouldn't still be in the list. |
# be in the device map, they shouldn't still be in the list. |
858 |
if not drive.startswith('md'): |
if not drive.startswith('md'): |
859 |
f.write("(%s) /dev/%s\n" % (self.grubbyDiskName(drive), |
f.write("(%s) /dev/%s\n" % (self.grubbyDiskName(drive), |
860 |
drive)) |
drive)) |
861 |
f.close() |
f.close() |
862 |
|
|
863 |
if self.forceLBA32: |
if self.forceLBA32: |
877 |
instRoot + sysconf + '.rpmsave') |
instRoot + sysconf + '.rpmsave') |
878 |
f = open(instRoot + sysconf, 'w+') |
f = open(instRoot + sysconf, 'w+') |
879 |
f.write("boot=/dev/%s\n" %(grubTarget,)) |
f.write("boot=/dev/%s\n" %(grubTarget,)) |
880 |
|
# XXX forcelba never gets read back... |
881 |
if self.forceLBA32: |
if self.forceLBA32: |
882 |
f.write("forcelba=1\n") |
f.write("forcelba=1\n") |
883 |
else: |
else: |
888 |
for bootDev in bootDevs: |
for bootDev in bootDevs: |
889 |
gtPart = self.getMatchingPart(bootDev, grubTarget) |
gtPart = self.getMatchingPart(bootDev, grubTarget) |
890 |
gtDisk = self.grubbyPartitionName(getDiskPart(gtPart)[0]) |
gtDisk = self.grubbyPartitionName(getDiskPart(gtPart)[0]) |
891 |
bPart = self.grubbyPartitionName(bootDev) |
bPart = self.grubbyPartitionName(bootDev) |
892 |
cmd = "root %s" % (bPart,) |
cmd = "root %s" % (bPart,) |
893 |
cmds.append(cmd) |
cmds.append(cmd) |
894 |
|
|
896 |
if target == "partition": |
if target == "partition": |
897 |
stage1Target = self.grubbyPartitionName(gtPart) |
stage1Target = self.grubbyPartitionName(gtPart) |
898 |
|
|
899 |
cmd = "install %s --stage2=/boot/grub/stage2 %s%s/stage1 %s %s%s/stage2 p %s/grub.conf" % \ |
cmd = "install %s%s/stage1 d %s %s/stage2 p %s%s/grub.conf" % \ |
900 |
(forcelba, bPart, grubPath, stage1Target, bPart, grubPath, grubPath) |
(forcelba, grubPath, stage1Target, grubPath, bPart, grubPath) |
901 |
cmds.append(cmd) |
cmds.append(cmd) |
902 |
|
|
903 |
if not justConfigFile: |
if not justConfigFile: |
904 |
log("GRUB commands:") |
log("GRUB commands:") |
905 |
for cmd in cmds: |
for cmd in cmds: |
922 |
# really install the bootloader |
# really install the bootloader |
923 |
p = os.pipe() |
p = os.pipe() |
924 |
for cmd in cmds: |
for cmd in cmds: |
925 |
os.write(p[1], cmd + '\n') |
os.write(p[1], cmd + '\n') |
926 |
os.close(p[1]) |
os.close(p[1]) |
927 |
rhpl.executil.execWithRedirect('/sbin/grub' , |
rhpl.executil.execWithRedirect('/sbin/grub' , |
928 |
[ "grub", "--batch", "--no-floppy", |
[ "grub", "--batch", "--no-floppy", |
943 |
return device |
return device |
944 |
return devices[0] |
return devices[0] |
945 |
|
|
|
|
|
946 |
def grubbyDiskName(self, name): |
def grubbyDiskName(self, name): |
947 |
return "hd%d" % self.drivelist.index(name) |
return "hd%d" % self.drivelist.index(name) |
948 |
|
|
992 |
if os.access(instRoot + message, os.R_OK): |
if os.access(instRoot + message, os.R_OK): |
993 |
config.addEntry("message", message, replace = 0) |
config.addEntry("message", message, replace = 0) |
994 |
|
|
995 |
if not config.testEntry('lba32') and not config.testEntry('linear'): |
if not config.testEntry('lba32'): |
996 |
if self.forceLBA32 or (bl.above1024 and |
if self.forceLBA32 or (bl.above1024 and |
997 |
butil.getArch() != "x86_64" and |
butil.getArch() != "x86_64" and |
998 |
edd.detect()): |
edd.detect()): |
999 |
config.addEntry("lba32", replace = 0) |
config.addEntry("lba32", replace = 0) |
|
elif self.useLinear: |
|
|
config.addEntry("linear", replace = 0) |
|
|
else: |
|
|
config.addEntry("nolinear", replace = 0) |
|
1000 |
|
|
1001 |
return config |
return config |
1002 |
|
|
|
def writeLilo(self, instRoot, fsset, bl, langs, kernelList, |
|
|
chainList, defaultDev, justConfig): |
|
|
if not self.doUpgradeOnly and len(kernelList) >= 1: |
|
|
config = self.getBootloaderConfig(instRoot, fsset, bl, langs, |
|
|
kernelList, chainList, defaultDev) |
|
|
config.write(instRoot + self.configfile, perms = self.perms) |
|
|
elif self.doUpgradeOnly: |
|
|
# this is to work around the fact that older kernels don't |
|
|
# remove themselves from lilo.conf on upgrade |
|
|
# it's a really bad hack, probably also needs to happen on |
|
|
# other arches once they support upgradeonly |
|
|
config = LiloConfigFile () |
|
|
if os.access (instRoot + self.configfile, os.R_OK): |
|
|
self.perms = os.stat(instRoot + self.configfile)[0] & 0777 |
|
|
config.read (instRoot + self.configfile) |
|
|
# Remove any invalid entries that are in the file; we probably |
|
|
# just removed those kernels. |
|
|
for label in config.listImages(): |
|
|
(fsType, sl, path, other) = config.getImage(label) |
|
|
if fsType == "other": continue |
|
|
|
|
|
if not os.access(instRoot + sl.getPath(), os.R_OK): |
|
|
config.delImage(label) |
|
|
|
|
|
# make sure that the default entry really exists. since |
|
|
# getDefault actually gets the entry for us, we'll get an |
|
|
# exception if it doesn't really exist. |
|
|
try: |
|
|
default = config.getDefault() |
|
|
except: |
|
|
try: |
|
|
config.delEntry("default") |
|
|
except: |
|
|
pass |
|
|
|
|
|
config.write(instRoot + self.configfile, perms = self.perms) |
|
|
|
|
|
# FIXME: do some syncs, just to make sure the config is written out |
|
|
import isys |
|
|
isys.sync() |
|
|
isys.sync() |
|
|
isys.sync() |
|
|
|
|
|
if not justConfig: |
|
|
str = rhpl.executil.execWithRedirect('/sbin/lilo' , |
|
|
["/sbin/lilo", "-v"], |
|
|
stdout = "/dev/tty5", |
|
|
stderr = "/dev/tty5", |
|
|
root = instRoot) |
|
|
else: |
|
|
str = "" |
|
|
|
|
|
return str |
|
|
|
|
1003 |
# this is a hackish function that depends on the way anaconda writes |
# this is a hackish function that depends on the way anaconda writes |
1004 |
# out the grub.conf with a #boot= comment |
# out the grub.conf with a #boot= comment |
1005 |
# XXX this falls into the category of self.doUpgradeOnly |
# XXX this falls into the category of self.doUpgradeOnly |
1021 |
f.close() |
f.close() |
1022 |
for line in lines: |
for line in lines: |
1023 |
if line.startswith(stanza): |
if line.startswith(stanza): |
|
import checkbootloader |
|
1024 |
theDev = checkbootloader.getBootDevString(line) |
theDev = checkbootloader.getBootDevString(line) |
1025 |
break |
break |
1026 |
if theDev is not None: |
if theDev is not None: |
1035 |
if not os.access(instRoot + sysconf, os.R_OK): |
if not os.access(instRoot + sysconf, os.R_OK): |
1036 |
f = open(instRoot + sysconf, "w+") |
f = open(instRoot + sysconf, "w+") |
1037 |
f.write("boot=%s\n" %(theDev,)) |
f.write("boot=%s\n" %(theDev,)) |
1038 |
|
# XXX forcelba never gets read back at all... |
1039 |
if self.forceLBA32: |
if self.forceLBA32: |
1040 |
f.write("forcelba=1\n") |
f.write("forcelba=1\n") |
1041 |
else: |
else: |
1082 |
grubbyRootPart = self.grubbyPartitionName(rootDev) |
grubbyRootPart = self.grubbyPartitionName(rootDev) |
1083 |
break |
break |
1084 |
|
|
1085 |
cmd = "root %s\ninstall --stage2=/boot/grub/stage2 %s%s/stage1 %s %s%s/stage2 p %s/grub.conf" \ |
cmd = "root %s\ninstall %s/stage1 d %s %s/stage2 p %s%s/grub.conf" \ |
1086 |
% (grubbyRootPart, grubbyRootPart, grubPath, grubbyStage1Dev, |
% (grubbyRootPart, grubPath, grubbyStage1Dev, |
1087 |
grubbyRootPart, grubPath, grubPath) |
grubPath, grubbyRootPart, grubPath) |
1088 |
|
|
1089 |
if not justConfigFile: |
if not justConfigFile: |
1090 |
log("GRUB command %s", cmd) |
log("GRUB command %s", cmd) |
1091 |
|
|
1092 |
# copy the stage files over into /boot |
# copy the stage files over into /boot |
1093 |
rhpl.executil.execWithRedirect( "/sbin/grub-install", |
rhpl.executil.execWithRedirect( "/sbin/grub-install", |
1094 |
["/sbin/grub-install", "--just-copy"], |
["/sbin/grub-install", "--just-copy"], |
1095 |
stdout = "/dev/tty5", stderr = "/dev/tty5", |
stdout = "/dev/tty5", stderr = "/dev/tty5", |
1096 |
root = instRoot) |
root = instRoot) |
1097 |
|
|
1098 |
# get the stage files synced to disk |
# get the stage files synced to disk |
1099 |
import isys |
import isys |
1100 |
isys.sync() |
isys.sync() |
1101 |
isys.sync() |
isys.sync() |
1102 |
isys.sync() |
isys.sync() |
1103 |
|
|
1104 |
# really install the bootloader |
# really install the bootloader |
1105 |
p = os.pipe() |
p = os.pipe() |
1106 |
os.write(p[1], cmd + '\n') |
os.write(p[1], cmd + '\n') |
1107 |
os.close(p[1]) |
os.close(p[1]) |
1108 |
rhpl.executil.execWithRedirect('/sbin/grub' , |
rhpl.executil.execWithRedirect('/sbin/grub' , |
1109 |
[ "grub", "--batch", "--no-floppy", |
[ "grub", "--batch", "--no-floppy", |
1110 |
"--device-map=/boot/grub/device.map" ], |
"--device-map=/boot/grub/device.map" ], |
1111 |
stdin = p[0], |
stdin = p[0], |
1112 |
stdout = "/dev/tty5", stderr = "/dev/tty5", |
stdout = "/dev/tty5", stderr = "/dev/tty5", |
1113 |
root = instRoot) |
root = instRoot) |
1114 |
os.close(p[0]) |
os.close(p[0]) |
1115 |
|
|
1116 |
return "" |
return "" |
1117 |
|
|
1120 |
defaultDev, justConfig, intf): |
defaultDev, justConfig, intf): |
1121 |
# XXX HACK ALERT - see declaration above |
# XXX HACK ALERT - see declaration above |
1122 |
if self.doUpgradeOnly: |
if self.doUpgradeOnly: |
1123 |
if not self.useGrubVal: |
if self.useGrubVal: |
|
# we do upgrades sort of right for lilo... |
|
|
str = self.writeLilo(instRoot, fsset, bl, langs, kernelList, |
|
|
chainList, defaultDev, |
|
|
justConfig | (self.useGrubVal)) |
|
|
else: |
|
1124 |
self.upgradeGrub(instRoot, fsset, bl, langs, kernelList, |
self.upgradeGrub(instRoot, fsset, bl, langs, kernelList, |
1125 |
chainList, defaultDev, justConfig) |
chainList, defaultDev, justConfig) |
1126 |
|
|
1148 |
if len(kernelList) < 1: |
if len(kernelList) < 1: |
1149 |
self.noKernelsWarn(intf) |
self.noKernelsWarn(intf) |
1150 |
|
|
|
str = self.writeLilo(instRoot, fsset, bl, langs, kernelList, |
|
|
chainList, defaultDev, |
|
|
justConfig | (self.useGrubVal)) |
|
1151 |
str = self.writeGrub(instRoot, fsset, bl, langs, kernelList, |
str = self.writeGrub(instRoot, fsset, bl, langs, kernelList, |
1152 |
chainList, defaultDev, |
chainList, defaultDev, |
1153 |
justConfig | (not self.useGrubVal)) |
justConfig | (not self.useGrubVal)) |
1162 |
def getArgList(self): |
def getArgList(self): |
1163 |
args = bootloaderInfo.getArgList(self) |
args = bootloaderInfo.getArgList(self) |
1164 |
|
|
|
if not self.useGrubVal: |
|
|
args.append("--useLilo") |
|
1165 |
if self.forceLBA32: |
if self.forceLBA32: |
1166 |
args.append("--lba32") |
args.append("--lba32") |
|
if not self.useLinear: |
|
|
args.append("--nolinear") |
|
1167 |
if self.password: |
if self.password: |
1168 |
args.append("--md5pass=%s" %(self.password)) |
args.append("--md5pass=%s" %(self.password)) |
1169 |
|
|
1544 |
bootDev = bootDev.device.getDevice(asBoot = 1) |
bootDev = bootDev.device.getDevice(asBoot = 1) |
1545 |
|
|
1546 |
f = open(instRoot + cf, "w+") |
f = open(instRoot + cf, "w+") |
1547 |
|
|
1548 |
f.write("# yaboot.conf generated by anaconda\n\n") |
f.write("# yaboot.conf generated by anaconda\n\n") |
1549 |
|
|
1550 |
f.write("boot=%s\n" %(yabootTarget,)) |
f.write("boot=%s\n" %(yabootTarget,)) |
1555 |
partno = partNum + 1 # 1 based |
partno = partNum + 1 # 1 based |
1556 |
f.write("partition=%s\n" %(partno,)) |
f.write("partition=%s\n" %(partno,)) |
1557 |
|
|
1558 |
f.write("timeout=20\n") |
f.write("timeout=80\n") |
1559 |
f.write("install=/usr/lib/yaboot/yaboot\n") |
f.write("install=/usr/lib/yaboot/yaboot\n") |
1560 |
f.write("delay=5\n") |
f.write("delay=5\n") |
1561 |
|
f.write("enablecdboot\n") |
1562 |
|
f.write("enableofboot\n") |
1563 |
|
f.write("enablenetboot\n") |
1564 |
|
|
1565 |
if butil.getPPCMachine() == "PMac": |
if butil.getPPCMachine() == "PMac": |
1566 |
|
# write out the first hfs/hfs+ partition as being macosx |
1567 |
|
for (label, longlabel, device) in chainList: |
1568 |
|
if ((not label) or (label == "")): |
1569 |
|
continue |
1570 |
|
f.write("macosx=/dev/%s\n" %(device,)) |
1571 |
|
break |
1572 |
|
|
1573 |
f.write("magicboot=/usr/lib/yaboot/ofboot\n") |
f.write("magicboot=/usr/lib/yaboot/ofboot\n") |
1574 |
|
|
1575 |
if butil.getPPCMachine() == "pSeries": |
if butil.getPPCMachine() == "pSeries": |
1578 |
if self.password: |
if self.password: |
1579 |
f.write("password=%s\n" %(self.password,)) |
f.write("password=%s\n" %(self.password,)) |
1580 |
f.write("restricted\n") |
f.write("restricted\n") |
|
|
|
1581 |
|
|
1582 |
f.write("\n") |
f.write("\n") |
1583 |
|
|
1625 |
|
|
1626 |
|
|
1627 |
log("running: %s" %(ybinargs,)) |
log("running: %s" %(ybinargs,)) |
1628 |
if not flags.test: |
if not flags.test: |
1629 |
rhpl.executil.execWithRedirect(ybinargs[0], |
rhpl.executil.execWithRedirect(ybinargs[0], |
1630 |
ybinargs, |
ybinargs, |
1631 |
stdout = "/dev/tty5", |
stdout = "/dev/tty5", |
1769 |
bootloaderInfo.__init__(self) |
bootloaderInfo.__init__(self) |
1770 |
self.kernelLocation = "/boot/" |
self.kernelLocation = "/boot/" |
1771 |
|
|
1772 |
|
class sparcBootloaderInfo(bootloaderInfo): |
1773 |
|
def writeSilo(self, instRoot, fsset, bl, langs, kernelList, |
1774 |
|
chainList, defaultDev, justConfigFile): |
1775 |
|
|
1776 |
|
from flags import flags |
1777 |
|
|
1778 |
|
bootDev = fsset.getEntryByMountPoint("/boot") |
1779 |
|
if bootDev: |
1780 |
|
cf = "/boot/silo.conf" |
1781 |
|
mf = "/boot/silo.message" |
1782 |
|
cfPath = "" |
1783 |
|
if not os.path.isdir(instRoot + "/boot"): |
1784 |
|
os.mkdir(instRoot + "/boot") |
1785 |
|
else: |
1786 |
|
bootDev = fsset.getEntryByMountPoint("/") |
1787 |
|
cf = "/etc/silo.conf" |
1788 |
|
mf = "/etc/silo.message" |
1789 |
|
cfPath = "/boot" |
1790 |
|
bootDev = bootDev.device.getDevice(asBoot = 1) |
1791 |
|
|
1792 |
|
f = open(instRoot + mf, "w+") |
1793 |
|
f.write("Welcome to %s!\nHit <TAB> for boot options\n\n" % \ |
1794 |
|
(butil.getProductName(),)) |
1795 |
|
f.close() |
1796 |
|
os.chmod(instRoot + mf, 0600) |
1797 |
|
|
1798 |
|
f = open(instRoot + cf, "w+") |
1799 |
|
f.write("# silo.conf generated by anaconda\n\n") |
1800 |
|
|
1801 |
|
f.write("#boot=%s\n" % (bootDev,)) |
1802 |
|
f.write("message=%s\n" % (mf,)) |
1803 |
|
f.write("timeout=50\n") |
1804 |
|
|
1805 |
|
(name, partNum) = getDiskPart(bootDev) |
1806 |
|
partno = partNum + 1 |
1807 |
|
f.write("partition=%s\n" % (partno,)) |
1808 |
|
|
1809 |
|
if self.password: |
1810 |
|
f.write("password=%s\n" % (self.password,)) |
1811 |
|
f.write("restricted\n") |
1812 |
|
|
1813 |
|
f.write("default=%s\n" % (kernelList[0][0],)) |
1814 |
|
f.write("\n") |
1815 |
|
|
1816 |
|
rootDev = fsset.getEntryByMountPoint("/").device.getDevice() |
1817 |
|
|
1818 |
|
for (label, longlabel, version) in kernelList: |
1819 |
|
kernelTag = "-" + version |
1820 |
|
kernelFile = "%s/vmlinuz%s" % (cfPath, kernelTag) |
1821 |
|
|
1822 |
|
f.write("image=%s\n" % (kernelFile,)) |
1823 |
|
f.write("\tlabel=%s\n" % (label,)) |
1824 |
|
f.write("\tread-only\n") |
1825 |
|
|
1826 |
|
initrd = booty.makeInitrd(kernelTag, instRoot) |
1827 |
|
if os.access(instRoot + initrd, os.R_OK): |
1828 |
|
f.write("\tinitrd=%s/initrd%s.img\n" % (cfPath, kernelTag)) |
1829 |
|
|
1830 |
|
append = "%s" % (self.args.get(),) |
1831 |
|
|
1832 |
|
realroot = getRootDevName(initrd, fsset, rootDev, instRoot) |
1833 |
|
if not realroot.startswith("LABEL="): |
1834 |
|
f.write("\troot=%s\n" % (realroot,)) |
1835 |
|
else: |
1836 |
|
if len(append) > 0: |
1837 |
|
append = "%s root=%s" % (append, realroot) |
1838 |
|
else: |
1839 |
|
append = "root=%s" % (realroot,) |
1840 |
|
|
1841 |
|
if len(append) > 0: |
1842 |
|
f.write("\tappend=\"%s\"\n" % (append,)) |
1843 |
|
f.write("\n") |
1844 |
|
|
1845 |
|
f.close() |
1846 |
|
os.chmod(instRoot + cf, 0600) |
1847 |
|
|
1848 |
|
# FIXME: hack to make sure things are written to disk |
1849 |
|
import isys |
1850 |
|
isys.sync() |
1851 |
|
isys.sync() |
1852 |
|
isys.sync() |
1853 |
|
|
1854 |
|
backup = "%s/backup.b" % (cfPath,) |
1855 |
|
sbinargs = ["/sbin/silo", "-f", "-C", cf, "-S", backup] |
1856 |
|
if butil.getSparcMachine() == "sun4u": |
1857 |
|
sbinargs += ["-u"] |
1858 |
|
else: |
1859 |
|
sbinargs += ["-U"] |
1860 |
|
|
1861 |
|
log("running: %s" % (sbinargs,)) |
1862 |
|
if not flags.test: |
1863 |
|
rhpl.executil.execWithRedirect(sbinargs[0], |
1864 |
|
sbinargs, |
1865 |
|
stdout = "/dev/tty5", |
1866 |
|
stderr = "/dev/tty5", |
1867 |
|
root = instRoot) |
1868 |
|
|
1869 |
|
if (not os.access(instRoot + "/etc/silo.conf", os.R_OK) and |
1870 |
|
os.access(instRoot + "/boot/etc/silo.conf", os.R_OK)): |
1871 |
|
os.symlink("../boot/etc/silo.conf", |
1872 |
|
instRoot + "/etc/silo.conf") |
1873 |
|
|
1874 |
|
return "" |
1875 |
|
|
1876 |
|
def setPassword(self, val, isCrypted = 1): |
1877 |
|
# silo just handles the password unencrypted |
1878 |
|
self.password = val |
1879 |
|
|
1880 |
|
def write(self, instRoot, fsset, bl, langs, kernelList, chainList, |
1881 |
|
defaultDev, justConfig, intf): |
1882 |
|
if len(kernelList) >= 1: |
1883 |
|
self.writeSilo(instRoot, fsset, bl, langs, kernelList, chainList, |
1884 |
|
defaultDev, justConfig) |
1885 |
|
else: |
1886 |
|
self.noKernelsWarn(intf) |
1887 |
|
|
1888 |
|
def __init__(self): |
1889 |
|
bootloaderInfo.__init__(self) |
1890 |
|
self.useSiloVal = 1 |
1891 |
|
self.kernelLocation = "/boot" |
1892 |
|
self.configfile = "/etc/silo.conf" |
1893 |
|
|
1894 |
############### |
############### |
1895 |
# end of boot loader objects... these are just some utility functions used |
# end of boot loader objects... these are just some utility functions used |