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. |
16 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
17 |
# |
# |
18 |
|
|
|
import isys |
|
19 |
import os, sys |
import os, sys |
20 |
|
import isys |
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 |
|
|
839 |
for dev in self.getPhysicalDevices(rootDev): |
for dev in self.getPhysicalDevices(rootDev): |
840 |
usedDevs[dev] = 1 |
usedDevs[dev] = 1 |
841 |
|
|
842 |
|
for dev in bootDevs: |
843 |
|
usedDevs[dev] = 1 |
844 |
|
|
845 |
if not os.access(instRoot + "/boot/grub/device.map", os.R_OK): |
if not os.access(instRoot + "/boot/grub/device.map", os.R_OK): |
846 |
f = open(instRoot + "/boot/grub/device.map", "w+") |
f = open(instRoot + "/boot/grub/device.map", "w+") |
847 |
f.write("# this device map was generated by anaconda\n") |
f.write("# this device map was generated by anaconda\n") |
860 |
# 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. |
861 |
if not drive.startswith('md'): |
if not drive.startswith('md'): |
862 |
f.write("(%s) /dev/%s\n" % (self.grubbyDiskName(drive), |
f.write("(%s) /dev/%s\n" % (self.grubbyDiskName(drive), |
863 |
drive)) |
drive)) |
864 |
f.close() |
f.close() |
865 |
|
|
866 |
if self.forceLBA32: |
if self.forceLBA32: |
880 |
instRoot + sysconf + '.rpmsave') |
instRoot + sysconf + '.rpmsave') |
881 |
f = open(instRoot + sysconf, 'w+') |
f = open(instRoot + sysconf, 'w+') |
882 |
f.write("boot=/dev/%s\n" %(grubTarget,)) |
f.write("boot=/dev/%s\n" %(grubTarget,)) |
883 |
|
# XXX forcelba never gets read back... |
884 |
if self.forceLBA32: |
if self.forceLBA32: |
885 |
f.write("forcelba=1\n") |
f.write("forcelba=1\n") |
886 |
else: |
else: |
889 |
|
|
890 |
cmds = [] |
cmds = [] |
891 |
for bootDev in bootDevs: |
for bootDev in bootDevs: |
892 |
gtPart = self.getMatchingPart(bootDev, grubTarget) |
gtDisk = self.grubbyPartitionName(getDiskPart(bootDev)[0]) |
893 |
gtDisk = self.grubbyPartitionName(getDiskPart(gtPart)[0]) |
bPart = self.grubbyPartitionName(bootDev) |
|
bPart = self.grubbyPartitionName(bootDev) |
|
|
cmd = "root %s" % (bPart,) |
|
|
cmds.append(cmd) |
|
894 |
|
|
895 |
stage1Target = gtDisk |
stage1Target = gtDisk |
896 |
if target == "partition": |
if target == "partition": |
897 |
stage1Target = self.grubbyPartitionName(gtPart) |
stage1Target = self.grubbyPartitionName(bootDev) |
898 |
|
|
899 |
cmd = "install %s%s/stage1 d %s %s/stage2 p %s%s/grub.conf" % \ |
cmd = "root %s\nsetup %s" % (bPart, stage1Target) |
|
(forcelba, grubPath, stage1Target, grubPath, bPart, grubPath) |
|
900 |
cmds.append(cmd) |
cmds.append(cmd) |
901 |
|
|
902 |
if not justConfigFile: |
if not justConfigFile: |
903 |
log("GRUB commands:") |
log("GRUB commands:") |
904 |
for cmd in cmds: |
for cmd in cmds: |
921 |
# really install the bootloader |
# really install the bootloader |
922 |
p = os.pipe() |
p = os.pipe() |
923 |
for cmd in cmds: |
for cmd in cmds: |
924 |
os.write(p[1], cmd + '\n') |
os.write(p[1], cmd + '\n') |
925 |
os.close(p[1]) |
os.close(p[1]) |
926 |
rhpl.executil.execWithRedirect('/sbin/grub' , |
rhpl.executil.execWithRedirect('/sbin/grub' , |
927 |
[ "grub", "--batch", "--no-floppy", |
[ "grub", "--batch", "--no-floppy", |
942 |
return device |
return device |
943 |
return devices[0] |
return devices[0] |
944 |
|
|
|
|
|
945 |
def grubbyDiskName(self, name): |
def grubbyDiskName(self, name): |
946 |
return "hd%d" % self.drivelist.index(name) |
return "hd%d" % self.drivelist.index(name) |
947 |
|
|
991 |
if os.access(instRoot + message, os.R_OK): |
if os.access(instRoot + message, os.R_OK): |
992 |
config.addEntry("message", message, replace = 0) |
config.addEntry("message", message, replace = 0) |
993 |
|
|
994 |
if not config.testEntry('lba32') and not config.testEntry('linear'): |
if not config.testEntry('lba32'): |
995 |
if self.forceLBA32 or (bl.above1024 and |
if self.forceLBA32 or (bl.above1024 and |
996 |
butil.getArch() != "x86_64" and |
butil.getArch() != "x86_64" and |
997 |
edd.detect()): |
edd.detect()): |
998 |
config.addEntry("lba32", replace = 0) |
config.addEntry("lba32", replace = 0) |
|
elif self.useLinear: |
|
|
config.addEntry("linear", replace = 0) |
|
|
else: |
|
|
config.addEntry("nolinear", replace = 0) |
|
999 |
|
|
1000 |
return config |
return config |
1001 |
|
|
|
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 |
|
|
|
|
1002 |
# this is a hackish function that depends on the way anaconda writes |
# this is a hackish function that depends on the way anaconda writes |
1003 |
# out the grub.conf with a #boot= comment |
# out the grub.conf with a #boot= comment |
1004 |
# XXX this falls into the category of self.doUpgradeOnly |
# XXX this falls into the category of self.doUpgradeOnly |
1020 |
f.close() |
f.close() |
1021 |
for line in lines: |
for line in lines: |
1022 |
if line.startswith(stanza): |
if line.startswith(stanza): |
|
import checkbootloader |
|
1023 |
theDev = checkbootloader.getBootDevString(line) |
theDev = checkbootloader.getBootDevString(line) |
1024 |
break |
break |
1025 |
if theDev is not None: |
if theDev is not None: |
1034 |
if not os.access(instRoot + sysconf, os.R_OK): |
if not os.access(instRoot + sysconf, os.R_OK): |
1035 |
f = open(instRoot + sysconf, "w+") |
f = open(instRoot + sysconf, "w+") |
1036 |
f.write("boot=%s\n" %(theDev,)) |
f.write("boot=%s\n" %(theDev,)) |
1037 |
|
# XXX forcelba never gets read back at all... |
1038 |
if self.forceLBA32: |
if self.forceLBA32: |
1039 |
f.write("forcelba=1\n") |
f.write("forcelba=1\n") |
1040 |
else: |
else: |
1081 |
grubbyRootPart = self.grubbyPartitionName(rootDev) |
grubbyRootPart = self.grubbyPartitionName(rootDev) |
1082 |
break |
break |
1083 |
|
|
1084 |
cmd = "root %s\ninstall %s/stage1 d %s %s/stage2 p %s%s/grub.conf" \ |
cmd = "root %s\nsetup %s" % (grubbyRootPart, grubbyStage1Dev) |
|
% (grubbyRootPart, grubPath, grubbyStage1Dev, |
|
|
grubPath, grubbyRootPart, grubPath) |
|
1085 |
|
|
1086 |
if not justConfigFile: |
if not justConfigFile: |
1087 |
log("GRUB command %s", cmd) |
log("GRUB command %s", cmd) |
1088 |
|
|
1089 |
# copy the stage files over into /boot |
# copy the stage files over into /boot |
1090 |
rhpl.executil.execWithRedirect( "/sbin/grub-install", |
rhpl.executil.execWithRedirect( "/sbin/grub-install", |
1091 |
["/sbin/grub-install", "--just-copy"], |
["/sbin/grub-install", "--just-copy"], |
1092 |
stdout = "/dev/tty5", stderr = "/dev/tty5", |
stdout = "/dev/tty5", stderr = "/dev/tty5", |
1093 |
root = instRoot) |
root = instRoot) |
1094 |
|
|
1095 |
# get the stage files synced to disk |
# get the stage files synced to disk |
1096 |
import isys |
import isys |
1097 |
isys.sync() |
isys.sync() |
1098 |
isys.sync() |
isys.sync() |
1099 |
isys.sync() |
isys.sync() |
1100 |
|
|
1101 |
# really install the bootloader |
# really install the bootloader |
1102 |
p = os.pipe() |
p = os.pipe() |
1103 |
os.write(p[1], cmd + '\n') |
os.write(p[1], cmd + '\n') |
1104 |
os.close(p[1]) |
os.close(p[1]) |
1105 |
rhpl.executil.execWithRedirect('/sbin/grub' , |
rhpl.executil.execWithRedirect('/sbin/grub' , |
1106 |
[ "grub", "--batch", "--no-floppy", |
[ "grub", "--batch", "--no-floppy", |
1107 |
"--device-map=/boot/grub/device.map" ], |
"--device-map=/boot/grub/device.map" ], |
1108 |
stdin = p[0], |
stdin = p[0], |
1109 |
stdout = "/dev/tty5", stderr = "/dev/tty5", |
stdout = "/dev/tty5", stderr = "/dev/tty5", |
1110 |
root = instRoot) |
root = instRoot) |
1111 |
os.close(p[0]) |
os.close(p[0]) |
1112 |
|
|
1113 |
return "" |
return "" |
1114 |
|
|
1117 |
defaultDev, justConfig, intf): |
defaultDev, justConfig, intf): |
1118 |
# XXX HACK ALERT - see declaration above |
# XXX HACK ALERT - see declaration above |
1119 |
if self.doUpgradeOnly: |
if self.doUpgradeOnly: |
1120 |
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: |
|
1121 |
self.upgradeGrub(instRoot, fsset, bl, langs, kernelList, |
self.upgradeGrub(instRoot, fsset, bl, langs, kernelList, |
1122 |
chainList, defaultDev, justConfig) |
chainList, defaultDev, justConfig) |
1123 |
|
|
1145 |
if len(kernelList) < 1: |
if len(kernelList) < 1: |
1146 |
self.noKernelsWarn(intf) |
self.noKernelsWarn(intf) |
1147 |
|
|
|
str = self.writeLilo(instRoot, fsset, bl, langs, kernelList, |
|
|
chainList, defaultDev, |
|
|
justConfig | (self.useGrubVal)) |
|
1148 |
str = self.writeGrub(instRoot, fsset, bl, langs, kernelList, |
str = self.writeGrub(instRoot, fsset, bl, langs, kernelList, |
1149 |
chainList, defaultDev, |
chainList, defaultDev, |
1150 |
justConfig | (not self.useGrubVal)) |
justConfig | (not self.useGrubVal)) |
1159 |
def getArgList(self): |
def getArgList(self): |
1160 |
args = bootloaderInfo.getArgList(self) |
args = bootloaderInfo.getArgList(self) |
1161 |
|
|
|
if not self.useGrubVal: |
|
|
args.append("--useLilo") |
|
1162 |
if self.forceLBA32: |
if self.forceLBA32: |
1163 |
args.append("--lba32") |
args.append("--lba32") |
|
if not self.useLinear: |
|
|
args.append("--nolinear") |
|
1164 |
if self.password: |
if self.password: |
1165 |
args.append("--md5pass=%s" %(self.password)) |
args.append("--md5pass=%s" %(self.password)) |
1166 |
|
|
1541 |
bootDev = bootDev.device.getDevice(asBoot = 1) |
bootDev = bootDev.device.getDevice(asBoot = 1) |
1542 |
|
|
1543 |
f = open(instRoot + cf, "w+") |
f = open(instRoot + cf, "w+") |
1544 |
|
|
1545 |
f.write("# yaboot.conf generated by anaconda\n\n") |
f.write("# yaboot.conf generated by anaconda\n\n") |
1546 |
|
|
1547 |
f.write("boot=%s\n" %(yabootTarget,)) |
f.write("boot=%s\n" %(yabootTarget,)) |
1552 |
partno = partNum + 1 # 1 based |
partno = partNum + 1 # 1 based |
1553 |
f.write("partition=%s\n" %(partno,)) |
f.write("partition=%s\n" %(partno,)) |
1554 |
|
|
1555 |
f.write("timeout=20\n") |
f.write("timeout=80\n") |
1556 |
f.write("install=/usr/lib/yaboot/yaboot\n") |
f.write("install=/usr/lib/yaboot/yaboot\n") |
1557 |
f.write("delay=5\n") |
f.write("delay=5\n") |
1558 |
|
f.write("enablecdboot\n") |
1559 |
|
f.write("enableofboot\n") |
1560 |
|
f.write("enablenetboot\n") |
1561 |
|
|
1562 |
if butil.getPPCMachine() == "PMac": |
if butil.getPPCMachine() == "PMac": |
1563 |
|
# write out the first hfs/hfs+ partition as being macosx |
1564 |
|
for (label, longlabel, device) in chainList: |
1565 |
|
if ((not label) or (label == "")): |
1566 |
|
continue |
1567 |
|
f.write("macosx=/dev/%s\n" %(device,)) |
1568 |
|
break |
1569 |
|
|
1570 |
f.write("magicboot=/usr/lib/yaboot/ofboot\n") |
f.write("magicboot=/usr/lib/yaboot/ofboot\n") |
1571 |
|
|
1572 |
if butil.getPPCMachine() == "pSeries": |
if butil.getPPCMachine() == "pSeries": |
1575 |
if self.password: |
if self.password: |
1576 |
f.write("password=%s\n" %(self.password,)) |
f.write("password=%s\n" %(self.password,)) |
1577 |
f.write("restricted\n") |
f.write("restricted\n") |
|
|
|
1578 |
|
|
1579 |
f.write("\n") |
f.write("\n") |
1580 |
|
|
1622 |
|
|
1623 |
|
|
1624 |
log("running: %s" %(ybinargs,)) |
log("running: %s" %(ybinargs,)) |
1625 |
if not flags.test: |
if not flags.test: |
1626 |
rhpl.executil.execWithRedirect(ybinargs[0], |
rhpl.executil.execWithRedirect(ybinargs[0], |
1627 |
ybinargs, |
ybinargs, |
1628 |
stdout = "/dev/tty5", |
stdout = "/dev/tty5", |
1766 |
bootloaderInfo.__init__(self) |
bootloaderInfo.__init__(self) |
1767 |
self.kernelLocation = "/boot/" |
self.kernelLocation = "/boot/" |
1768 |
|
|
1769 |
|
class sparcBootloaderInfo(bootloaderInfo): |
1770 |
|
def writeSilo(self, instRoot, fsset, bl, langs, kernelList, |
1771 |
|
chainList, defaultDev, justConfigFile): |
1772 |
|
|
1773 |
|
from flags import flags |
1774 |
|
|
1775 |
|
bootDev = fsset.getEntryByMountPoint("/boot") |
1776 |
|
if bootDev: |
1777 |
|
cf = "/boot/silo.conf" |
1778 |
|
mf = "/boot/silo.message" |
1779 |
|
cfPath = "" |
1780 |
|
if not os.path.isdir(instRoot + "/boot"): |
1781 |
|
os.mkdir(instRoot + "/boot") |
1782 |
|
else: |
1783 |
|
bootDev = fsset.getEntryByMountPoint("/") |
1784 |
|
cf = "/etc/silo.conf" |
1785 |
|
mf = "/etc/silo.message" |
1786 |
|
cfPath = "/boot" |
1787 |
|
bootDev = bootDev.device.getDevice(asBoot = 1) |
1788 |
|
|
1789 |
|
f = open(instRoot + mf, "w+") |
1790 |
|
f.write("Welcome to %s!\nHit <TAB> for boot options\n\n" % \ |
1791 |
|
(butil.getProductName(),)) |
1792 |
|
f.close() |
1793 |
|
os.chmod(instRoot + mf, 0600) |
1794 |
|
|
1795 |
|
f = open(instRoot + cf, "w+") |
1796 |
|
f.write("# silo.conf generated by anaconda\n\n") |
1797 |
|
|
1798 |
|
f.write("#boot=%s\n" % (bootDev,)) |
1799 |
|
f.write("message=%s\n" % (mf,)) |
1800 |
|
f.write("timeout=50\n") |
1801 |
|
|
1802 |
|
(name, partNum) = getDiskPart(bootDev) |
1803 |
|
partno = partNum + 1 |
1804 |
|
f.write("partition=%s\n" % (partno,)) |
1805 |
|
|
1806 |
|
if self.password: |
1807 |
|
f.write("password=%s\n" % (self.password,)) |
1808 |
|
f.write("restricted\n") |
1809 |
|
|
1810 |
|
f.write("default=%s\n" % (kernelList[0][0],)) |
1811 |
|
f.write("\n") |
1812 |
|
|
1813 |
|
rootDev = fsset.getEntryByMountPoint("/").device.getDevice() |
1814 |
|
|
1815 |
|
for (label, longlabel, version) in kernelList: |
1816 |
|
kernelTag = "-" + version |
1817 |
|
kernelFile = "%s/vmlinuz%s" % (cfPath, kernelTag) |
1818 |
|
|
1819 |
|
f.write("image=%s\n" % (kernelFile,)) |
1820 |
|
f.write("\tlabel=%s\n" % (label,)) |
1821 |
|
f.write("\tread-only\n") |
1822 |
|
|
1823 |
|
initrd = booty.makeInitrd(kernelTag, instRoot) |
1824 |
|
if os.access(instRoot + initrd, os.R_OK): |
1825 |
|
f.write("\tinitrd=%s/initrd%s.img\n" % (cfPath, kernelTag)) |
1826 |
|
|
1827 |
|
append = "%s" % (self.args.get(),) |
1828 |
|
|
1829 |
|
realroot = getRootDevName(initrd, fsset, rootDev, instRoot) |
1830 |
|
if not realroot.startswith("LABEL="): |
1831 |
|
f.write("\troot=%s\n" % (realroot,)) |
1832 |
|
else: |
1833 |
|
if len(append) > 0: |
1834 |
|
append = "%s root=%s" % (append, realroot) |
1835 |
|
else: |
1836 |
|
append = "root=%s" % (realroot,) |
1837 |
|
|
1838 |
|
if len(append) > 0: |
1839 |
|
f.write("\tappend=\"%s\"\n" % (append,)) |
1840 |
|
f.write("\n") |
1841 |
|
|
1842 |
|
f.close() |
1843 |
|
os.chmod(instRoot + cf, 0600) |
1844 |
|
|
1845 |
|
# FIXME: hack to make sure things are written to disk |
1846 |
|
import isys |
1847 |
|
isys.sync() |
1848 |
|
isys.sync() |
1849 |
|
isys.sync() |
1850 |
|
|
1851 |
|
backup = "%s/backup.b" % (cfPath,) |
1852 |
|
sbinargs = ["/sbin/silo", "-f", "-C", cf, "-S", backup] |
1853 |
|
if butil.getSparcMachine() == "sun4u": |
1854 |
|
sbinargs += ["-u"] |
1855 |
|
else: |
1856 |
|
sbinargs += ["-U"] |
1857 |
|
|
1858 |
|
log("running: %s" % (sbinargs,)) |
1859 |
|
if not flags.test: |
1860 |
|
rhpl.executil.execWithRedirect(sbinargs[0], |
1861 |
|
sbinargs, |
1862 |
|
stdout = "/dev/tty5", |
1863 |
|
stderr = "/dev/tty5", |
1864 |
|
root = instRoot) |
1865 |
|
|
1866 |
|
if (not os.access(instRoot + "/etc/silo.conf", os.R_OK) and |
1867 |
|
os.access(instRoot + "/boot/etc/silo.conf", os.R_OK)): |
1868 |
|
os.symlink("../boot/etc/silo.conf", |
1869 |
|
instRoot + "/etc/silo.conf") |
1870 |
|
|
1871 |
|
return "" |
1872 |
|
|
1873 |
|
def setPassword(self, val, isCrypted = 1): |
1874 |
|
# silo just handles the password unencrypted |
1875 |
|
self.password = val |
1876 |
|
|
1877 |
|
def write(self, instRoot, fsset, bl, langs, kernelList, chainList, |
1878 |
|
defaultDev, justConfig, intf): |
1879 |
|
if len(kernelList) >= 1: |
1880 |
|
self.writeSilo(instRoot, fsset, bl, langs, kernelList, chainList, |
1881 |
|
defaultDev, justConfig) |
1882 |
|
else: |
1883 |
|
self.noKernelsWarn(intf) |
1884 |
|
|
1885 |
|
def __init__(self): |
1886 |
|
bootloaderInfo.__init__(self) |
1887 |
|
self.useSiloVal = 1 |
1888 |
|
self.kernelLocation = "/boot" |
1889 |
|
self.configfile = "/etc/silo.conf" |
1890 |
|
|
1891 |
############### |
############### |
1892 |
# end of boot loader objects... these are just some utility functions used |
# end of boot loader objects... these are just some utility functions used |