diff options
author | Dan Nicholson <nicholson@endlessm.com> | 2019-10-15 16:46:59 -0600 |
---|---|---|
committer | Dan Nicholson <dbn@endlessos.org> | 2023-02-07 14:50:47 -0700 |
commit | b88948180129a8866a4c03699c16f21ce40f3b18 (patch) | |
tree | f0cf15124948545bd24e582a639d82cfbc104754 /src/ostree | |
parent | b2f02337f86efe55f56ea2ad641a55059c2a2623 (diff) | |
download | ostree-b88948180129a8866a4c03699c16f21ce40f3b18.tar.gz |
repo: Create metadata commit in ostree_repo_regenerate_metadata
Rather than creating the `ostree-metadata` commit in the summary
builtin, do it in the new `ostree_repo_regenerate_metadata` API. The
commit contents are unchanged and the commit is generated before the
summary as before. To keep from triggering an extra summary update,
automatic summary updating is disabled in the transaction.
Since the summary builtin was already using the new API, it will
continue to generate the `ostree-metadata` commit when the repo has a
collection ID. However, the `ostree_repo_regenerate_summary` API will
still only generate the summary file as before.
Diffstat (limited to 'src/ostree')
-rw-r--r-- | src/ostree/ot-builtin-summary.c | 101 |
1 files changed, 0 insertions, 101 deletions
diff --git a/src/ostree/ot-builtin-summary.c b/src/ostree/ot-builtin-summary.c index 219af604..fc590f8a 100644 --- a/src/ostree/ot-builtin-summary.c +++ b/src/ostree/ot-builtin-summary.c @@ -122,107 +122,6 @@ ostree_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invocati return FALSE; } - const char *collection_id = ostree_repo_get_collection_id (repo); - - /* Write out a new metadata commit for the repository. */ - if (collection_id != NULL) - { - OstreeCollectionRef collection_ref = { (gchar *) collection_id, (gchar *) OSTREE_REPO_METADATA_REF }; - g_autofree char *old_ostree_metadata_checksum = NULL; - g_autofree gchar *new_ostree_metadata_checksum = NULL; - g_autoptr(OstreeMutableTree) mtree = NULL; - g_autoptr(OstreeRepoFile) repo_file = NULL; - g_autoptr(GVariantDict) new_summary_commit_dict = NULL; - g_autoptr(GVariant) new_summary_commit = NULL; - - if (!ostree_repo_resolve_rev (repo, OSTREE_REPO_METADATA_REF, - TRUE, &old_ostree_metadata_checksum, error)) - return FALSE; - - /* Add bindings to the metadata. */ - new_summary_commit_dict = g_variant_dict_new (additional_metadata); - g_variant_dict_insert (new_summary_commit_dict, OSTREE_COMMIT_META_KEY_COLLECTION_BINDING, - "s", collection_ref.collection_id); - g_variant_dict_insert_value (new_summary_commit_dict, OSTREE_COMMIT_META_KEY_REF_BINDING, - g_variant_new_strv ((const gchar * const *) &collection_ref.ref_name, 1)); - new_summary_commit = g_variant_dict_end (new_summary_commit_dict); - - if (!ostree_repo_prepare_transaction (repo, NULL, cancellable, error)) - return FALSE; - - /* Set up an empty mtree. */ - mtree = ostree_mutable_tree_new (); - - glnx_unref_object GFileInfo *fi = g_file_info_new (); - g_file_info_set_attribute_uint32 (fi, "unix::uid", 0); - g_file_info_set_attribute_uint32 (fi, "unix::gid", 0); - g_file_info_set_attribute_uint32 (fi, "unix::mode", (0755 | S_IFDIR)); - - g_autofree guchar *csum_raw = NULL; - g_autofree char *csum = NULL; - - g_autoptr(GVariant) dirmeta = ostree_create_directory_metadata (fi, NULL /* xattrs */); - - if (!ostree_repo_write_metadata (repo, OSTREE_OBJECT_TYPE_DIR_META, NULL, - dirmeta, &csum_raw, cancellable, error)) - return FALSE; - - csum = ostree_checksum_from_bytes (csum_raw); - ostree_mutable_tree_set_metadata_checksum (mtree, csum); - - if (!ostree_repo_write_mtree (repo, mtree, (GFile **) &repo_file, NULL, error)) - return FALSE; - - if (!ostree_repo_write_commit (repo, old_ostree_metadata_checksum, - NULL /* subject */, NULL /* body */, - new_summary_commit, repo_file, &new_ostree_metadata_checksum, - NULL, error)) - return FALSE; - if (opt_gpg_key_ids != NULL) - { - for (const char * const *iter = (const char * const *) opt_gpg_key_ids; - iter != NULL && *iter != NULL; iter++) - { - const char *key_id = *iter; - - if (!ostree_repo_sign_commit (repo, - new_ostree_metadata_checksum, - key_id, - opt_gpg_homedir, - cancellable, - error)) - return FALSE; - } - } - - if (opt_key_ids) - { - char **iter; - for (iter = opt_key_ids; iter && *iter; iter++) - { - const char *keyid = *iter; - g_autoptr (GVariant) secret_key = NULL; - - secret_key = g_variant_new_string (keyid); - if (!ostree_sign_set_sk (sign, secret_key, error)) - return FALSE; - - if (!ostree_sign_commit (sign, - repo, - new_ostree_metadata_checksum, - cancellable, - error)) - return FALSE; - } - } - - ostree_repo_transaction_set_collection_ref (repo, &collection_ref, - new_ostree_metadata_checksum); - - if (!ostree_repo_commit_transaction (repo, NULL, cancellable, error)) - return FALSE; - } - /* Regenerate and sign the repo metadata. */ g_auto(GVariantBuilder) metadata_opts_builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_VARDICT); g_autoptr(GVariant) metadata_opts = NULL; |