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: |
886 |
|
|
887 |
cmds = [] |
cmds = [] |
888 |
for bootDev in bootDevs: |
for bootDev in bootDevs: |
889 |
gtPart = self.getMatchingPart(bootDev, grubTarget) |
gtDisk = self.grubbyPartitionName(getDiskPart(bootDev)[0]) |
890 |
gtDisk = self.grubbyPartitionName(getDiskPart(gtPart)[0]) |
bPart = self.grubbyPartitionName(bootDev) |
|
bPart = self.grubbyPartitionName(bootDev) |
|
891 |
cmd = "root %s" % (bPart,) |
cmd = "root %s" % (bPart,) |
892 |
cmds.append(cmd) |
cmds.append(cmd) |
893 |
|
|
894 |
stage1Target = gtDisk |
stage1Target = gtDisk |
895 |
if target == "partition": |
if target == "partition": |
896 |
stage1Target = self.grubbyPartitionName(gtPart) |
stage1Target = self.grubbyPartitionName(bootDev) |
897 |
|
|
898 |
cmd = "install %s --stage2=/boot/grub/stage2 %s%s/stage1 %s %s%s/stage2 p %s/grub.conf" % \ |
cmd = "install %s/stage1 %s %s1+16 p %s%s/stage2 %s/grub.conf" % \ |
899 |
(forcelba, bPart, grubPath, stage1Target, bPart, grubPath, grubPath) |
(grubPath, stage1Target, stage1Target, bPart, grubPath, 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 --stage2=/boot/grub/stage2 %s%s/stage1 %s %s%s/stage2 p %s/grub.conf" \ |
cmd = "root %s\ninstall %s/stage1 %s %s1+16 p %s%s/stage2 %s/grub.conf" \ |
1085 |
% (grubbyRootPart, grubbyRootPart, grubPath, grubbyStage1Dev, |
% (grubbyRootPart, grubPath, stage1Dev, stage1Dev, |
1086 |
grubbyRootPart, grubPath, grubPath) |
grubbyRootPart, grubPath, grubPath) |
1087 |
|
|
1088 |
if not justConfigFile: |
if not justConfigFile: |
1089 |
log("GRUB command %s", cmd) |
log("GRUB command %s", cmd) |
1090 |
|
|
1091 |
# copy the stage files over into /boot |
# copy the stage files over into /boot |
1092 |
rhpl.executil.execWithRedirect( "/sbin/grub-install", |
rhpl.executil.execWithRedirect( "/sbin/grub-install", |
1093 |
["/sbin/grub-install", "--just-copy"], |
["/sbin/grub-install", "--just-copy"], |
1094 |
stdout = "/dev/tty5", stderr = "/dev/tty5", |
stdout = "/dev/tty5", stderr = "/dev/tty5", |
1095 |
root = instRoot) |
root = instRoot) |
1096 |
|
|
1097 |
# get the stage files synced to disk |
# get the stage files synced to disk |
1098 |
import isys |
import isys |
1099 |
isys.sync() |
isys.sync() |
1100 |
isys.sync() |
isys.sync() |
1101 |
isys.sync() |
isys.sync() |
1102 |
|
|
1103 |
# really install the bootloader |
# really install the bootloader |
1104 |
p = os.pipe() |
p = os.pipe() |
1105 |
os.write(p[1], cmd + '\n') |
os.write(p[1], cmd + '\n') |
1106 |
os.close(p[1]) |
os.close(p[1]) |
1107 |
rhpl.executil.execWithRedirect('/sbin/grub' , |
rhpl.executil.execWithRedirect('/sbin/grub' , |
1108 |
[ "grub", "--batch", "--no-floppy", |
[ "grub", "--batch", "--no-floppy", |
1109 |
"--device-map=/boot/grub/device.map" ], |
"--device-map=/boot/grub/device.map" ], |
1110 |
stdin = p[0], |
stdin = p[0], |
1111 |
stdout = "/dev/tty5", stderr = "/dev/tty5", |
stdout = "/dev/tty5", stderr = "/dev/tty5", |
1112 |
root = instRoot) |
root = instRoot) |
1113 |
os.close(p[0]) |
os.close(p[0]) |
1114 |
|
|
1115 |
return "" |
return "" |
1116 |
|
|
1119 |
defaultDev, justConfig, intf): |
defaultDev, justConfig, intf): |
1120 |
# XXX HACK ALERT - see declaration above |
# XXX HACK ALERT - see declaration above |
1121 |
if self.doUpgradeOnly: |
if self.doUpgradeOnly: |
1122 |
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: |
|
1123 |
self.upgradeGrub(instRoot, fsset, bl, langs, kernelList, |
self.upgradeGrub(instRoot, fsset, bl, langs, kernelList, |
1124 |
chainList, defaultDev, justConfig) |
chainList, defaultDev, justConfig) |
1125 |
|
|
1147 |
if len(kernelList) < 1: |
if len(kernelList) < 1: |
1148 |
self.noKernelsWarn(intf) |
self.noKernelsWarn(intf) |
1149 |
|
|
|
str = self.writeLilo(instRoot, fsset, bl, langs, kernelList, |
|
|
chainList, defaultDev, |
|
|
justConfig | (self.useGrubVal)) |
|
1150 |
str = self.writeGrub(instRoot, fsset, bl, langs, kernelList, |
str = self.writeGrub(instRoot, fsset, bl, langs, kernelList, |
1151 |
chainList, defaultDev, |
chainList, defaultDev, |
1152 |
justConfig | (not self.useGrubVal)) |
justConfig | (not self.useGrubVal)) |
1161 |
def getArgList(self): |
def getArgList(self): |
1162 |
args = bootloaderInfo.getArgList(self) |
args = bootloaderInfo.getArgList(self) |
1163 |
|
|
|
if not self.useGrubVal: |
|
|
args.append("--useLilo") |
|
1164 |
if self.forceLBA32: |
if self.forceLBA32: |
1165 |
args.append("--lba32") |
args.append("--lba32") |
|
if not self.useLinear: |
|
|
args.append("--nolinear") |
|
1166 |
if self.password: |
if self.password: |
1167 |
args.append("--md5pass=%s" %(self.password)) |
args.append("--md5pass=%s" %(self.password)) |
1168 |
|
|
1543 |
bootDev = bootDev.device.getDevice(asBoot = 1) |
bootDev = bootDev.device.getDevice(asBoot = 1) |
1544 |
|
|
1545 |
f = open(instRoot + cf, "w+") |
f = open(instRoot + cf, "w+") |
1546 |
|
|
1547 |
f.write("# yaboot.conf generated by anaconda\n\n") |
f.write("# yaboot.conf generated by anaconda\n\n") |
1548 |
|
|
1549 |
f.write("boot=%s\n" %(yabootTarget,)) |
f.write("boot=%s\n" %(yabootTarget,)) |
1554 |
partno = partNum + 1 # 1 based |
partno = partNum + 1 # 1 based |
1555 |
f.write("partition=%s\n" %(partno,)) |
f.write("partition=%s\n" %(partno,)) |
1556 |
|
|
1557 |
f.write("timeout=20\n") |
f.write("timeout=80\n") |
1558 |
f.write("install=/usr/lib/yaboot/yaboot\n") |
f.write("install=/usr/lib/yaboot/yaboot\n") |
1559 |
f.write("delay=5\n") |
f.write("delay=5\n") |
1560 |
|
f.write("enablecdboot\n") |
1561 |
|
f.write("enableofboot\n") |
1562 |
|
f.write("enablenetboot\n") |
1563 |
|
|
1564 |
if butil.getPPCMachine() == "PMac": |
if butil.getPPCMachine() == "PMac": |
1565 |
|
# write out the first hfs/hfs+ partition as being macosx |
1566 |
|
for (label, longlabel, device) in chainList: |
1567 |
|
if ((not label) or (label == "")): |
1568 |
|
continue |
1569 |
|
f.write("macosx=/dev/%s\n" %(device,)) |
1570 |
|
break |
1571 |
|
|
1572 |
f.write("magicboot=/usr/lib/yaboot/ofboot\n") |
f.write("magicboot=/usr/lib/yaboot/ofboot\n") |
1573 |
|
|
1574 |
if butil.getPPCMachine() == "pSeries": |
if butil.getPPCMachine() == "pSeries": |
1577 |
if self.password: |
if self.password: |
1578 |
f.write("password=%s\n" %(self.password,)) |
f.write("password=%s\n" %(self.password,)) |
1579 |
f.write("restricted\n") |
f.write("restricted\n") |
|
|
|
1580 |
|
|
1581 |
f.write("\n") |
f.write("\n") |
1582 |
|
|
1624 |
|
|
1625 |
|
|
1626 |
log("running: %s" %(ybinargs,)) |
log("running: %s" %(ybinargs,)) |
1627 |
if not flags.test: |
if not flags.test: |
1628 |
rhpl.executil.execWithRedirect(ybinargs[0], |
rhpl.executil.execWithRedirect(ybinargs[0], |
1629 |
ybinargs, |
ybinargs, |
1630 |
stdout = "/dev/tty5", |
stdout = "/dev/tty5", |
1768 |
bootloaderInfo.__init__(self) |
bootloaderInfo.__init__(self) |
1769 |
self.kernelLocation = "/boot/" |
self.kernelLocation = "/boot/" |
1770 |
|
|
1771 |
|
class sparcBootloaderInfo(bootloaderInfo): |
1772 |
|
def writeSilo(self, instRoot, fsset, bl, langs, kernelList, |
1773 |
|
chainList, defaultDev, justConfigFile): |
1774 |
|
|
1775 |
|
from flags import flags |
1776 |
|
|
1777 |
|
bootDev = fsset.getEntryByMountPoint("/boot") |
1778 |
|
if bootDev: |
1779 |
|
cf = "/boot/silo.conf" |
1780 |
|
mf = "/boot/silo.message" |
1781 |
|
cfPath = "" |
1782 |
|
if not os.path.isdir(instRoot + "/boot"): |
1783 |
|
os.mkdir(instRoot + "/boot") |
1784 |
|
else: |
1785 |
|
bootDev = fsset.getEntryByMountPoint("/") |
1786 |
|
cf = "/etc/silo.conf" |
1787 |
|
mf = "/etc/silo.message" |
1788 |
|
cfPath = "/boot" |
1789 |
|
bootDev = bootDev.device.getDevice(asBoot = 1) |
1790 |
|
|
1791 |
|
f = open(instRoot + mf, "w+") |
1792 |
|
f.write("Welcome to %s!\nHit <TAB> for boot options\n\n" % \ |
1793 |
|
(butil.getProductName(),)) |
1794 |
|
f.close() |
1795 |
|
os.chmod(instRoot + mf, 0600) |
1796 |
|
|
1797 |
|
f = open(instRoot + cf, "w+") |
1798 |
|
f.write("# silo.conf generated by anaconda\n\n") |
1799 |
|
|
1800 |
|
f.write("#boot=%s\n" % (bootDev,)) |
1801 |
|
f.write("message=%s\n" % (mf,)) |
1802 |
|
f.write("timeout=50\n") |
1803 |
|
|
1804 |
|
(name, partNum) = getDiskPart(bootDev) |
1805 |
|
partno = partNum + 1 |
1806 |
|
f.write("partition=%s\n" % (partno,)) |
1807 |
|
|
1808 |
|
if self.password: |
1809 |
|
f.write("password=%s\n" % (self.password,)) |
1810 |
|
f.write("restricted\n") |
1811 |
|
|
1812 |
|
f.write("default=%s\n" % (kernelList[0][0],)) |
1813 |
|
f.write("\n") |
1814 |
|
|
1815 |
|
rootDev = fsset.getEntryByMountPoint("/").device.getDevice() |
1816 |
|
|
1817 |
|
for (label, longlabel, version) in kernelList: |
1818 |
|
kernelTag = "-" + version |
1819 |
|
kernelFile = "%s/vmlinuz%s" % (cfPath, kernelTag) |
1820 |
|
|
1821 |
|
f.write("image=%s\n" % (kernelFile,)) |
1822 |
|
f.write("\tlabel=%s\n" % (label,)) |
1823 |
|
f.write("\tread-only\n") |
1824 |
|
|
1825 |
|
initrd = booty.makeInitrd(kernelTag, instRoot) |
1826 |
|
if os.access(instRoot + initrd, os.R_OK): |
1827 |
|
f.write("\tinitrd=%s/initrd%s.img\n" % (cfPath, kernelTag)) |
1828 |
|
|
1829 |
|
append = "%s" % (self.args.get(),) |
1830 |
|
|
1831 |
|
realroot = getRootDevName(initrd, fsset, rootDev, instRoot) |
1832 |
|
if not realroot.startswith("LABEL="): |
1833 |
|
f.write("\troot=%s\n" % (realroot,)) |
1834 |
|
else: |
1835 |
|
if len(append) > 0: |
1836 |
|
append = "%s root=%s" % (append, realroot) |
1837 |
|
else: |
1838 |
|
append = "root=%s" % (realroot,) |
1839 |
|
|
1840 |
|
if len(append) > 0: |
1841 |
|
f.write("\tappend=\"%s\"\n" % (append,)) |
1842 |
|
f.write("\n") |
1843 |
|
|
1844 |
|
f.close() |
1845 |
|
os.chmod(instRoot + cf, 0600) |
1846 |
|
|
1847 |
|
# FIXME: hack to make sure things are written to disk |
1848 |
|
import isys |
1849 |
|
isys.sync() |
1850 |
|
isys.sync() |
1851 |
|
isys.sync() |
1852 |
|
|
1853 |
|
backup = "%s/backup.b" % (cfPath,) |
1854 |
|
sbinargs = ["/sbin/silo", "-f", "-C", cf, "-S", backup] |
1855 |
|
if butil.getSparcMachine() == "sun4u": |
1856 |
|
sbinargs += ["-u"] |
1857 |
|
else: |
1858 |
|
sbinargs += ["-U"] |
1859 |
|
|
1860 |
|
log("running: %s" % (sbinargs,)) |
1861 |
|
if not flags.test: |
1862 |
|
rhpl.executil.execWithRedirect(sbinargs[0], |
1863 |
|
sbinargs, |
1864 |
|
stdout = "/dev/tty5", |
1865 |
|
stderr = "/dev/tty5", |
1866 |
|
root = instRoot) |
1867 |
|
|
1868 |
|
if (not os.access(instRoot + "/etc/silo.conf", os.R_OK) and |
1869 |
|
os.access(instRoot + "/boot/etc/silo.conf", os.R_OK)): |
1870 |
|
os.symlink("../boot/etc/silo.conf", |
1871 |
|
instRoot + "/etc/silo.conf") |
1872 |
|
|
1873 |
|
return "" |
1874 |
|
|
1875 |
|
def setPassword(self, val, isCrypted = 1): |
1876 |
|
# silo just handles the password unencrypted |
1877 |
|
self.password = val |
1878 |
|
|
1879 |
|
def write(self, instRoot, fsset, bl, langs, kernelList, chainList, |
1880 |
|
defaultDev, justConfig, intf): |
1881 |
|
if len(kernelList) >= 1: |
1882 |
|
self.writeSilo(instRoot, fsset, bl, langs, kernelList, chainList, |
1883 |
|
defaultDev, justConfig) |
1884 |
|
else: |
1885 |
|
self.noKernelsWarn(intf) |
1886 |
|
|
1887 |
|
def __init__(self): |
1888 |
|
bootloaderInfo.__init__(self) |
1889 |
|
self.useSiloVal = 1 |
1890 |
|
self.kernelLocation = "/boot" |
1891 |
|
self.configfile = "/etc/silo.conf" |
1892 |
|
|
1893 |
############### |
############### |
1894 |
# end of boot loader objects... these are just some utility functions used |
# end of boot loader objects... these are just some utility functions used |