[PATCH] Write the grub config even on errors (#1114774)
Vratislav Podzimek
vpodzime at redhat.com
Mon Jul 14 08:03:56 UTC 2014
On Thu, 2014-07-10 at 15:19 -0700, Brian C. Lane wrote:
> 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
Nice, ACK.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list