|
|
c44415 |
From 8c533c5aab948fff3ebef12a6d965c9303302c35 Mon Sep 17 00:00:00 2001
|
|
|
c44415 |
From: Luca BRUNO <luca.bruno@coreos.com>
|
|
|
c44415 |
Date: Thu, 17 Jun 2021 08:30:00 +0000
|
|
|
c44415 |
Subject: [PATCH 1/3] builtin/tree: inject _dbpath macro file in postprocessing
|
|
|
c44415 |
step
|
|
|
c44415 |
|
|
|
c44415 |
This wires the _dbpath macro injection logic to `compose postprocess`,
|
|
|
c44415 |
in order to make sure that the rpm configuration in the commit
|
|
|
c44415 |
matches the location of the rpmdb database.
|
|
|
c44415 |
---
|
|
|
c44415 |
rust/src/composepost.rs | 12 +++++++++---
|
|
|
c44415 |
rust/src/lib.rs | 1 +
|
|
|
c44415 |
src/libpriv/rpmostree-postprocess.cxx | 3 +++
|
|
|
c44415 |
3 files changed, 13 insertions(+), 3 deletions(-)
|
|
|
c44415 |
|
|
|
c44415 |
diff --git a/rust/src/composepost.rs b/rust/src/composepost.rs
|
|
|
c44415 |
index c63ca8fa5..4e000a97e 100644
|
|
|
c44415 |
--- a/rust/src/composepost.rs
|
|
|
c44415 |
+++ b/rust/src/composepost.rs
|
|
|
c44415 |
@@ -172,9 +172,15 @@ fn postprocess_presets(rootfs_dfd: &openat::Dir) -> Result<()> {
|
|
|
c44415 |
Ok(())
|
|
|
c44415 |
}
|
|
|
c44415 |
|
|
|
c44415 |
-// We keep hitting issues with the ostree-remount preset not being
|
|
|
c44415 |
-// enabled; let's just do this rather than trying to propagate the
|
|
|
c44415 |
-// preset everywhere.
|
|
|
c44415 |
+/// Write an RPM macro file to ensure the rpmdb path is set on the client side.
|
|
|
c44415 |
+pub fn compose_postprocess_rpm_macro(rootfs_dfd: i32) -> CxxResult<()> {
|
|
|
c44415 |
+ let rootfs = &crate::ffiutil::ffi_view_openat_dir(rootfs_dfd);
|
|
|
c44415 |
+ postprocess_rpm_macro(rootfs)?;
|
|
|
c44415 |
+ Ok(())
|
|
|
c44415 |
+}
|
|
|
c44415 |
+
|
|
|
c44415 |
+/// Ensure our own `_dbpath` macro exists in the tree.
|
|
|
c44415 |
+#[context("Writing _dbpath RPM macro")]
|
|
|
c44415 |
fn postprocess_rpm_macro(rootfs_dfd: &openat::Dir) -> Result<()> {
|
|
|
c44415 |
let rpm_macros_dir = "usr/lib/rpm/macros.d";
|
|
|
c44415 |
rootfs_dfd.ensure_dir_all(rpm_macros_dir, 0o755)?;
|
|
|
c44415 |
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
|
|
|
c44415 |
index 4c328fe4c..658a7fa95 100644
|
|
|
c44415 |
--- a/rust/src/lib.rs
|
|
|
c44415 |
+++ b/rust/src/lib.rs
|
|
|
c44415 |
@@ -160,6 +160,7 @@ pub mod ffi {
|
|
|
c44415 |
rootfs_dfd: i32,
|
|
|
c44415 |
cancellable: Pin<&mut GCancellable>,
|
|
|
c44415 |
) -> Result<()>;
|
|
|
c44415 |
+ fn compose_postprocess_rpm_macro(rootfs_dfd: i32) -> Result<()>;
|
|
|
c44415 |
}
|
|
|
c44415 |
|
|
|
c44415 |
// A grab-bag of metadata from the deployment's ostree commit
|
|
|
c44415 |
diff --git a/src/libpriv/rpmostree-postprocess.cxx b/src/libpriv/rpmostree-postprocess.cxx
|
|
|
c44415 |
index 42aa0b569..781c3a15c 100644
|
|
|
c44415 |
--- a/src/libpriv/rpmostree-postprocess.cxx
|
|
|
c44415 |
+++ b/src/libpriv/rpmostree-postprocess.cxx
|
|
|
c44415 |
@@ -649,6 +649,9 @@ rpmostree_rootfs_postprocess_common (int rootfs_fd,
|
|
|
c44415 |
}
|
|
|
c44415 |
}
|
|
|
c44415 |
|
|
|
c44415 |
+ /* Make sure there is an RPM macro in place pointing to the rpmdb in /usr */
|
|
|
c44415 |
+ rpmostreecxx::compose_postprocess_rpm_macro(rootfs_fd);
|
|
|
c44415 |
+
|
|
|
c44415 |
if (!rpmostree_cleanup_leftover_rpmdb_files (rootfs_fd, cancellable, error))
|
|
|
c44415 |
return FALSE;
|
|
|
c44415 |
|
|
|
c44415 |
|
|
|
c44415 |
From ac7c64428594726a5420b1c11d7b6d6a48ffc0a8 Mon Sep 17 00:00:00 2001
|
|
|
c44415 |
From: Luca BRUNO <luca.bruno@coreos.com>
|
|
|
c44415 |
Date: Sun, 13 Jun 2021 13:50:39 +0000
|
|
|
c44415 |
Subject: [PATCH 2/3] libpriv/core: set _dbpath macro in dnf context
|
|
|
c44415 |
|
|
|
c44415 |
This ensures that the `_dbpath` macro is always in all dnf contexts,
|
|
|
c44415 |
in order to use the rpmdb under /usr.
|
|
|
c44415 |
Setting it explicitly makes sure that there is no logic implicitly
|
|
|
c44415 |
relying on host configuration. This is particularly relevant in
|
|
|
c44415 |
server-side compose cases, which are more likely to be running in
|
|
|
c44415 |
an environment without rpm-ostree macro file.
|
|
|
c44415 |
---
|
|
|
c44415 |
src/libpriv/rpmostree-core.cxx | 3 +++
|
|
|
c44415 |
1 file changed, 3 insertions(+)
|
|
|
c44415 |
|
|
|
c44415 |
diff --git a/src/libpriv/rpmostree-core.cxx b/src/libpriv/rpmostree-core.cxx
|
|
|
c44415 |
index 12381e20e..ab0e0ef54 100644
|
|
|
c44415 |
--- a/src/libpriv/rpmostree-core.cxx
|
|
|
c44415 |
+++ b/src/libpriv/rpmostree-core.cxx
|
|
|
c44415 |
@@ -379,6 +379,9 @@ rpmostree_context_new_client (OstreeRepo *repo)
|
|
|
c44415 |
dnf_context_set_zchunk (self->dnfctx, FALSE);
|
|
|
c44415 |
#endif
|
|
|
c44415 |
|
|
|
c44415 |
+ /* The rpmdb is at /usr/share/rpm */
|
|
|
c44415 |
+ dnf_context_set_rpm_macro (self->dnfctx, "_dbpath", "/" RPMOSTREE_RPMDB_LOCATION);
|
|
|
c44415 |
+
|
|
|
c44415 |
return self;
|
|
|
c44415 |
}
|
|
|
c44415 |
|
|
|
c44415 |
|
|
|
c44415 |
From bfdebee9f8b0bf7c4488bcfe723b12faed784da8 Mon Sep 17 00:00:00 2001
|
|
|
c44415 |
From: Colin Walters <walters@verbum.org>
|
|
|
c44415 |
Date: Fri, 11 Jun 2021 15:33:30 +0000
|
|
|
c44415 |
Subject: [PATCH 3/3] builtin/tree: explicitly set _dbpath macro in global
|
|
|
c44415 |
libdnf initialization
|
|
|
c44415 |
|
|
|
c44415 |
This ensures that the `_dbpath` macro is always in all dnf contexts,
|
|
|
c44415 |
in order to use the rpmdb under /usr.
|
|
|
c44415 |
Setting it explicitly makes sure that there is no logic implicitly
|
|
|
c44415 |
relying on host configuration. This is particularly relevant in
|
|
|
c44415 |
server-side compose cases, which are more likely to be running in
|
|
|
c44415 |
an environment without rpm-ostree macro file.
|
|
|
c44415 |
---
|
|
|
c44415 |
src/app/rpmostree-compose-builtin-tree.cxx | 2 ++
|
|
|
c44415 |
src/libpriv/rpmostree-core.cxx | 32 +++++++++++++++++++---
|
|
|
c44415 |
src/libpriv/rpmostree-core.h | 4 +++
|
|
|
c44415 |
src/libpriv/rpmostree-rpm-util.cxx | 2 ++
|
|
|
c44415 |
4 files changed, 36 insertions(+), 4 deletions(-)
|
|
|
c44415 |
|
|
|
c44415 |
diff --git a/src/app/rpmostree-compose-builtin-tree.cxx b/src/app/rpmostree-compose-builtin-tree.cxx
|
|
|
c44415 |
index 4d88ee95f..d6eef2c44 100644
|
|
|
c44415 |
--- a/src/app/rpmostree-compose-builtin-tree.cxx
|
|
|
c44415 |
+++ b/src/app/rpmostree-compose-builtin-tree.cxx
|
|
|
c44415 |
@@ -574,6 +574,8 @@ rpm_ostree_compose_context_new (const char *treefile_pathstr,
|
|
|
c44415 |
{
|
|
|
c44415 |
g_autoptr(RpmOstreeTreeComposeContext) self = g_new0 (RpmOstreeTreeComposeContext, 1);
|
|
|
c44415 |
|
|
|
c44415 |
+ rpmostreecxx::core_libdnf_process_global_init();
|
|
|
c44415 |
+
|
|
|
c44415 |
/* Init fds to -1 */
|
|
|
c44415 |
self->workdir_dfd = self->rootfs_dfd = self->cachedir_dfd = -1;
|
|
|
c44415 |
/* Test whether or not bwrap is going to work - we will fail inside e.g. a Docker
|
|
|
c44415 |
diff --git a/src/libpriv/rpmostree-core.cxx b/src/libpriv/rpmostree-core.cxx
|
|
|
c44415 |
index ab0e0ef54..e142ccd76 100644
|
|
|
c44415 |
--- a/src/libpriv/rpmostree-core.cxx
|
|
|
c44415 |
+++ b/src/libpriv/rpmostree-core.cxx
|
|
|
c44415 |
@@ -653,6 +653,32 @@ rpmostree_context_set_treespec (RpmOstreeContext *self, RpmOstreeTreespec *trees
|
|
|
c44415 |
self->spec = (RpmOstreeTreespec*)g_object_ref (treespec);
|
|
|
c44415 |
}
|
|
|
c44415 |
|
|
|
c44415 |
+namespace rpmostreecxx {
|
|
|
c44415 |
+// Sadly, like most of librpm, macros are a process-global state.
|
|
|
c44415 |
+// For rpm-ostree, the dbpath must be overriden.
|
|
|
c44415 |
+void
|
|
|
c44415 |
+core_libdnf_process_global_init()
|
|
|
c44415 |
+{
|
|
|
c44415 |
+ static gsize initialized = 0;
|
|
|
c44415 |
+
|
|
|
c44415 |
+ if (g_once_init_enter (&initialized))
|
|
|
c44415 |
+ {
|
|
|
c44415 |
+ g_autoptr(GError) error = NULL;
|
|
|
c44415 |
+ /* Fatally error out if this fails */
|
|
|
c44415 |
+ if (!dnf_context_globals_init (&error))
|
|
|
c44415 |
+ g_error ("%s", error->message);
|
|
|
c44415 |
+
|
|
|
c44415 |
+ /* This is what we use as default. Note we should be able to drop this in the
|
|
|
c44415 |
+ * future on the *client side* now that we inject a macro to set that value in our OSTrees.
|
|
|
c44415 |
+ */
|
|
|
c44415 |
+ free (rpmExpand ("%define _dbpath /" RPMOSTREE_RPMDB_LOCATION, NULL));
|
|
|
c44415 |
+
|
|
|
c44415 |
+ g_once_init_leave (&initialized, 1);
|
|
|
c44415 |
+ }
|
|
|
c44415 |
+}
|
|
|
c44415 |
+
|
|
|
c44415 |
+} /* namespace */
|
|
|
c44415 |
+
|
|
|
c44415 |
/* Wraps `dnf_context_setup()`, and initializes state based on the treespec
|
|
|
c44415 |
* @spec. Another way to say it is we pair `DnfContext` with an
|
|
|
c44415 |
* `RpmOstreeTreespec`. For example, we handle "instlangs", set the rpmdb root
|
|
|
c44415 |
@@ -674,6 +700,8 @@ rpmostree_context_setup (RpmOstreeContext *self,
|
|
|
c44415 |
/* This exists (as a canonically empty dir) at least on RHEL7+ */
|
|
|
c44415 |
static const char emptydir_path[] = "/usr/share/empty";
|
|
|
c44415 |
|
|
|
c44415 |
+ rpmostreecxx::core_libdnf_process_global_init();
|
|
|
c44415 |
+
|
|
|
c44415 |
/* Auto-synthesize a spec for now; this will be removed */
|
|
|
c44415 |
if (!self->spec)
|
|
|
c44415 |
rpmostree_context_set_treespec (self, NULL);
|
|
|
c44415 |
@@ -710,10 +738,6 @@ rpmostree_context_setup (RpmOstreeContext *self,
|
|
|
c44415 |
dnf_context_set_rpm_macro (self->dnfctx, "_install_langs", instlangs.c_str());
|
|
|
c44415 |
}
|
|
|
c44415 |
|
|
|
c44415 |
- /* This is what we use as default. Note we should be able to drop this in the
|
|
|
c44415 |
- * future now that we inject a macro to set that value in our OSTrees. */
|
|
|
c44415 |
- dnf_context_set_rpm_macro (self->dnfctx, "_dbpath", "/" RPMOSTREE_RPMDB_LOCATION);
|
|
|
c44415 |
-
|
|
|
c44415 |
/* Set the database backend only in the compose path. It then becomes the default
|
|
|
c44415 |
* for any client side layering.
|
|
|
c44415 |
*/
|
|
|
c44415 |
diff --git a/src/libpriv/rpmostree-core.h b/src/libpriv/rpmostree-core.h
|
|
|
c44415 |
index 1db1014cd..cea97028e 100644
|
|
|
c44415 |
--- a/src/libpriv/rpmostree-core.h
|
|
|
c44415 |
+++ b/src/libpriv/rpmostree-core.h
|
|
|
c44415 |
@@ -78,6 +78,10 @@ char* rpmostree_refspec_to_string (RpmOstreeRefspecType reftype,
|
|
|
c44415 |
char* rpmostree_refspec_canonicalize (const char *orig_refspec,
|
|
|
c44415 |
GError **error);
|
|
|
c44415 |
|
|
|
c44415 |
+namespace rpmostreecxx {
|
|
|
c44415 |
+void core_libdnf_process_global_init();
|
|
|
c44415 |
+}
|
|
|
c44415 |
+
|
|
|
c44415 |
RpmOstreeContext *rpmostree_context_new_client (OstreeRepo *repo);
|
|
|
c44415 |
|
|
|
c44415 |
RpmOstreeContext *rpmostree_context_new_compose (int basedir_dfd,
|
|
|
c44415 |
diff --git a/src/libpriv/rpmostree-rpm-util.cxx b/src/libpriv/rpmostree-rpm-util.cxx
|
|
|
c44415 |
index 57bdda4ed..19640b864 100644
|
|
|
c44415 |
--- a/src/libpriv/rpmostree-rpm-util.cxx
|
|
|
c44415 |
+++ b/src/libpriv/rpmostree-rpm-util.cxx
|
|
|
c44415 |
@@ -851,6 +851,8 @@ get_sack_for_root (int dfd,
|
|
|
c44415 |
GLNX_AUTO_PREFIX_ERROR ("Loading sack", error);
|
|
|
c44415 |
g_assert (out_sack != NULL);
|
|
|
c44415 |
|
|
|
c44415 |
+ rpmostreecxx::core_libdnf_process_global_init();
|
|
|
c44415 |
+
|
|
|
c44415 |
g_autofree char *fullpath = glnx_fdrel_abspath (dfd, path);
|
|
|
c44415 |
|
|
|
c44415 |
g_autoptr(DnfSack) sack = dnf_sack_new ();
|