summaryrefslogtreecommitdiffstats
path: root/booty
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2009-06-05 10:59:29 -0400
committerChris Lumens <clumens@redhat.com>2009-06-05 16:12:33 -0400
commit34ed3c31021d7139de8f0e84215a46769abdb992 (patch)
tree0eac7ad7090a6a7d506f8c5595603fd2bb780b29 /booty
parent5247763ce8b9d61aed0f9cec552d69bff7829a95 (diff)
downloadanaconda-34ed3c31021d7139de8f0e84215a46769abdb992.tar.gz
anaconda-34ed3c31021d7139de8f0e84215a46769abdb992.tar.xz
anaconda-34ed3c31021d7139de8f0e84215a46769abdb992.zip
Catch errors from bootloader installation and tell the user (#502210).
Diffstat (limited to 'booty')
-rw-r--r--booty/alpha.py26
-rw-r--r--booty/bootloaderInfo.py37
-rw-r--r--booty/ia64.py18
-rw-r--r--booty/ppc.py28
-rw-r--r--booty/s390.py25
-rw-r--r--booty/sparc.py18
-rw-r--r--booty/x86.py61
7 files changed, 128 insertions, 85 deletions
diff --git a/booty/alpha.py b/booty/alpha.py
index efe4446fd..33cef8234 100644
--- a/booty/alpha.py
+++ b/booty/alpha.py
@@ -111,10 +111,12 @@ class alphaBootloaderInfo(bootloaderInfo):
# to and the second argument is a path to the bootstrap loader
# file.
args = [("/dev/%s" % wbd), "/boot/bootlx"]
- iutil.execWithRedirect ('/sbin/swriteboot', args,
- root = instRoot,
- stdout = "/dev/tty5",
- stderr = "/dev/tty5")
+ rc = iutil.execWithRedirect ('/sbin/swriteboot', args,
+ root = instRoot,
+ stdout = "/dev/tty5",
+ stderr = "/dev/tty5")
+ if rc:
+ return rc
# Calling abootconf to configure the installed aboot. The
# first argument is the disk to use, the second argument is
@@ -122,10 +124,14 @@ class alphaBootloaderInfo(bootloaderInfo):
# It's always the boot partition whether it's / or /boot (with
# the mount point being omitted.)
args = [("/dev/%s" % wbd), str (bdpn)]
- iutil.execWithRedirect ('/sbin/abootconf', args,
- root = instRoot,
- stdout = "/dev/tty5",
- stderr = "/dev/tty5")
+ rc = iutil.execWithRedirect ('/sbin/abootconf', args,
+ root = instRoot,
+ stdout = "/dev/tty5",
+ stderr = "/dev/tty5")
+ if rc:
+ return rc
+
+ return 0
def write(self, instRoot, bl, kernelList, chainList,
@@ -133,8 +139,8 @@ class alphaBootloaderInfo(bootloaderInfo):
if len(kernelList) < 1:
raise BootyNoKernelWarning
- self.writeAboot(instRoot, bl, kernelList,
- chainList, defaultDev, justConfig)
+ return self.writeAboot(instRoot, bl, kernelList,
+ chainList, defaultDev, justConfig)
def __init__(self, storage):
bootloaderInfo.__init__(self, storage)
diff --git a/booty/bootloaderInfo.py b/booty/bootloaderInfo.py
index a1a27b71c..8e09c5030 100644
--- a/booty/bootloaderInfo.py
+++ b/booty/bootloaderInfo.py
@@ -405,15 +405,17 @@ class bootloaderInfo:
def write(self, instRoot, bl, kernelList, chainList,
defaultDev, justConfig):
+ rc = 0
+
if len(kernelList) >= 1:
config = self.getBootloaderConfig(instRoot, bl,
kernelList, chainList,
defaultDev)
- config.write(instRoot + self.configfile, perms = self.perms)
+ rc = config.write(instRoot + self.configfile, perms = self.perms)
else:
raise booty.BootyNoKernelWarning
- return ""
+ return rc
def getArgList(self):
args = []
@@ -533,9 +535,11 @@ class efiBootloaderInfo(bootloaderInfo):
# XXX wouldn't it be nice to have a real interface to use efibootmgr from?
def removeOldEfiEntries(self, instRoot):
p = os.pipe()
- iutil.execWithRedirect('/usr/sbin/efibootmgr', [],
- root = instRoot, stdout = p[1])
+ rc = iutil.execWithRedirect('/usr/sbin/efibootmgr', [],
+ root = instRoot, stdout = p[1])
os.close(p[1])
+ if rc:
+ return rc
c = os.read(p[0], 1)
buf = c
@@ -550,10 +554,14 @@ class efiBootloaderInfo(bootloaderInfo):
continue
if string.join(fields[1:], " ") == productName:
entry = fields[0][4:8]
- iutil.execWithRedirect('/usr/sbin/efibootmgr',
- ["-b", entry, "-B"],
- root = instRoot,
- stdout="/dev/tty5", stderr="/dev/tty5")
+ rc = iutil.execWithRedirect('/usr/sbin/efibootmgr',
+ ["-b", entry, "-B"],
+ root = instRoot,
+ stdout="/dev/tty5", stderr="/dev/tty5")
+ if rc:
+ return rc
+
+ return 0
def addNewEfiEntry(self, instRoot):
try:
@@ -581,16 +589,19 @@ class efiBootloaderInfo(bootloaderInfo):
argv = [ "/usr/sbin/efibootmgr", "-c" , "-w", "-L",
productName, "-d", "/dev/%s" % bootdisk,
"-p", bootpart, "-l", "\\EFI\\redhat\\" + self.bootloader ]
- iutil.execWithRedirect(argv[0], argv[1:], root = instRoot,
- stdout = "/dev/tty5",
- stderr = "/dev/tty5")
+ rc = iutil.execWithRedirect(argv[0], argv[1:], root = instRoot,
+ stdout = "/dev/tty5",
+ stderr = "/dev/tty5")
+ return rc
def installGrub(self, instRoot, bootDevs, grubTarget, grubPath,
target, cfPath):
if not iutil.isEfi():
raise EnvironmentError
- self.removeOldEfiEntries(instRoot)
- self.addNewEfiEntry(instRoot)
+ rc = self.removeOldEfiEntries(instRoot)
+ if rc:
+ return rc
+ return self.addNewEfiEntry(instRoot)
def __init__(self, storage, initialize = True):
if initialize:
diff --git a/booty/ia64.py b/booty/ia64.py
index b9646d3a5..6c9cdc232 100644
--- a/booty/ia64.py
+++ b/booty/ia64.py
@@ -11,25 +11,27 @@ class ia64BootloaderInfo(efiBootloaderInfo):
config.addEntry("relocatable")
return config
-
+
def writeLilo(self, instRoot, bl, kernelList,
chainList, defaultDev, justConfig):
config = self.getBootloaderConfig(instRoot, bl,
kernelList, chainList, defaultDev)
- config.write(instRoot + self.configfile, perms = 0755)
+ return config.write(instRoot + self.configfile, perms = 0755)
- return ""
-
def write(self, instRoot, bl, kernelList, chainList,
defaultDev, justConfig):
if len(kernelList) >= 1:
- out = self.writeLilo(instRoot, bl, kernelList,
- chainList, defaultDev, justConfig)
+ rc = self.writeLilo(instRoot, bl, kernelList,
+ chainList, defaultDev, justConfig)
+ if rc:
+ return rc
else:
raise BootyNoKernelWarning
- self.removeOldEfiEntries(instRoot)
- self.addNewEfiEntry(instRoot)
+ rc = self.removeOldEfiEntries(instRoot)
+ if rc:
+ return rc
+ return self.addNewEfiEntry(instRoot)
def makeInitrd(self, kernelTag):
return "/boot/efi/EFI/redhat/initrd%s.img" % kernelTag
diff --git a/booty/ppc.py b/booty/ppc.py
index 4633f079d..8cd427532 100644
--- a/booty/ppc.py
+++ b/booty/ppc.py
@@ -141,34 +141,40 @@ class ppcBootloaderInfo(bootloaderInfo):
isys.sync()
ybinargs = [ yabootProg, "-f", "-C", cf ]
-
+
if not flags.test:
- iutil.execWithRedirect(ybinargs[0],
- ybinargs[1:],
- stdout = "/dev/tty5",
- stderr = "/dev/tty5",
- root = instRoot)
+ rc = iutil.execWithRedirect(ybinargs[0],
+ ybinargs[1:],
+ stdout = "/dev/tty5",
+ stderr = "/dev/tty5",
+ root = instRoot)
+ if rc:
+ return rc
if (not os.access(instRoot + "/etc/yaboot.conf", os.R_OK) and
os.access(instRoot + "/boot/etc/yaboot.conf", os.R_OK)):
os.symlink("../boot/etc/yaboot.conf",
instRoot + "/etc/yaboot.conf")
-
- return ""
+
+ return 0
def setPassword(self, val, isCrypted = 1):
# yaboot just handles the password and doesn't care if its crypted
# or not
self.password = val
-
+
def write(self, instRoot, bl, kernelList, chainList,
defaultDev, justConfig):
if len(kernelList) >= 1:
- out = self.writeYaboot(instRoot, bl, kernelList,
- chainList, defaultDev, justConfig)
+ rc = self.writeYaboot(instRoot, bl, kernelList,
+ chainList, defaultDev, justConfig)
+ if rc:
+ return rc
else:
raise BootyNoKernelWarning
+ return 0
+
def __init__(self, storage):
bootloaderInfo.__init__(self, storage)
self.useYabootVal = 1
diff --git a/booty/s390.py b/booty/s390.py
index 717f50ffa..9b6260054 100644
--- a/booty/s390.py
+++ b/booty/s390.py
@@ -153,19 +153,24 @@ class s390BootloaderInfo(bootloaderInfo):
f.close()
if not justConfigFile:
- iutil.execWithRedirect("/sbin/zipl", [], root = instRoot,
- stdout = "/dev/stdout",
- stderr = "/dev/stderr")
-
- return ""
+ rc = iutil.execWithRedirect("/sbin/zipl", [], root = instRoot,
+ stdout = "/dev/stdout",
+ stderr = "/dev/stderr")
+ if rc:
+ return rc
+
+ return 0
def write(self, instRoot, bl, kernelList, chainList,
defaultDev, justConfig):
- out = self.writeZipl(instRoot, bl, kernelList,
- chainList, defaultDev,
- justConfig | (not self.useZiplVal))
- out = self.writeChandevConf(bl, instRoot)
-
+ rc = self.writeZipl(instRoot, bl, kernelList,
+ chainList, defaultDev,
+ justConfig | (not self.useZiplVal))
+ if rc:
+ return rc
+
+ return self.writeChandevConf(bl, instRoot)
+
def __init__(self, storage):
bootloaderInfo.__init__(self, storage)
self.useZiplVal = 1 # only used on s390
diff --git a/booty/sparc.py b/booty/sparc.py
index 39b84f167..b12b20769 100644
--- a/booty/sparc.py
+++ b/booty/sparc.py
@@ -94,18 +94,20 @@ class sparcBootloaderInfo(bootloaderInfo):
sbinargs += ["-U"]
if not flags.test:
- iutil.execWithRedirect(sbinargs[0],
- sbinargs[1:],
- stdout = "/dev/tty5",
- stderr = "/dev/tty5",
- root = instRoot)
+ rc = iutil.execWithRedirect(sbinargs[0],
+ sbinargs[1:],
+ stdout = "/dev/tty5",
+ stderr = "/dev/tty5",
+ root = instRoot)
+ if rc:
+ return rc
if (not os.access(instRoot + "/etc/silo.conf", os.R_OK) and
os.access(instRoot + "/boot/etc/silo.conf", os.R_OK)):
os.symlink("../boot/etc/silo.conf",
instRoot + "/etc/silo.conf")
- return ""
+ return 0
def setPassword(self, val, isCrypted = 1):
# silo just handles the password unencrypted
@@ -114,8 +116,8 @@ class sparcBootloaderInfo(bootloaderInfo):
def write(self, instRoot, bl, kernelList, chainList,
defaultDev, justConfig):
if len(kernelList) >= 1:
- self.writeSilo(instRoot, bl, kernelList, chainList,
- defaultDev, justConfig)
+ return self.writeSilo(instRoot, bl, kernelList, chainList,
+ defaultDev, justConfig)
else:
raise BootyNoKernelWarning
diff --git a/booty/x86.py b/booty/x86.py
index 5d52c3115..8ba5d23e8 100644
--- a/booty/x86.py
+++ b/booty/x86.py
@@ -67,10 +67,12 @@ class x86BootloaderInfo(efiBootloaderInfo):
syncDataToDisk(bootDev, "/", instRoot)
# copy the stage files over into /boot
- iutil.execWithRedirect("/sbin/grub-install",
- ["--just-copy"],
- stdout = "/dev/tty5", stderr = "/dev/tty5",
- root = instRoot)
+ rc = iutil.execWithRedirect("/sbin/grub-install",
+ ["--just-copy"],
+ stdout = "/dev/tty5", stderr = "/dev/tty5",
+ root = instRoot)
+ if rc:
+ return rc
# really install the bootloader
for cmd in cmds:
@@ -85,20 +87,22 @@ class x86BootloaderInfo(efiBootloaderInfo):
else:
syncDataToDisk(bootDev, "/", instRoot)
- iutil.execWithRedirect('/sbin/grub' ,
- [ "--batch", "--no-floppy",
- "--device-map=/boot/grub/device.map" ],
- stdin = p[0],
- stdout = "/dev/tty5", stderr = "/dev/tty5",
- root = instRoot)
+ rc = iutil.execWithRedirect('/sbin/grub' ,
+ [ "--batch", "--no-floppy",
+ "--device-map=/boot/grub/device.map" ],
+ stdin = p[0],
+ stdout = "/dev/tty5", stderr = "/dev/tty5",
+ root = instRoot)
os.close(p[0])
+ if rc:
+ return rc
+
def installGrub(self, instRoot, bootDevs, grubTarget, grubPath,
target, cfPath):
if iutil.isEfi():
- efiBootloaderInfo.installGrub(self, instRoot, bootDevs, grubTarget,
- grubPath, target, cfPath)
- return
+ return efiBootloaderInfo.installGrub(self, instRoot, bootDevs, grubTarget,
+ grubPath, target, cfPath)
args = "--stage2=/boot/grub/stage2 "
@@ -117,7 +121,11 @@ class x86BootloaderInfo(efiBootloaderInfo):
(args, grubPath, stage1Target, grubPath, bPart, grubPath)
cmds.append(cmd)
- self.runGrubInstall(instRoot, bootDev, cmds, cfPath)
+ rc = self.runGrubInstall(instRoot, bootDev, cmds, cfPath)
+ if rc:
+ return rc
+
+ return 0
def writeGrub(self, instRoot, bl, kernelList, chainList,
defaultDev, justConfigFile):
@@ -344,10 +352,10 @@ class x86BootloaderInfo(efiBootloaderInfo):
f.close()
if not justConfigFile:
- self.installGrub(instRoot, bootDevs, grubTarget, grubPath, \
- target, cfPath)
+ return self.installGrub(instRoot, bootDevs, grubTarget, grubPath,
+ target, cfPath)
- return ""
+ return 0
def getMatchingPart(self, bootDev, target):
bootName, bootPartNum = getDiskPart(bootDev, self.storage)
@@ -488,9 +496,9 @@ class x86BootloaderInfo(efiBootloaderInfo):
cmds.append(cmd)
if not justConfigFile:
- self.runGrubInstall(instRoot, bootDev, cmds, cfPath)
+ return self.runGrubInstall(instRoot, bootDev, cmds, cfPath)
- return ""
+ return 0
def writeSysconfig(self, instRoot, installDev):
sysconf = '/etc/sysconfig/grub'
@@ -508,16 +516,18 @@ class x86BootloaderInfo(efiBootloaderInfo):
# XXX HACK ALERT - see declaration above
if self.doUpgradeOnly:
if self.useGrubVal:
- self.upgradeGrub(instRoot, bl, kernelList,
- chainList, defaultDev, justConfig)
- return
+ return self.upgradeGrub(instRoot, bl, kernelList,
+ chainList, defaultDev, justConfig)
+ return 0
if len(kernelList) < 1:
raise BootyNoKernelWarning
- out = self.writeGrub(instRoot, bl, kernelList,
- chainList, defaultDev,
- justConfig | (not self.useGrubVal))
+ rc = self.writeGrub(instRoot, bl, kernelList,
+ chainList, defaultDev,
+ justConfig | (not self.useGrubVal))
+ if rc:
+ return rc
# XXX move the lilo.conf out of the way if they're using GRUB
# so that /sbin/installkernel does a more correct thing
@@ -525,6 +535,7 @@ class x86BootloaderInfo(efiBootloaderInfo):
os.rename(instRoot + "/etc/lilo.conf",
instRoot + "/etc/lilo.conf.anaconda")
+ return 0
def getArgList(self):
args = bootloaderInfo.getArgList(self)