+ def _mount_wrapper(self, rootdir):
+ if 'freebsd' in os.sys.platform:
+ self.runcmd(['mount', 'dev', '-t', 'devfs',
+ '%s' % os.path.join(rootdir, 'dev')])
+ self.runcmd(['mount', 'proc', '-t', 'linprocfs',
+ '%s' % os.path.join(rootdir, 'proc')])
+ self.runcmd(['mount', 'sys', '-t', 'linsysfs',
+ '%s' % os.path.join(rootdir, 'sys')])
+ else:
+ self.runcmd(['mount', '/dev', '-t', 'devfs', '-obind',
+ '%s' % os.path.join(rootdir, 'dev')])
+ self.runcmd(['mount', '/proc', '-t', 'proc', '-obind',
+ '%s' % os.path.join(rootdir, 'proc')])
+ self.runcmd(['mount', '/sys', '-t', 'sysfs', '-obind',
+ '%s' % os.path.join(rootdir, 'sys')])
+
+ def _umount_wrapper(self, rootdir):
+ self.runcmd(['umount', os.path.join(rootdir, 'sys')])
+ self.runcmd(['umount', os.path.join(rootdir, 'proc')])
+ self.runcmd(['umount', os.path.join(rootdir, 'dev')])
+
+ def install_grub_uefi(self, rootdir):
+ self.message("Configuring grub-uefi")
+ target = self.efi_arch_table[self.settings['arch']]['target']
+ grub_opts = "--target=%s" % target
+ logging.debug("Running grub-install with options: %s", grub_opts)
+ self._mount_wrapper(rootdir)
+ try:
+ self.runcmd(['chroot', rootdir, 'update-grub'])
+ self.runcmd(['chroot', rootdir, 'grub-install', grub_opts])
+ except cliapp.AppException as exc:
+ logging.warning(exc)
+ self.message(
+ "Failed to configure grub-uefi for %s" %
+ self.settings['arch'])
+ self._umount_wrapper(rootdir)
+ self.configure_efi()
+ extra = str(self.efi_arch_table[self.settings['arch']]['extra'])
+ if extra:
+ target = self.efi_arch_table[extra]['target']
+ grub_opts = "--target=%s" % target
+ try:
+ self.runcmd(['chroot', rootdir, 'update-grub'])
+ self.runcmd(['chroot', rootdir, 'grub-install', grub_opts])
+ except cliapp.AppException as exc:
+ logging.warning(exc)
+ self.message(
+ "Failed to configure grub-uefi for %s" % extra)
+ self.configure_extra_efi()
+ self._umount_wrapper(rootdir)
+