diff options
author | Neil Williams <codehelp@debian.org> | 2015-08-17 13:16:35 +0200 |
---|---|---|
committer | Neil Williams <codehelp@debian.org> | 2015-08-18 11:12:41 +0200 |
commit | bc7ef0f9a3df88424ab594fe13a4322b408f6718 (patch) | |
tree | df2f1f0a7b8fe661a083e059eb923e8a280080bd /vmdebootstrap | |
parent | 54212e6812319e288a9ecd1a4d032b23ea9ae4ea (diff) | |
download | vmdebootstrap-bc7ef0f9a3df88424ab594fe13a4322b408f6718.tar.gz |
check that the ESP is mounted before trying to configure
Diffstat (limited to 'vmdebootstrap')
-rw-r--r-- | vmdebootstrap/grub.py | 18 | ||||
-rw-r--r-- | vmdebootstrap/uefi.py | 19 |
2 files changed, 27 insertions, 10 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") diff --git a/vmdebootstrap/uefi.py b/vmdebootstrap/uefi.py index 6f4b3bf..2a8bc2a 100644 --- a/vmdebootstrap/uefi.py +++ b/vmdebootstrap/uefi.py @@ -58,16 +58,16 @@ class Uefi(Base): def copy_efi_binary(self, efi_removable, efi_install): logging.debug("using bootdir=%s", self.bootdir) - logging.debug("moving %s to %s", efi_removable, efi_install) if efi_removable.startswith('/'): efi_removable = efi_removable[1:] if efi_install.startswith('/'): efi_install = efi_install[1:] efi_output = os.path.join(self.bootdir, efi_removable) efi_input = os.path.join(self.bootdir, efi_install) + logging.debug("moving %s to %s", efi_output, efi_input) if not os.path.exists(efi_input): logging.warning("%s does not exist (%s)", efi_input, efi_install) - raise cliapp.AppException("Missing %s" % efi_install) + raise cliapp.AppException("Missing %s" % efi_input) if not os.path.exists(os.path.dirname(efi_output)): os.makedirs(os.path.dirname(efi_output)) logging.debug( @@ -86,18 +86,23 @@ class Uefi(Base): efi_removable = str(arch_table[self.settings['arch']]['removable']) efi_install = str(arch_table[self.settings['arch']]['install']) self.message('Installing UEFI support binary') - self.copy_efi_binary(efi_removable, efi_install) - umount_wrapper(rootdir) + logging.debug("moving %s to %s", efi_removable, efi_install) + try: + self.copy_efi_binary(efi_removable, efi_install) + finally: + umount_wrapper(rootdir) def configure_extra_efi(self, rootdir): - extra = str(arch_table[self.settings['arch']]['extra']) + extra = arch_table[self.settings['arch']]['extra'] if extra: mount_wrapper(rootdir) efi_removable = str(arch_table[extra]['removable']) efi_install = str(arch_table[extra]['install']) self.message('Copying UEFI support binary for %s' % extra) - self.copy_efi_binary(efi_removable, efi_install) - umount_wrapper(rootdir) + try: + self.copy_efi_binary(efi_removable, efi_install) + finally: + umount_wrapper(rootdir) def partition_esp(self): espsize = self.settings['esp-size'] / (1024 * 1024) |