summaryrefslogtreecommitdiff
path: root/vmdebootstrap/grub.py
diff options
context:
space:
mode:
authorNeil Williams <codehelp@debian.org>2015-08-17 13:16:35 +0200
committerNeil Williams <codehelp@debian.org>2015-08-18 11:12:41 +0200
commitbc7ef0f9a3df88424ab594fe13a4322b408f6718 (patch)
treedf2f1f0a7b8fe661a083e059eb923e8a280080bd /vmdebootstrap/grub.py
parent54212e6812319e288a9ecd1a4d032b23ea9ae4ea (diff)
downloadvmdebootstrap-bc7ef0f9a3df88424ab594fe13a4322b408f6718.tar.gz
check that the ESP is mounted before trying to configure
Diffstat (limited to 'vmdebootstrap/grub.py')
-rw-r--r--vmdebootstrap/grub.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/vmdebootstrap/grub.py b/vmdebootstrap/grub.py
index e348a53..909c2d1 100644
--- a/vmdebootstrap/grub.py
+++ b/vmdebootstrap/grub.py
@@ -75,6 +75,7 @@ class GrubHandler(Base):
return True
def install_grub_uefi(self, rootdir):
+ ret = True
self.message("Configuring grub-uefi")
target = arch_table[self.settings['arch']]['target']
grub_opts = "--target=%s" % target
@@ -85,22 +86,33 @@ class GrubHandler(Base):
runcmd(['chroot', rootdir, 'grub-install', grub_opts])
except cliapp.AppException as exc:
logging.warning(exc)
+ ret = False
self.message(
"Failed to configure grub-uefi for %s" %
self.settings['arch'])
- umount_wrapper(rootdir)
+ finally:
+ umount_wrapper(rootdir)
+ if not ret:
+ raise cliapp.AppException("Failed to install grub uefi")
def install_extra_grub_uefi(self, rootdir):
- extra = str(arch_table[self.settings['arch']]['extra'])
+ ret = True
+ extra = arch_table[self.settings['arch']]['extra']
if extra:
+ logging.debug("Installing extra grub support for %s", extra)
mount_wrapper(rootdir)
target = arch_table[extra]['target']
grub_opts = "--target=%s" % target
+ self.message("Adding grub target %s" % grub_opts)
try:
runcmd(['chroot', rootdir, 'update-grub'])
runcmd(['chroot', rootdir, 'grub-install', grub_opts])
except cliapp.AppException as exc:
logging.warning(exc)
+ ret = False
self.message(
"Failed to configure grub-uefi for %s" % extra)
- umount_wrapper(rootdir)
+ finally:
+ umount_wrapper(rootdir)
+ if not ret:
+ raise cliapp.AppException("Failed to install extra grub uefi")