From fdc3f657e65c4f487d8d1f2e652b102ad06684f6 Mon Sep 17 00:00:00 2001 From: David Abdurachmanov Date: Nov 15 2018 07:22:36 +0000 Subject: [PATCH 1/2] Don't write /boot/grub/grub.conf if bootloader is disabled If user explicitly disabled bootloader then we don't need to write /boot/grub/grub.conf. The bootloader is external to disk image (i.e. built outside of distribution) Note: - --location=none simply disables bootloader installation - --disabled disables bootloader installation and also disables installation of the bootloader package We check for both being present, but we could probably relax it to just --disabled. Signed-off-by: David Abdurachmanov --- diff --git a/appcreate/appliance.py b/appcreate/appliance.py index 812fbd9..42a3164 100644 --- a/appcreate/appliance.py +++ b/appcreate/appliance.py @@ -520,9 +520,12 @@ class ApplianceImageCreator(ImageCreator): def _create_bootconfig(self): logging.debug("Writing kickstart file.") self._write_kickstart() - # For EC2 lets always make a grub Legacy config file - logging.debug("Writing GRUB Legacy config.") - self._create_grub_config() + # For EC2 lets make a grub Legacy config file + # (only if bootloader is enabled) + if ((hasattr(self.ks.handler.bootloader, "disabled") and self.ks.handler.bootloader.disabled is False) and + (hasattr(self.ks.handler.bootloader, "location") and self.ks.handler.bootloader.location != "none")): + logging.debug("Writing GRUB Legacy config.") + self._create_grub_config() if self.bootloader == 'grub2': # We have GRUB2 package installed From 8367ab57338a7a2ad703222fd9c002edb667536f Mon Sep 17 00:00:00 2001 From: David Abdurachmanov Date: Nov 15 2018 07:26:42 +0000 Subject: [PATCH 2/2] Respect clearpart --disklabel from user if bootloader is disabled User could disable bootloader (i.e. not part of distribution itself), but still would like to select partition layout. The patch respects user provided --disklabel (parition layout) if bootloader is disabled. Signed-off-by: David Abdurachmanov --- diff --git a/appcreate/appliance.py b/appcreate/appliance.py index 42a3164..c6706cb 100644 --- a/appcreate/appliance.py +++ b/appcreate/appliance.py @@ -169,22 +169,30 @@ class ApplianceImageCreator(ImageCreator): packages = kickstart.get_packages(self.ks) # make this the default partition_layout = 'msdos' - # check for extlinux in kickstart then grub2 and falling back to grub - if hasattr(self.ks.handler.bootloader, "extlinux"): - if 'syslinux-extlinux' in packages: - self.bootloader = 'extlinux' - elif 'extlinux-bootloader' in packages: - self.bootloader = 'extlinux-bootloader' + # set bootloader only if it is enabled and use user specified partition_layout + if ((not hasattr(self.ks.handler.bootloader, "disabled")) or + (hasattr(self.ks.handler.bootloader, "disabled") and self.ks.handler.bootloader.disabled is False)): + # check for extlinux in kickstart then grub2 and falling back to grub + if hasattr(self.ks.handler.bootloader, "extlinux"): + if 'syslinux-extlinux' in packages: + self.bootloader = 'extlinux' + elif 'extlinux-bootloader' in packages: + self.bootloader = 'extlinux-bootloader' + else: + logging.warning("WARNING! syslinux-extlinux package not found.") else: - logging.warning("WARNING! syslinux-extlinux package not found.") + if 'grub2' in packages: + self.bootloader = 'grub2' + partition_layout = 'gpt' + elif 'grub' in packages: + self.bootloader = 'grub' + else: + logging.warning("WARNING! grub package not found.") else: - if 'grub2' in packages: - self.bootloader = 'grub2' - partition_layout = 'gpt' - elif 'grub' in packages: - self.bootloader = 'grub' - else: - logging.warning("WARNING! grub package not found.") + # user explicitly disabled bootloader (i.e. not part of disk image) + if hasattr(self.ks.handler.clearpart, "disklabel"): + logging.debug("Using user set default disk label: {}".format(self.ks.handler.clearpart.disklabel)) + partition_layout = self.ks.handler.clearpart.disklabel self.__instloop = PartitionedMount(self.__disks, self._instroot,