From 8f4082df6d680adc07cfcd127bf34344ec799e14 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 24 Jun 2019 12:15:32 +0200 Subject: [PATCH] build-bundle: Add --oci-use-labels switch This allows the user to pick at runtime whether to use annotations or labels as OCI metadata carrier. For historical reasons annotations is the default, but some registries don't support this and then you can use labels instead. Closes: #2978 Approved by: alexlarsson --- app/flatpak-builtins-build-bundle.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/flatpak-builtins-build-bundle.c b/app/flatpak-builtins-build-bundle.c index a4287709..b11a68c1 100644 --- a/app/flatpak-builtins-build-bundle.c +++ b/app/flatpak-builtins-build-bundle.c @@ -48,6 +48,7 @@ static char *opt_runtime_repo; static gboolean opt_runtime = FALSE; static char **opt_gpg_file; static gboolean opt_oci = FALSE; +static gboolean opt_oci_use_labels = FALSE; static char **opt_gpg_key_ids; static char *opt_gpg_homedir; static char *opt_from_commit; @@ -62,6 +63,7 @@ static GOptionEntry options[] = { { "gpg-homedir", 0, 0, G_OPTION_ARG_STRING, &opt_gpg_homedir, N_("GPG Homedir to use when looking for keyrings"), N_("HOMEDIR") }, { "from-commit", 0, 0, G_OPTION_ARG_STRING, &opt_from_commit, N_("OSTree commit to create a delta bundle from"), N_("COMMIT") }, { "oci", 0, 0, G_OPTION_ARG_NONE, &opt_oci, N_("Export oci image instead of flatpak bundle"), NULL }, + { "oci-use-labels", 0, 0, G_OPTION_ARG_NONE, &opt_oci_use_labels, N_("Use OCI labels instead of annotations"), NULL }, { NULL } }; @@ -522,8 +524,9 @@ build_oci (OstreeRepo *repo, const char *commit_checksum, GFile *dir, image->history[history_index]->created = g_time_val_to_iso8601 (&tv); image->history[history_index]->created_by = g_strdup ("flatpak build-bundle"); - flatpak_oci_copy_annotations (flatpak_annotations, - flatpak_oci_image_get_labels (image)); + if (opt_oci_use_labels) + flatpak_oci_copy_annotations (flatpak_annotations, + flatpak_oci_image_get_labels (image)); timestamp = timestamp_to_iso8601 (ostree_commit_get_timestamp (commit_data)); flatpak_oci_image_set_created (image, timestamp); @@ -536,8 +539,9 @@ build_oci (OstreeRepo *repo, const char *commit_checksum, GFile *dir, flatpak_oci_manifest_set_config (manifest, image_desc); flatpak_oci_manifest_set_layer (manifest, layer_desc); - flatpak_oci_copy_annotations (flatpak_annotations, - flatpak_oci_manifest_get_annotations (manifest)); + if (!opt_oci_use_labels) + flatpak_oci_copy_annotations (flatpak_annotations, + flatpak_oci_manifest_get_annotations (manifest)); manifest_desc = flatpak_oci_registry_store_json (registry, FLATPAK_JSON (manifest), cancellable, error); if (manifest_desc == NULL)