From 4b1e9567ae895c18b07ec62be20a91cce3038f33 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 11 Sep 2023 13:04:57 -0400 Subject: [PATCH] core: Add composefs digest for local commits too This pairs with https://github.com/coreos/rpm-ostree/pull/4495/commits/dbe78217c0205dad372c84b2cf0a299003787952 where we generate composefs metadata for base images. It's going to be useful to do it for client side builds too, so that we can treat them symmetrically. It doesn't have a very high cost, just a metadata traversal. --- src/libpriv/rpmostree-core.cxx | 5 ++++- src/libpriv/rpmostree-postprocess.cxx | 14 +++----------- tests/kolainst/destructive/layering-local | 3 +++ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/libpriv/rpmostree-core.cxx b/src/libpriv/rpmostree-core.cxx index 9507bc43f8..0c52c70e3f 100644 --- a/src/libpriv/rpmostree-core.cxx +++ b/src/libpriv/rpmostree-core.cxx @@ -4718,9 +4718,12 @@ rpmostree_context_commit (RpmOstreeContext *self, const char *parent, if (!ostree_commit_metadata_for_bootable (root, metadata_dict, cancellable, error)) return FALSE; } - g_autoptr (GVariant) metadata = g_variant_dict_end (metadata_dict); + if (!ostree_repo_commit_add_composefs_metadata (self->ostreerepo, 0, metadata_dict, + (OstreeRepoFile *)root, cancellable, error)) + return glnx_prefix_error (error, "Adding composefs metadata"); { + g_autoptr (GVariant) metadata = g_variant_dict_end (metadata_dict); if (!ostree_repo_write_commit (self->ostreerepo, parent, "", "", metadata, OSTREE_REPO_FILE (root), &ret_commit_checksum, cancellable, error)) diff --git a/src/libpriv/rpmostree-postprocess.cxx b/src/libpriv/rpmostree-postprocess.cxx index 3030ce5b3a..c72644bc2a 100644 --- a/src/libpriv/rpmostree-postprocess.cxx +++ b/src/libpriv/rpmostree-postprocess.cxx @@ -838,17 +838,9 @@ rpmostree_compose_commit (int rootfs_fd, OstreeRepo *repo, const char *parent_re // Unfortunately these API takes GVariantDict, not GVariantBuilder, so convert g_autoptr (GVariantDict) metadata_dict = g_variant_dict_new (src_metadata); -#if OSTREE_CHECK_VERSION(2023, 4) - g_autoptr (GError) local_error = NULL; - if (!ostree_repo_commit_add_composefs_metadata ( - repo, 0, metadata_dict, (OstreeRepoFile *)root_tree, cancellable, &local_error) - && !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) - { - g_propagate_prefixed_error (error, util::move_nullify (local_error), - "Adding composefs metadata"); - return FALSE; - } -#endif + if (!ostree_repo_commit_add_composefs_metadata (repo, 0, metadata_dict, + (OstreeRepoFile *)root_tree, cancellable, error)) + return glnx_prefix_error (error, "Adding composefs metadata"); if (!container) { diff --git a/tests/kolainst/destructive/layering-local b/tests/kolainst/destructive/layering-local index ca03ceea4c..8ba5a84378 100755 --- a/tests/kolainst/destructive/layering-local +++ b/tests/kolainst/destructive/layering-local @@ -76,6 +76,9 @@ fi ostree show --print-metadata-key=ostree.bootable ${booted_commit} >out.txt assert_file_has_content_literal out.txt 'true' echo "ok bootable metadata" +ostree show --print-metadata-key=ostree.composefs.digest.v0 ${booted_commit} >out.txt +assert_file_has_content_literal out.txt 'byte' +echo "ok composefs metadata on client generated commit" # check we could uninstall the package using either its NEVRA or name rpm-ostree uninstall foo-1.2-3.x86_64