[PATCH] Handle the case of rpmostreepayload + GRUB2

Colin Walters walters at verbum.org
Thu Oct 16 02:23:11 UTC 2014


Note: I didn't actually test this on rawhide, I wrote it on master and
backported
it to rhel7-branch and tested there due to not having a rawhide dev env
handy.
If someone does, testing it will be a pain as you'll also need the newer
rpm-ostree patch, and to compose a new tree with it and the ostree
patch, etc.

>From cc8aaa04f9e78916efd4b0cc2dae5507e176f591 Mon Sep 17 00:00:00 2001
From: Colin Walters <walters at verbum.org>
Date: Mon, 13 Oct 2014 21:01:23 -0400
Subject: [PATCH] Handle the case of rpmostreepayload + GRUB2

NOTE: Incompatible change for trees constructed prior to
NOTE: https://github.com/projectatomic/rpm-ostree/pull/35

For rpmostreepayload (in contrast to yum mainline) is that 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).

However, the handling of /boot in OSTree was a bit broken, and trying
to support GRUB2 forced this change, because we need to ultimately
execute grub2-mkconfig in the chroot and we need both the *real* /boot
as well as the new /usr/lib/ostree-boot.

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 | 22 ++++++++++++++++++----
 3 files changed, 23 insertions(+), 25 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..8d3ff42 100644
--- a/pyanaconda/packaging/rpmostreepayload.py
+++ b/pyanaconda/packaging/rpmostreepayload.py
@@ -219,7 +219,8 @@ class RPMOSTreePayload(ArchivePayload):
     def postInstall(self):
         super(RPMOSTreePayload, self).postInstall()
 
-        physboot = iutil.getTargetPhysicalRoot() + '/boot'
+        # not actually "phys" anymore, not changed to avoid diff spam
+        physboot = iutil.getSysroot() + '/boot'
 
         # If we're using extlinux, rename extlinux.conf to
         # syslinux.cfg, since that's what OSTree knows about.
@@ -240,11 +241,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



More information about the anaconda-patches mailing list