dpolovinkin / rpms / anaconda

Forked from rpms/anaconda 3 years ago
Clone
Blob Blame History Raw
From 5dccbe00aa1b160cd35e5e17fc1121e3e3f4f203 Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Thu, 15 May 2014 07:44:18 -0400
Subject: [PATCH 12/20] rpmostreepayload: Use systemd-tmpfiles rather than
 handrolling mkdir

I hit an issue where something in Anaconda may invoke a program or
library which uses rpm, and because the OSTree model has /var/lib/rpm
-> /usr/share/rpm, but that's created during boot, I'd end up with a
new empty rpmdb in /var/lib.

Fix this by switching to running systemd-tmpfiles on the target root
*only* for the directories we'll need at install time.  For example,
we don't need /var/spool/abrt until the target is running, so don't
try to create it.

Resolves: rhbz#1113535
Port of rpmostreepayload patches from master
commit a5f48d26312bfde6800d8bb608c5f08186c8eed1
---
 pyanaconda/packaging/rpmostreepayload.py | 33 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 20 deletions(-)

diff --git a/pyanaconda/packaging/rpmostreepayload.py b/pyanaconda/packaging/rpmostreepayload.py
index d5f7a23..0210017 100644
--- a/pyanaconda/packaging/rpmostreepayload.py
+++ b/pyanaconda/packaging/rpmostreepayload.py
@@ -147,26 +147,6 @@ class RPMOSTreePayload(ArchivePayload):
         deployment_path = sysroot.get_deployment_directory(deployment)
         iutil.setSysroot(deployment_path.get_path())
 
-        varroot = iutil.getTargetPhysicalRoot() + '/ostree/deploy/' + ostreesetup.osname + '/var'
-
-        # This is a bit of a hack; we precreate the targets of
-        # possible mounts of legacy paths like /home and /opt so the
-        # installer/%post scripts can find them.  In particular,
-        # Anaconda itself writes to /root/anaconda-ks.cfg.  What we
-        # really should do is export this data in some way the
-        # installer can read reliably.  Right now it's just encoded in
-        # systemd-tmpfiles.
-        for (dname, mode) in [('root', 0700), ('home', 0755),
-                              ('opt', 0755), ('srv', 0755),
-                              ('media', 0755), ('mnt', 0755)]:
-            linksrc = iutil.getSysroot() + '/' + dname
-            if os.path.islink(linksrc) and not os.path.isdir(linksrc):
-                linkdata = os.readlink(linksrc)
-                if linkdata.startswith('var/'):
-                    linkdest = varroot + '/' + linkdata[4:]
-                    log.info("Creating %s" % linkdest)
-                    os.mkdir(linkdest, mode)
-
         # Copy specific bootloader data files from the deployment
         # checkout to the target root.  See
         # https://bugzilla.gnome.org/show_bug.cgi?id=726757 This
@@ -204,6 +184,19 @@ class RPMOSTreePayload(ArchivePayload):
                 self._safeExecWithRedirect("mount",
                                            ["--bind", "-o", "ro", src, src])
 
+        # Now, ensure that all other potential mount point directories such as
+        # (/home) are created.  We run through the full tmpfiles here in order
+        # to also allow Anaconda and %post scripts to write to directories like
+        # /root.  We don't iterate *all* tmpfiles because we don't have the
+        # matching NSS configuration inside Anaconda, and we can't "chroot" to
+        # get it because that would require mounting the API filesystems in the
+        # target.
+        for varsubdir in ('home', 'roothome', 'lib/rpm', 'opt', 'srv',
+                          'usrlocal', 'mnt', 'media'):
+            self._safeExecWithRedirect("systemd-tmpfiles",
+                                       ["--create", "--boot", "--root=" + iutil.getSysroot(),
+                                        "--prefix=/var/" + varsubdir])
+
     def postInstall(self):
         super(RPMOSTreePayload, self).postInstall()
 
-- 
1.9.3