rpm-ostree/0001-libpriv-rpm-util-Use-usr-share-rpm-for-base-rpmdb-qu.patch
DistroBaker 4e5186faa2 Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/rpm-ostree.git#e0b1dfbe1225f55f9a1cff49c3da9530bea346c5
2021-02-17 21:35:25 +00:00

90 lines
3.8 KiB
Diff

From 667fdc9ff44d086140d195e4714d132edee2bf9a Mon Sep 17 00:00:00 2001
From: Jonathan Lebon <jonathan@jlebon.com>
Date: Tue, 9 Feb 2021 14:17:16 -0500
Subject: [PATCH] libpriv/rpm-util: Use /usr/share/rpm for base rpmdb query
Follow-up to previous commit: we had another path where we made a
temporary rootfs and symlinked `/var/lib/rpm` to the base rpmdb. That of
course broke now that we inject a macro to point the rpmdb to
`/usr/share/rpm`.
Rework this to use `/usr/share/rpm` since that's our canonical location
for now, but also add the compat symlinks so that this logic should keep
working even on trees without the injected macro yet.
---
src/libpriv/rpmostree-rpm-util.cxx | 38 ++++++++++++++++++++----------
1 file changed, 26 insertions(+), 12 deletions(-)
diff --git a/src/libpriv/rpmostree-rpm-util.cxx b/src/libpriv/rpmostree-rpm-util.cxx
index c8d368b3..d8de9830 100644
--- a/src/libpriv/rpmostree-rpm-util.cxx
+++ b/src/libpriv/rpmostree-rpm-util.cxx
@@ -788,6 +788,26 @@ rpmrev_free (struct RpmRevisionData *ptr)
g_free (ptr);
}
+/* Currently, our rpmdb lives at /usr/share/rpm. Add symlinks from the legacy
+ * /var/lib/rpm *and* the future /usr/lib/sysimage/rpm paths to that. */
+static gboolean
+mk_rpmdb_compat_symlinks (int rootfs_dfd,
+ GCancellable *cancellable,
+ GError **error)
+{
+ if (!glnx_shutil_mkdir_p_at (rootfs_dfd, "var/lib", 0777, cancellable, error))
+ return FALSE;
+ if (symlinkat ("../../" RPMOSTREE_RPMDB_LOCATION, rootfs_dfd, "var/lib/rpm") == -1)
+ return glnx_throw_errno_prefix (error, "symlinkat");
+
+ if (!glnx_shutil_mkdir_p_at (rootfs_dfd, RPMOSTREE_SYSIMAGE_DIR, 0777, cancellable, error))
+ return FALSE;
+ if (symlinkat ("../../../" RPMOSTREE_RPMDB_LOCATION, rootfs_dfd, RPMOSTREE_SYSIMAGE_RPMDB) == -1)
+ return glnx_throw_errno_prefix (error, "symlinkat");
+
+ return TRUE;
+}
+
/* Check out a copy of the rpmdb into @tmpdir */
static gboolean
checkout_only_rpmdb (OstreeRepo *repo,
@@ -816,17 +836,8 @@ checkout_only_rpmdb (OstreeRepo *repo,
cancellable, error))
return FALSE;
- /* And make a compat symlink to keep rpm happy */
- if (!glnx_shutil_mkdir_p_at (tmpdir->fd, "var/lib", 0777, cancellable, error))
- return FALSE;
- if (symlinkat ("../../" RPMOSTREE_RPMDB_LOCATION, tmpdir->fd, "var/lib/rpm") == -1)
- return glnx_throw_errno_prefix (error, "symlinkat");
-
- /* And make a symlink from our *future* location too */
- if (!glnx_shutil_mkdir_p_at (tmpdir->fd, RPMOSTREE_SYSIMAGE_DIR, 0777, cancellable, error))
+ if (!mk_rpmdb_compat_symlinks (tmpdir->fd, cancellable, error))
return FALSE;
- if (symlinkat ("../../../" RPMOSTREE_RPMDB_LOCATION, tmpdir->fd, RPMOSTREE_SYSIMAGE_RPMDB) == -1)
- return glnx_throw_errno_prefix (error, "symlinkat");
return TRUE;
}
@@ -890,13 +901,16 @@ rpmostree_get_base_refsack_for_root (int dfd,
g_auto(GLnxTmpDir) tmpdir = {0, };
if (!glnx_mkdtemp ("rpmostree-dbquery-XXXXXX", 0700, &tmpdir, error))
return FALSE;
- if (!glnx_shutil_mkdir_p_at (tmpdir.fd, "var/lib", 0777, cancellable, error))
+ if (!glnx_shutil_mkdir_p_at (tmpdir.fd, dirname (strdupa (RPMOSTREE_RPMDB_LOCATION)), 0777, cancellable, error))
return FALSE;
g_autofree char *base_rpm = glnx_fdrel_abspath (dfd, subpath);
- if (symlinkat (base_rpm, tmpdir.fd, "var/lib/rpm") == -1)
+ if (symlinkat (base_rpm, tmpdir.fd, RPMOSTREE_RPMDB_LOCATION) == -1)
return glnx_throw_errno_prefix (error, "symlinkat");
+ if (!mk_rpmdb_compat_symlinks (tmpdir.fd, cancellable, error))
+ return FALSE;
+
g_autoptr(DnfSack) sack = NULL; /* NB: refsack adds a ref to it */
if (!get_sack_for_root (tmpdir.fd, ".", &sack, error))
return FALSE;
--
2.29.2