[PATCH] Write the grub config even on errors (#1114774)
Brian C. Lane
bcl at redhat.com
Thu Jul 10 22:19:40 UTC 2014
It can be useful for advanced users to have the config file written even
if bootloader installation failed. This puts the configuration write
into a finally block so that it will be written even when there is
an error.
---
pyanaconda/bootloader.py | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index eb8bede..509796e 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -1604,15 +1604,17 @@ class GRUB2(GRUB):
self.update()
return
- self.write_device_map()
- self.stage2_device.format.sync(root=iutil.getTargetPhysicalRoot())
- sync()
- self.install()
- sync()
- self.stage2_device.format.sync(root=iutil.getTargetPhysicalRoot())
- self.write_config()
- sync()
- self.stage2_device.format.sync(root=iutil.getTargetPhysicalRoot())
+ try:
+ self.write_device_map()
+ self.stage2_device.format.sync(root=iutil.getTargetPhysicalRoot())
+ sync()
+ self.install()
+ sync()
+ self.stage2_device.format.sync(root=iutil.getTargetPhysicalRoot())
+ finally:
+ self.write_config()
+ sync()
+ self.stage2_device.format.sync(root=iutil.getTargetPhysicalRoot())
def check(self):
""" When installing to the mbr of a disk grub2 needs enough space
@@ -1752,10 +1754,12 @@ class EFIGRUB(GRUB2):
self.update()
return
- sync()
- self.stage2_device.format.sync(root=iutil.getTargetPhysicalRoot())
- self.install()
- self.write_config()
+ try:
+ sync()
+ self.stage2_device.format.sync(root=iutil.getTargetPhysicalRoot())
+ self.install()
+ finally:
+ self.write_config()
def check(self):
return True
--
1.9.3
More information about the anaconda-patches
mailing list