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