fbcaed
From 5dccbe00aa1b160cd35e5e17fc1121e3e3f4f203 Mon Sep 17 00:00:00 2001
fbcaed
From: Colin Walters <walters@verbum.org>
fbcaed
Date: Thu, 15 May 2014 07:44:18 -0400
fbcaed
Subject: [PATCH 12/20] rpmostreepayload: Use systemd-tmpfiles rather than
fbcaed
 handrolling mkdir
fbcaed
fbcaed
I hit an issue where something in Anaconda may invoke a program or
fbcaed
library which uses rpm, and because the OSTree model has /var/lib/rpm
fbcaed
-> /usr/share/rpm, but that's created during boot, I'd end up with a
fbcaed
new empty rpmdb in /var/lib.
fbcaed
fbcaed
Fix this by switching to running systemd-tmpfiles on the target root
fbcaed
*only* for the directories we'll need at install time.  For example,
fbcaed
we don't need /var/spool/abrt until the target is running, so don't
fbcaed
try to create it.
fbcaed
fbcaed
Resolves: rhbz#1113535
fbcaed
Port of rpmostreepayload patches from master
fbcaed
commit a5f48d26312bfde6800d8bb608c5f08186c8eed1
fbcaed
---
fbcaed
 pyanaconda/packaging/rpmostreepayload.py | 33 +++++++++++++-------------------
fbcaed
 1 file changed, 13 insertions(+), 20 deletions(-)
fbcaed
fbcaed
diff --git a/pyanaconda/packaging/rpmostreepayload.py b/pyanaconda/packaging/rpmostreepayload.py
fbcaed
index d5f7a23..0210017 100644
fbcaed
--- a/pyanaconda/packaging/rpmostreepayload.py
fbcaed
+++ b/pyanaconda/packaging/rpmostreepayload.py
fbcaed
@@ -147,26 +147,6 @@ class RPMOSTreePayload(ArchivePayload):
fbcaed
         deployment_path = sysroot.get_deployment_directory(deployment)
fbcaed
         iutil.setSysroot(deployment_path.get_path())
fbcaed
 
fbcaed
-        varroot = iutil.getTargetPhysicalRoot() + '/ostree/deploy/' + ostreesetup.osname + '/var'
fbcaed
-
fbcaed
-        # This is a bit of a hack; we precreate the targets of
fbcaed
-        # possible mounts of legacy paths like /home and /opt so the
fbcaed
-        # installer/%post scripts can find them.  In particular,
fbcaed
-        # Anaconda itself writes to /root/anaconda-ks.cfg.  What we
fbcaed
-        # really should do is export this data in some way the
fbcaed
-        # installer can read reliably.  Right now it's just encoded in
fbcaed
-        # systemd-tmpfiles.
fbcaed
-        for (dname, mode) in [('root', 0700), ('home', 0755),
fbcaed
-                              ('opt', 0755), ('srv', 0755),
fbcaed
-                              ('media', 0755), ('mnt', 0755)]:
fbcaed
-            linksrc = iutil.getSysroot() + '/' + dname
fbcaed
-            if os.path.islink(linksrc) and not os.path.isdir(linksrc):
fbcaed
-                linkdata = os.readlink(linksrc)
fbcaed
-                if linkdata.startswith('var/'):
fbcaed
-                    linkdest = varroot + '/' + linkdata[4:]
fbcaed
-                    log.info("Creating %s" % linkdest)
fbcaed
-                    os.mkdir(linkdest, mode)
fbcaed
-
fbcaed
         # Copy specific bootloader data files from the deployment
fbcaed
         # checkout to the target root.  See
fbcaed
         # https://bugzilla.gnome.org/show_bug.cgi?id=726757 This
fbcaed
@@ -204,6 +184,19 @@ class RPMOSTreePayload(ArchivePayload):
fbcaed
                 self._safeExecWithRedirect("mount",
fbcaed
                                            ["--bind", "-o", "ro", src, src])
fbcaed
 
fbcaed
+        # Now, ensure that all other potential mount point directories such as
fbcaed
+        # (/home) are created.  We run through the full tmpfiles here in order
fbcaed
+        # to also allow Anaconda and %post scripts to write to directories like
fbcaed
+        # /root.  We don't iterate *all* tmpfiles because we don't have the
fbcaed
+        # matching NSS configuration inside Anaconda, and we can't "chroot" to
fbcaed
+        # get it because that would require mounting the API filesystems in the
fbcaed
+        # target.
fbcaed
+        for varsubdir in ('home', 'roothome', 'lib/rpm', 'opt', 'srv',
fbcaed
+                          'usrlocal', 'mnt', 'media'):
fbcaed
+            self._safeExecWithRedirect("systemd-tmpfiles",
fbcaed
+                                       ["--create", "--boot", "--root=" + iutil.getSysroot(),
fbcaed
+                                        "--prefix=/var/" + varsubdir])
fbcaed
+
fbcaed
     def postInstall(self):
fbcaed
         super(RPMOSTreePayload, self).postInstall()
fbcaed
 
fbcaed
-- 
fbcaed
1.9.3
fbcaed