mirror of
https://github.com/flatpak/flatpak.git
synced 2026-04-02 06:13:13 -04:00
OCI: Handle manifests without annotations in index.json
When we export a manifest to the index, always pass the ref we're targeting instead of relying on the org.opencontainers.image.ref.name annotation, because that may not be set if we're using labels instead. This is no big deal, because we know what ref we're handling anyway.
This commit is contained in:
@@ -553,7 +553,7 @@ build_oci (OstreeRepo *repo, const char *commit_checksum, GFile *dir,
|
||||
if (index == NULL)
|
||||
index = flatpak_oci_index_new ();
|
||||
|
||||
flatpak_oci_index_add_manifest (index, manifest_desc);
|
||||
flatpak_oci_index_add_manifest (index, ref, manifest_desc);
|
||||
|
||||
if (!flatpak_oci_registry_save_index (registry, index, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
@@ -5025,7 +5025,7 @@ flatpak_dir_mirror_oci (FlatpakDir *self,
|
||||
|
||||
g_debug ("Mirroring OCI image %s", oci_digest);
|
||||
|
||||
res = flatpak_mirror_image_from_oci (dst_registry, registry, oci_repository, oci_digest, oci_pull_progress_cb,
|
||||
res = flatpak_mirror_image_from_oci (dst_registry, registry, oci_repository, oci_digest, ref, oci_pull_progress_cb,
|
||||
progress, cancellable, error);
|
||||
|
||||
if (progress)
|
||||
|
||||
@@ -152,6 +152,7 @@ struct _FlatpakOciIndexClass
|
||||
|
||||
FlatpakOciIndex * flatpak_oci_index_new (void);
|
||||
void flatpak_oci_index_add_manifest (FlatpakOciIndex *self,
|
||||
const char *ref,
|
||||
FlatpakOciDescriptor *desc);
|
||||
gboolean flatpak_oci_index_remove_manifest (FlatpakOciIndex *self,
|
||||
const char *ref);
|
||||
|
||||
@@ -448,21 +448,18 @@ flatpak_oci_index_get_n_manifests (FlatpakOciIndex *self)
|
||||
|
||||
void
|
||||
flatpak_oci_index_add_manifest (FlatpakOciIndex *self,
|
||||
const char *ref,
|
||||
FlatpakOciDescriptor *desc)
|
||||
{
|
||||
FlatpakOciManifestDescriptor *m;
|
||||
const char *m_ref = NULL;
|
||||
int count;
|
||||
|
||||
if (desc->annotations != NULL)
|
||||
m_ref = g_hash_table_lookup (desc->annotations, "org.flatpak.ref");
|
||||
|
||||
if (m_ref != NULL)
|
||||
flatpak_oci_index_remove_manifest (self, m_ref);
|
||||
if (ref != NULL)
|
||||
flatpak_oci_index_remove_manifest (self, ref);
|
||||
|
||||
count = flatpak_oci_index_get_n_manifests (self);
|
||||
|
||||
m = manifest_desc_for_desc (desc, m_ref);
|
||||
m = manifest_desc_for_desc (desc, ref);
|
||||
self->manifests = g_renew (FlatpakOciManifestDescriptor *, self->manifests, count + 2);
|
||||
self->manifests[count] = m;
|
||||
self->manifests[count + 1] = NULL;
|
||||
|
||||
@@ -526,6 +526,7 @@ gboolean flatpak_mirror_image_from_oci (FlatpakOciRegistry *dst_registry,
|
||||
FlatpakOciRegistry *registry,
|
||||
const char *oci_repository,
|
||||
const char *digest,
|
||||
const char *ref,
|
||||
FlatpakOciPullProgress progress_cb,
|
||||
gpointer progress_data,
|
||||
GCancellable *cancellable,
|
||||
|
||||
@@ -5426,6 +5426,7 @@ flatpak_mirror_image_from_oci (FlatpakOciRegistry *dst_registry,
|
||||
FlatpakOciRegistry *registry,
|
||||
const char *oci_repository,
|
||||
const char *digest,
|
||||
const char *ref,
|
||||
FlatpakOciPullProgress progress_cb,
|
||||
gpointer progress_user_data,
|
||||
GCancellable *cancellable,
|
||||
@@ -5491,7 +5492,7 @@ flatpak_mirror_image_from_oci (FlatpakOciRegistry *dst_registry,
|
||||
|
||||
flatpak_oci_export_annotations (manifest->annotations, manifest_desc->annotations);
|
||||
|
||||
flatpak_oci_index_add_manifest (index, manifest_desc);
|
||||
flatpak_oci_index_add_manifest (index, ref, manifest_desc);
|
||||
|
||||
if (!flatpak_oci_registry_save_index (dst_registry, index, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
Reference in New Issue
Block a user