From ae108e08a5daee04426f57db1fa13ac814638543 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 15 Nov 2016 10:17:03 -0500 Subject: [PATCH] Add rpmostree.clientlayer metadata to derived commits In the future we may add more commands that take as input commit IDs. However, we really want to distinguish between server and client generated commits, as some of these operations won't make sense for derived commits. This changes the API to have callers say which type of commit they're generating, which also fixes a FIXME, and helps get us a bit closer to the "unified core". Closes: #520 Approved by: jlebon --- src/app/rpmostree-container-builtins.c | 6 ++++-- src/daemon/rpmostree-sysroot-upgrader.c | 1 + src/libpriv/rpmostree-core.c | 12 +++++++++--- src/libpriv/rpmostree-core.h | 6 ++++++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/app/rpmostree-container-builtins.c b/src/app/rpmostree-container-builtins.c index 8e769891..a2d3cb9b 100644 --- a/src/app/rpmostree-container-builtins.c +++ b/src/app/rpmostree-container-builtins.c @@ -322,7 +322,8 @@ rpmostree_container_builtin_assemble (int argc, goto out; if (!rpmostree_context_assemble_commit (rocctx->ctx, tmprootfs_dfd, NULL, - NULL, FALSE, &commit, cancellable, error)) + NULL, RPMOSTREE_ASSEMBLE_TYPE_SERVER_BASE, + FALSE, &commit, cancellable, error)) goto out; glnx_shutil_rm_rf_at (rocctx->userroot_dfd, tmprootfs, cancellable, NULL); @@ -534,7 +535,8 @@ rpmostree_container_builtin_upgrade (int argc, char **argv, GCancellable *cancel goto out; if (!rpmostree_context_assemble_commit (rocctx->ctx, tmprootfs_dfd, NULL, - NULL, TRUE, &new_commit_checksum, + NULL, RPMOSTREE_ASSEMBLE_TYPE_SERVER_BASE, + TRUE, &new_commit_checksum, cancellable, error)) goto out; diff --git a/src/daemon/rpmostree-sysroot-upgrader.c b/src/daemon/rpmostree-sysroot-upgrader.c index 716eb04a..d679fbf2 100644 --- a/src/daemon/rpmostree-sysroot-upgrader.c +++ b/src/daemon/rpmostree-sysroot-upgrader.c @@ -1064,6 +1064,7 @@ overlay_final_pkgset (RpmOstreeSysrootUpgrader *self, /* --- Overlay and commit --- */ if (!rpmostree_context_assemble_commit (ctx, tmprootfs_dfd, devino_cache, base_rev, + RPMOSTREE_ASSEMBLE_TYPE_CLIENT_LAYERING, (self->flags & RPMOSTREE_SYSROOT_UPGRADER_FLAGS_PKGOVERLAY_NOSCRIPTS) > 0, &self->new_revision, cancellable, error)) diff --git a/src/libpriv/rpmostree-core.c b/src/libpriv/rpmostree-core.c index 3730984c..9b923dfe 100644 --- a/src/libpriv/rpmostree-core.c +++ b/src/libpriv/rpmostree-core.c @@ -1849,6 +1849,7 @@ rpmostree_context_assemble_commit (RpmOstreeContext *self, int tmprootfs_dfd, OstreeRepoDevInoCache *devino_cache, const char *parent, + RpmOstreeAssembleType assemble_type, gboolean noscripts, char **out_commit, GCancellable *cancellable, @@ -2188,13 +2189,14 @@ rpmostree_context_assemble_commit (RpmOstreeContext *self, g_variant_builder_add (&metadata_builder, "{sv}", "rpmostree.spec", spec_v); - /* copy the version tag from the parent if present -- XXX: this behaviour - * should probably be adjustable from a new parameter instead */ - if (parent != NULL) + /* copy the version tag */ + if (assemble_type == RPMOSTREE_ASSEMBLE_TYPE_CLIENT_LAYERING) { g_autoptr(GVariant) commit = NULL; g_autofree char *parent_version = NULL; + g_assert (parent != NULL); + if (!ostree_repo_load_commit (self->ostreerepo, parent, &commit, NULL, error)) goto out; @@ -2203,6 +2205,10 @@ rpmostree_context_assemble_commit (RpmOstreeContext *self, if (parent_version) g_variant_builder_add (&metadata_builder, "{sv}", "version", g_variant_new_string (parent_version)); + + /* Flag the commit as a client layer */ + g_variant_builder_add (&metadata_builder, "{sv}", "rpmostree.clientlayer", + g_variant_new_boolean (TRUE)); } state_checksum = rpmostree_context_get_state_sha512 (self); diff --git a/src/libpriv/rpmostree-core.h b/src/libpriv/rpmostree-core.h index f64bde62..dbc6695c 100644 --- a/src/libpriv/rpmostree-core.h +++ b/src/libpriv/rpmostree-core.h @@ -103,12 +103,18 @@ gboolean rpmostree_context_relabel (RpmOstreeContext *self, GCancellable *cancellable, GError **error); +typedef enum { + RPMOSTREE_ASSEMBLE_TYPE_SERVER_BASE, + RPMOSTREE_ASSEMBLE_TYPE_CLIENT_LAYERING +} RpmOstreeAssembleType; + /* NB: tmprootfs_dfd is allowed to have pre-existing data */ /* devino_cache can be NULL if no previous cache established */ gboolean rpmostree_context_assemble_commit (RpmOstreeContext *self, int tmprootfs_dfd, OstreeRepoDevInoCache *devino_cache, const char *parent, + RpmOstreeAssembleType assemble_type, gboolean noscripts, char **out_commit, GCancellable *cancellable,