+ if self.settings['swap'] > 0:
+ swap = '/dev/mapper/%s' % devices[swapindex]
+ return root, boot, swap
+
+ def _efi_packages(self):
+ packages = []
+ pkg = self.efi_arch_table[self.settings['arch']]['package']
+ self.message("Adding %s" % pkg)
+ packages.append(pkg)
+ extra = self.efi_arch_table[self.settings['arch']]['extra']
+ if extra and isinstance(extra, str):
+ bin_pkg = self.efi_arch_table[str(extra)]['bin_package']
+ self.message("Adding support for %s using %s" % (extra, bin_pkg))
+ packages.append(bin_pkg)
+ return packages
+
+ 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)
+ 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)
+ if not os.path.exists(os.path.dirname(efi_output)):
+ os.makedirs(os.path.dirname(efi_output))
+ logging.debug(
+ 'Moving UEFI support: %s -> %s', efi_input, efi_output)
+ if os.path.exists(efi_output):
+ os.unlink(efi_output)
+ os.rename(efi_input, efi_output)
+
+ def configure_efi(self):
+ """
+ Copy the bootloader file from the package into the location
+ so needs to be after grub and kernel already installed.
+ """
+ self.message('Configuring EFI')
+ efi_removable = str(self.efi_arch_table[self.settings['arch']]['removable'])
+ efi_install = str(self.efi_arch_table[self.settings['arch']]['install'])
+ self.message('Installing UEFI support binary')
+ self._copy_efi_binary(efi_removable, efi_install)
+
+ def configure_extra_efi(self):
+ extra = str(self.efi_arch_table[self.settings['arch']]['extra'])
+ if extra:
+ efi_removable = str(self.efi_arch_table[extra]['removable'])
+ efi_install = str(self.efi_arch_table[extra]['install'])
+ self.message('Copying UEFI support binary for %s' % extra)
+ self._copy_efi_binary(efi_removable, efi_install)
+
+ def mkfs(self, device, fstype):
+ self.message('Creating filesystem %s' % fstype)
+ self.runcmd(['mkfs', '-t', fstype, device])
+
+ def suite_to_codename(self, distro):
+ suite = self.debian_info.codename(distro, datetime.date.today())
+ if not suite:
+ return distro
+ return suite
+
+ def was_oldstable(self, limit):
+ suite = self.suite_to_codename(self.settings['distribution'])
+ # this check is only for debian
+ if not self.debian_info.valid(suite):
+ return False
+ return suite == self.debian_info.old(limit)
+
+ def was_stable(self, limit):
+ suite = self.suite_to_codename(self.settings['distribution'])
+ # this check is only for debian
+ if not self.debian_info.valid(suite):
+ return False
+ return suite == self.debian_info.stable(limit)
+
+ def debootstrap(self, rootdir): # pylint: disable=too-many-statements
+ msg = "(%s)" % self.settings['variant'] if self.settings['variant'] else ''
+ self.message(
+ 'Debootstrapping %s [%s] %s' % (
+ self.settings['distribution'], self.settings['arch'], msg))