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 |
727 |
|
if isys.smpAvailable() or isys.htavailable(): |
728 |
|
smpCapable=1 |
729 |
|
else: |
730 |
|
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 |
733 |
# since grub indexes by where it is in the config file |
# since grub indexes by where it is in the config file |
734 |
if defaultDev == rootDev: |
if defaultDev == rootDev: |
735 |
for kernel in range(0, len(kernelList)): |
for kernel in range(0, len(kernelList)): |
736 |
default=kernel |
default=kernel |
737 |
if kernelList[kernel][2].find('smp')<0 or isys.smpAvailable() or isys.htavailable(): |
version=kernelList[kernel][2] |
738 |
break |
if version.find('smp')<0 and not smpCapable: |
739 |
|
break |
740 |
|
if version.find('smp')>=0 and smpCapable: |
741 |
|
break |
742 |
else: |
else: |
743 |
# if the default isn't linux, it's the first thing in the |
# if the default isn't linux, it's the first thing in the |
744 |
# chain list |
# chain list |
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: |
902 |
cmd = "install %s%s/stage1 d %s %s/stage2 p %s%s/grub.conf" % \ |
cmd = "install %s%s/stage1 d %s %s/stage2 p %s%s/grub.conf" % \ |
903 |
(forcelba, grubPath, stage1Target, grubPath, bPart, grubPath) |
(forcelba, grubPath, stage1Target, grubPath, bPart, grubPath) |
904 |
cmds.append(cmd) |
cmds.append(cmd) |
905 |
|
|
906 |
if not justConfigFile: |
if not justConfigFile: |
907 |
log("GRUB commands:") |
log("GRUB commands:") |
908 |
for cmd in cmds: |
for cmd in cmds: |
925 |
# really install the bootloader |
# really install the bootloader |
926 |
p = os.pipe() |
p = os.pipe() |
927 |
for cmd in cmds: |
for cmd in cmds: |
928 |
os.write(p[1], cmd + '\n') |
os.write(p[1], cmd + '\n') |
929 |
os.close(p[1]) |
os.close(p[1]) |
930 |
rhpl.executil.execWithRedirect('/sbin/grub' , |
rhpl.executil.execWithRedirect('/sbin/grub' , |
931 |
[ "grub", "--batch", "--no-floppy", |
[ "grub", "--batch", "--no-floppy", |
946 |
return device |
return device |
947 |
return devices[0] |
return devices[0] |
948 |
|
|
|
|
|
949 |
def grubbyDiskName(self, name): |
def grubbyDiskName(self, name): |
950 |
return "hd%d" % self.drivelist.index(name) |
return "hd%d" % self.drivelist.index(name) |
951 |
|
|
995 |
if os.access(instRoot + message, os.R_OK): |
if os.access(instRoot + message, os.R_OK): |
996 |
config.addEntry("message", message, replace = 0) |
config.addEntry("message", message, replace = 0) |
997 |
|
|
998 |
if not config.testEntry('lba32') and not config.testEntry('linear'): |
if not config.testEntry('lba32'): |
999 |
if self.forceLBA32 or (bl.above1024 and |
if self.forceLBA32 or (bl.above1024 and |
1000 |
butil.getArch() != "x86_64" and |
butil.getArch() != "x86_64" and |
1001 |
edd.detect()): |
edd.detect()): |
1002 |
config.addEntry("lba32", replace = 0) |
config.addEntry("lba32", replace = 0) |
|
elif self.useLinear: |
|
|
config.addEntry("linear", replace = 0) |
|
|
else: |
|
|
config.addEntry("nolinear", replace = 0) |
|
1003 |
|
|
1004 |
return config |
return config |
1005 |
|
|
|
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 |
|
|
|
|
1006 |
# this is a hackish function that depends on the way anaconda writes |
# this is a hackish function that depends on the way anaconda writes |
1007 |
# out the grub.conf with a #boot= comment |
# out the grub.conf with a #boot= comment |
1008 |
# XXX this falls into the category of self.doUpgradeOnly |
# XXX this falls into the category of self.doUpgradeOnly |
1024 |
f.close() |
f.close() |
1025 |
for line in lines: |
for line in lines: |
1026 |
if line.startswith(stanza): |
if line.startswith(stanza): |
|
import checkbootloader |
|
1027 |
theDev = checkbootloader.getBootDevString(line) |
theDev = checkbootloader.getBootDevString(line) |
1028 |
break |
break |
1029 |
if theDev is not None: |
if theDev is not None: |
1038 |
if not os.access(instRoot + sysconf, os.R_OK): |
if not os.access(instRoot + sysconf, os.R_OK): |
1039 |
f = open(instRoot + sysconf, "w+") |
f = open(instRoot + sysconf, "w+") |
1040 |
f.write("boot=%s\n" %(theDev,)) |
f.write("boot=%s\n" %(theDev,)) |
1041 |
|
# XXX forcelba never gets read back at all... |
1042 |
if self.forceLBA32: |
if self.forceLBA32: |
1043 |
f.write("forcelba=1\n") |
f.write("forcelba=1\n") |
1044 |
else: |
else: |
1089 |
% (grubbyRootPart, grubPath, grubbyStage1Dev, |
% (grubbyRootPart, grubPath, grubbyStage1Dev, |
1090 |
grubPath, grubbyRootPart, grubPath) |
grubPath, grubbyRootPart, grubPath) |
1091 |
|
|
1092 |
if not justConfigFile: |
if not justConfigFile: |
1093 |
log("GRUB command %s", cmd) |
log("GRUB command %s", cmd) |
1094 |
|
|
1095 |
# copy the stage files over into /boot |
# copy the stage files over into /boot |
1096 |
rhpl.executil.execWithRedirect( "/sbin/grub-install", |
rhpl.executil.execWithRedirect( "/sbin/grub-install", |
1097 |
["/sbin/grub-install", "--just-copy"], |
["/sbin/grub-install", "--just-copy"], |
1098 |
stdout = "/dev/tty5", stderr = "/dev/tty5", |
stdout = "/dev/tty5", stderr = "/dev/tty5", |
1099 |
root = instRoot) |
root = instRoot) |
1100 |
|
|
1101 |
# get the stage files synced to disk |
# get the stage files synced to disk |
1102 |
import isys |
import isys |
1103 |
isys.sync() |
isys.sync() |
1104 |
isys.sync() |
isys.sync() |
1105 |
isys.sync() |
isys.sync() |
1106 |
|
|
1107 |
# really install the bootloader |
# really install the bootloader |
1108 |
p = os.pipe() |
p = os.pipe() |
1109 |
os.write(p[1], cmd + '\n') |
os.write(p[1], cmd + '\n') |
1110 |
os.close(p[1]) |
os.close(p[1]) |
1111 |
rhpl.executil.execWithRedirect('/sbin/grub' , |
rhpl.executil.execWithRedirect('/sbin/grub' , |
1112 |
[ "grub", "--batch", "--no-floppy", |
[ "grub", "--batch", "--no-floppy", |
1113 |
"--device-map=/boot/grub/device.map" ], |
"--device-map=/boot/grub/device.map" ], |
1114 |
stdin = p[0], |
stdin = p[0], |
1115 |
stdout = "/dev/tty5", stderr = "/dev/tty5", |
stdout = "/dev/tty5", stderr = "/dev/tty5", |
1116 |
root = instRoot) |
root = instRoot) |
1117 |
os.close(p[0]) |
os.close(p[0]) |
1118 |
|
|
1119 |
return "" |
return "" |
1120 |
|
|
1123 |
defaultDev, justConfig, intf): |
defaultDev, justConfig, intf): |
1124 |
# XXX HACK ALERT - see declaration above |
# XXX HACK ALERT - see declaration above |
1125 |
if self.doUpgradeOnly: |
if self.doUpgradeOnly: |
1126 |
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: |
|
1127 |
self.upgradeGrub(instRoot, fsset, bl, langs, kernelList, |
self.upgradeGrub(instRoot, fsset, bl, langs, kernelList, |
1128 |
chainList, defaultDev, justConfig) |
chainList, defaultDev, justConfig) |
1129 |
|
|
1151 |
if len(kernelList) < 1: |
if len(kernelList) < 1: |
1152 |
self.noKernelsWarn(intf) |
self.noKernelsWarn(intf) |
1153 |
|
|
|
str = self.writeLilo(instRoot, fsset, bl, langs, kernelList, |
|
|
chainList, defaultDev, |
|
|
justConfig | (self.useGrubVal)) |
|
1154 |
str = self.writeGrub(instRoot, fsset, bl, langs, kernelList, |
str = self.writeGrub(instRoot, fsset, bl, langs, kernelList, |
1155 |
chainList, defaultDev, |
chainList, defaultDev, |
1156 |
justConfig | (not self.useGrubVal)) |
justConfig | (not self.useGrubVal)) |
1165 |
def getArgList(self): |
def getArgList(self): |
1166 |
args = bootloaderInfo.getArgList(self) |
args = bootloaderInfo.getArgList(self) |
1167 |
|
|
|
if not self.useGrubVal: |
|
|
args.append("--useLilo") |
|
1168 |
if self.forceLBA32: |
if self.forceLBA32: |
1169 |
args.append("--lba32") |
args.append("--lba32") |
|
if not self.useLinear: |
|
|
args.append("--nolinear") |
|
1170 |
if self.password: |
if self.password: |
1171 |
args.append("--md5pass=%s" %(self.password)) |
args.append("--md5pass=%s" %(self.password)) |
1172 |
|
|
1547 |
bootDev = bootDev.device.getDevice(asBoot = 1) |
bootDev = bootDev.device.getDevice(asBoot = 1) |
1548 |
|
|
1549 |
f = open(instRoot + cf, "w+") |
f = open(instRoot + cf, "w+") |
1550 |
|
|
1551 |
f.write("# yaboot.conf generated by anaconda\n\n") |
f.write("# yaboot.conf generated by anaconda\n\n") |
1552 |
|
|
1553 |
f.write("boot=%s\n" %(yabootTarget,)) |
f.write("boot=%s\n" %(yabootTarget,)) |
1558 |
partno = partNum + 1 # 1 based |
partno = partNum + 1 # 1 based |
1559 |
f.write("partition=%s\n" %(partno,)) |
f.write("partition=%s\n" %(partno,)) |
1560 |
|
|
1561 |
f.write("timeout=20\n") |
f.write("timeout=80\n") |
1562 |
f.write("install=/usr/lib/yaboot/yaboot\n") |
f.write("install=/usr/lib/yaboot/yaboot\n") |
1563 |
f.write("delay=5\n") |
f.write("delay=5\n") |
1564 |
|
f.write("enablecdboot\n") |
1565 |
|
f.write("enableofboot\n") |
1566 |
|
f.write("enablenetboot\n") |
1567 |
|
|
1568 |
if butil.getPPCMachine() == "PMac": |
if butil.getPPCMachine() == "PMac": |
1569 |
|
# write out the first hfs/hfs+ partition as being macosx |
1570 |
|
for (label, longlabel, device) in chainList: |
1571 |
|
if ((not label) or (label == "")): |
1572 |
|
continue |
1573 |
|
f.write("macosx=/dev/%s\n" %(device,)) |
1574 |
|
break |
1575 |
|
|
1576 |
f.write("magicboot=/usr/lib/yaboot/ofboot\n") |
f.write("magicboot=/usr/lib/yaboot/ofboot\n") |
1577 |
|
|
1578 |
if butil.getPPCMachine() == "pSeries": |
if butil.getPPCMachine() == "pSeries": |
1581 |
if self.password: |
if self.password: |
1582 |
f.write("password=%s\n" %(self.password,)) |
f.write("password=%s\n" %(self.password,)) |
1583 |
f.write("restricted\n") |
f.write("restricted\n") |
|
|
|
1584 |
|
|
1585 |
f.write("\n") |
f.write("\n") |
1586 |
|
|
1628 |
|
|
1629 |
|
|
1630 |
log("running: %s" %(ybinargs,)) |
log("running: %s" %(ybinargs,)) |
1631 |
if not flags.test: |
if not flags.test: |
1632 |
rhpl.executil.execWithRedirect(ybinargs[0], |
rhpl.executil.execWithRedirect(ybinargs[0], |
1633 |
ybinargs, |
ybinargs, |
1634 |
stdout = "/dev/tty5", |
stdout = "/dev/tty5", |
1772 |
bootloaderInfo.__init__(self) |
bootloaderInfo.__init__(self) |
1773 |
self.kernelLocation = "/boot/" |
self.kernelLocation = "/boot/" |
1774 |
|
|
1775 |
|
class sparcBootloaderInfo(bootloaderInfo): |
1776 |
|
def writeSilo(self, instRoot, fsset, bl, langs, kernelList, |
1777 |
|
chainList, defaultDev, justConfigFile): |
1778 |
|
|
1779 |
|
from flags import flags |
1780 |
|
|
1781 |
|
bootDev = fsset.getEntryByMountPoint("/boot") |
1782 |
|
if bootDev: |
1783 |
|
cf = "/boot/silo.conf" |
1784 |
|
mf = "/boot/silo.message" |
1785 |
|
cfPath = "" |
1786 |
|
if not os.path.isdir(instRoot + "/boot"): |
1787 |
|
os.mkdir(instRoot + "/boot") |
1788 |
|
else: |
1789 |
|
bootDev = fsset.getEntryByMountPoint("/") |
1790 |
|
cf = "/etc/silo.conf" |
1791 |
|
mf = "/etc/silo.message" |
1792 |
|
cfPath = "/boot" |
1793 |
|
bootDev = bootDev.device.getDevice(asBoot = 1) |
1794 |
|
|
1795 |
|
f = open(instRoot + mf, "w+") |
1796 |
|
f.write("Welcome to %s!\nHit <TAB> for boot options\n\n" % \ |
1797 |
|
(butil.getProductName(),)) |
1798 |
|
f.close() |
1799 |
|
os.chmod(instRoot + mf, 0600) |
1800 |
|
|
1801 |
|
f = open(instRoot + cf, "w+") |
1802 |
|
f.write("# silo.conf generated by anaconda\n\n") |
1803 |
|
|
1804 |
|
f.write("#boot=%s\n" % (bootDev,)) |
1805 |
|
f.write("message=%s\n" % (mf,)) |
1806 |
|
f.write("timeout=50\n") |
1807 |
|
|
1808 |
|
(name, partNum) = getDiskPart(bootDev) |
1809 |
|
partno = partNum + 1 |
1810 |
|
f.write("partition=%s\n" % (partno,)) |
1811 |
|
|
1812 |
|
if self.password: |
1813 |
|
f.write("password=%s\n" % (self.password,)) |
1814 |
|
f.write("restricted\n") |
1815 |
|
|
1816 |
|
f.write("default=%s\n" % (kernelList[0][0],)) |
1817 |
|
f.write("\n") |
1818 |
|
|
1819 |
|
rootDev = fsset.getEntryByMountPoint("/").device.getDevice() |
1820 |
|
|
1821 |
|
for (label, longlabel, version) in kernelList: |
1822 |
|
kernelTag = "-" + version |
1823 |
|
kernelFile = "%s/vmlinuz%s" % (cfPath, kernelTag) |
1824 |
|
|
1825 |
|
f.write("image=%s\n" % (kernelFile,)) |
1826 |
|
f.write("\tlabel=%s\n" % (label,)) |
1827 |
|
f.write("\tread-only\n") |
1828 |
|
|
1829 |
|
initrd = booty.makeInitrd(kernelTag, instRoot) |
1830 |
|
if os.access(instRoot + initrd, os.R_OK): |
1831 |
|
f.write("\tinitrd=%s/initrd%s.img\n" % (cfPath, kernelTag)) |
1832 |
|
|
1833 |
|
append = "%s" % (self.args.get(),) |
1834 |
|
|
1835 |
|
realroot = getRootDevName(initrd, fsset, rootDev, instRoot) |
1836 |
|
if not realroot.startswith("LABEL="): |
1837 |
|
f.write("\troot=%s\n" % (realroot,)) |
1838 |
|
else: |
1839 |
|
if len(append) > 0: |
1840 |
|
append = "%s root=%s" % (append, realroot) |
1841 |
|
else: |
1842 |
|
append = "root=%s" % (realroot,) |
1843 |
|
|
1844 |
|
if len(append) > 0: |
1845 |
|
f.write("\tappend=\"%s\"\n" % (append,)) |
1846 |
|
f.write("\n") |
1847 |
|
|
1848 |
|
f.close() |
1849 |
|
os.chmod(instRoot + cf, 0600) |
1850 |
|
|
1851 |
|
# FIXME: hack to make sure things are written to disk |
1852 |
|
import isys |
1853 |
|
isys.sync() |
1854 |
|
isys.sync() |
1855 |
|
isys.sync() |
1856 |
|
|
1857 |
|
backup = "%s/backup.b" % (cfPath,) |
1858 |
|
sbinargs = ["/sbin/silo", "-f", "-C", cf, "-S", backup] |
1859 |
|
if butil.getSparcMachine() == "sun4u": |
1860 |
|
sbinargs += ["-u"] |
1861 |
|
else: |
1862 |
|
sbinargs += ["-U"] |
1863 |
|
|
1864 |
|
log("running: %s" % (sbinargs,)) |
1865 |
|
if not flags.test: |
1866 |
|
rhpl.executil.execWithRedirect(sbinargs[0], |
1867 |
|
sbinargs, |
1868 |
|
stdout = "/dev/tty5", |
1869 |
|
stderr = "/dev/tty5", |
1870 |
|
root = instRoot) |
1871 |
|
|
1872 |
|
if (not os.access(instRoot + "/etc/silo.conf", os.R_OK) and |
1873 |
|
os.access(instRoot + "/boot/etc/silo.conf", os.R_OK)): |
1874 |
|
os.symlink("../boot/etc/silo.conf", |
1875 |
|
instRoot + "/etc/silo.conf") |
1876 |
|
|
1877 |
|
return "" |
1878 |
|
|
1879 |
|
def setPassword(self, val, isCrypted = 1): |
1880 |
|
# silo just handles the password unencrypted |
1881 |
|
self.password = val |
1882 |
|
|
1883 |
|
def write(self, instRoot, fsset, bl, langs, kernelList, chainList, |
1884 |
|
defaultDev, justConfig, intf): |
1885 |
|
if len(kernelList) >= 1: |
1886 |
|
self.writeSilo(instRoot, fsset, bl, langs, kernelList, chainList, |
1887 |
|
defaultDev, justConfig) |
1888 |
|
else: |
1889 |
|
self.noKernelsWarn(intf) |
1890 |
|
|
1891 |
|
def __init__(self): |
1892 |
|
bootloaderInfo.__init__(self) |
1893 |
|
self.useSiloVal = 1 |
1894 |
|
self.kernelLocation = "/boot" |
1895 |
|
self.configfile = "/etc/silo.conf" |
1896 |
|
|
1897 |
############### |
############### |
1898 |
# end of boot loader objects... these are just some utility functions used |
# end of boot loader objects... these are just some utility functions used |