neil / rpms / anaconda

Forked from rpms/anaconda a year ago
Clone
Blob Blame History Raw
From 9277b3b38557cbdb60abe06af93513ebcb0038c9 Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Mon, 13 Oct 2014 21:01:23 -0400
Subject: [PATCH 1/5] 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.

Conflicts:
	pyanaconda/bootloader.py
	pyanaconda/install.py
	pyanaconda/packaging/rpmostreepayload.py
---
 pyanaconda/bootloader.py                 | 11 ++++----
 pyanaconda/install.py                    | 14 ----------
 pyanaconda/packaging/rpmostreepayload.py | 48 +++++++++++++++-----------------
 3 files changed, 28 insertions(+), 45 deletions(-)

diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index 6c693db..29004b1 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -1551,11 +1551,12 @@ class GRUB2(GRUB):
             log.error("bootloader password setup failed: %s" % e)
 
         # make sure the default entry is the OS we are installing
-        entry_title = "%s Linux, with Linux %s" % (productName,
-                                                   self.default.version)
-        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 = "%s Linux, with Linux %s" % (productName,
+                                                       self.default.version)
+            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 959878b..8c90221 100644
--- a/pyanaconda/install.py
+++ b/pyanaconda/install.py
@@ -107,17 +107,6 @@ def doConfiguration(storage, payload, ksdata, instClass):
 
     progressQ.send_complete()
 
-def moveBootMntToPhysical(storage):
-    """Move the /boot mount to /mnt/sysimage/boot."""
-    if iutil.getSysroot() == iutil.getTargetPhysicalRoot():
-        return
-    bootmnt = storage.mountpoints.get('/boot')
-    if bootmnt is None:
-        return
-    bootmnt.format.teardown()
-    bootmnt.teardown()
-    bootmnt.format.setup(options=bootmnt.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.
@@ -215,9 +204,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()
 
     progressQ.send_complete()
diff --git a/pyanaconda/packaging/rpmostreepayload.py b/pyanaconda/packaging/rpmostreepayload.py
index 8be6d3b..dfb0466 100644
--- a/pyanaconda/packaging/rpmostreepayload.py
+++ b/pyanaconda/packaging/rpmostreepayload.py
@@ -222,40 +222,36 @@ class RPMOSTreePayload(ArchivePayload):
     def postInstall(self):
         super(RPMOSTreePayload, self).postInstall()
 
-        physboot = iutil.getTargetPhysicalRoot() + '/boot'
+        boot = iutil.getSysroot() + '/boot'
 
         # If we're using extlinux, rename extlinux.conf to
         # syslinux.cfg, since that's what OSTree knows about.
         # syslinux upstream supports both, but I'd say that upstream
         # using syslinux.cfg is somewhat preferred.
-        physboot_extlinux = physboot + '/extlinux'
-        if os.path.isdir(physboot_extlinux):
-            physboot_syslinux = physboot + '/syslinux'
-            physboot_loader = physboot + '/loader'
-            assert os.path.isdir(physboot_loader)
-            orig_extlinux_conf = physboot_extlinux + '/extlinux.conf'
-            target_syslinux_cfg = physboot_loader + '/syslinux.cfg'
-            log.info("Moving %s -> %s" % (orig_extlinux_conf, target_syslinux_cfg))
-            os.rename(orig_extlinux_conf, target_syslinux_cfg)
-            # A compatibility bit for OSTree
-            os.mkdir(physboot_syslinux)
-            os.symlink('../loader/syslinux.cfg', physboot_syslinux + '/syslinux.cfg')
-            # And *also* tell syslinux that the config is really in /boot/loader
-            os.symlink('loader/syslinux.cfg', physboot + '/syslinux.cfg')
+        boot_extlinux = boot + '/extlinux'
+        if os.path.isdir(boot_extlinux):
+            boot_syslinux = boot + '/syslinux'
+            boot_loader = boot + '/loader'
+            orig_extlinux_conf = boot_extlinux + '/extlinux.conf'
+            target_syslinux_cfg = boot_loader + '/syslinux.cfg'
+            log.info("Moving %s -> %s", orig_extlinux_conf, target_syslinux_cfg)
+            os.symlink('loader/syslinux.cfg', boot + '/syslinux.cfg')
+
+        # And if we're using GRUB2, move its config file, also with a
+        # compatibility symlink.
+        boot_grub2 = boot + '/grub2'
+        if os.path.isdir(boot_grub2):
+            boot_loader = boot + '/loader'
+            orig_grub_cfg = boot_grub2 + '/grub.cfg'
+            target_grub_cfg = boot_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)
-
-        # This command iterates over all files we might have created
-        # and ensures they're labeled. It's like running
-        # chroot(iutil.getTargetPhysicalRoot()) + fixfiles, except
-        # with a better name and semantics.
-        self._safeExecWithRedirect("ostree",
-            ["admin", "--sysroot=" + iutil.getTargetPhysicalRoot(),
-             "instutil", "selinux-ensure-labeled", iutil.getTargetPhysicalRoot(), ""])
+        self._safeExecWithRedirect("ostree", set_kargs_args, root=iutil.getSysroot())
-- 
1.8.3.1