From 105a993bb26bcc6210c04f178641f6a64132353d Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 13 Oct 2014 21:01:23 -0400 Subject: [PATCH] Handle the case of rpmostreepayload + GRUB2 For rpmostreepayload, Anaconda lays down the bootloader data and computes the kernel arguments, but ostree takes care of writing the configuration file (as it does on upgrades as well). We switch to keeping /boot in the target root, and call ostree from there. This should still work for extlinux because we're just rewriting a config file. For moving the GRUB2 config file, see a similar change for rpmostreepayload+extlinux in commit: 627486c22cdaf6c07009026791f5bd6fc1aaadaa Note: This commit is only useful on BIOS systems as of yet. --- pyanaconda/bootloader.py | 9 +++++---- pyanaconda/install.py | 17 ----------------- pyanaconda/packaging/rpmostreepayload.py | 19 ++++++++++++++++--- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py index b021067..8cdbd2f 100644 --- a/pyanaconda/bootloader.py +++ b/pyanaconda/bootloader.py @@ -1547,10 +1547,11 @@ class GRUB2(GRUB): log.error("boot loader password setup failed: %s", e) # make sure the default entry is the OS we are installing - entry_title = "0" - rc = iutil.execInSysroot("grub2-set-default", [entry_title]) - if rc: - log.error("failed to set default menu entry to %s", productName) + if self.default is not None: + entry_title = "0" + rc = iutil.execInSysroot("grub2-set-default", [entry_title]) + if rc: + log.error("failed to set default menu entry to %s", productName) # now tell grub2 to generate the main configuration file rc = iutil.execInSysroot("grub2-mkconfig", diff --git a/pyanaconda/install.py b/pyanaconda/install.py index 40ead97..94f4663 100644 --- a/pyanaconda/install.py +++ b/pyanaconda/install.py @@ -118,20 +118,6 @@ def doConfiguration(storage, payload, ksdata, instClass): progress_complete() -def moveBootMntToPhysical(storage): - """Move the /boot mount to /mnt/sysimage/boot.""" - if iutil.getSysroot() == iutil.getTargetPhysicalRoot(): - return - - mounts = [storage.mountpoints.get("/boot/efi"), storage.mountpoints.get("/boot")] - for mnt in mounts: - if mnt is None: - return - - mnt.format.teardown() - mnt.teardown() - mnt.format.setup(options=mnt.format.options, chroot=iutil.getTargetPhysicalRoot()) - def doInstall(storage, payload, ksdata, instClass): """Perform an installation. This method takes the ksdata as prepared by the UI (the first hub, in graphical mode) and applies it to the disk. @@ -266,9 +252,6 @@ def doInstall(storage, payload, ksdata, instClass): writeBootLoader(storage, payload, instClass, ksdata) with progress_report(_("Performing post-installation setup tasks")): - # Now, let's reset the state here so that the payload has - # /boot in the system root. - moveBootMntToPhysical(storage) payload.postInstall() progress_complete() diff --git a/pyanaconda/packaging/rpmostreepayload.py b/pyanaconda/packaging/rpmostreepayload.py index 70a4903..7cba64c 100644 --- a/pyanaconda/packaging/rpmostreepayload.py +++ b/pyanaconda/packaging/rpmostreepayload.py @@ -240,11 +240,24 @@ class RPMOSTreePayload(ArchivePayload): # And *also* tell syslinux that the config is really in /boot/loader os.symlink('loader/syslinux.cfg', physboot + '/syslinux.cfg') + # And if we're using GRUB2, move its config file, also with a + # compatibility symlink. + physboot_grub2 = physboot + '/grub2' + if os.path.isdir(physboot_grub2): + physboot_loader = physboot + '/loader' + assert os.path.isdir(physboot_loader) + orig_grub_cfg = physboot_grub2 + '/grub.cfg' + target_grub_cfg = physboot_loader + '/grub.cfg' + log.info("Moving %s -> %s", orig_grub_cfg, target_grub_cfg) + os.rename(orig_grub_cfg, target_grub_cfg) + os.symlink('../loader/grub.cfg', orig_grub_cfg) + # OSTree owns the bootloader configuration, so here we give it # the argument list we computed from storage, architecture and # such. - set_kargs_args = ["admin", "--sysroot=" + iutil.getTargetPhysicalRoot(), - "instutil", "set-kargs"] + set_kargs_args = ["admin", "instutil", "set-kargs"] set_kargs_args.extend(self.storage.bootloader.boot_args) set_kargs_args.append("root=" + self.storage.rootDevice.fstabSpec) - self._safeExecWithRedirect("ostree", set_kargs_args) + # Here we run ostree from the target system, because the bootloader + # code for GRUB2 needs to run grub2-mkconfig. + self._safeExecWithRedirect("ostree", set_kargs_args, root=iutil.getSysroot()) -- 1.8.3.1