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