From: Michael Tremer Date: Sat, 8 Feb 2025 14:59:59 +0000 (+0000) Subject: oci: Write the OCI layout file X-Git-Tag: 0.9.30~65 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ce139ea5ccb00e05951c8893d7fe6552d6033ac1;p=pakfire.git oci: Write the OCI layout file Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/oci.c b/src/pakfire/oci.c index 2a63b7c4..18da4def 100644 --- a/src/pakfire/oci.c +++ b/src/pakfire/oci.c @@ -74,6 +74,34 @@ static const char* pakfire_oci_arch(struct pakfire* pakfire) { return arch; } +static int pakfire_oci_writer_write_oci_layout(struct pakfire_oci_writer* self) { + struct json_object* o = NULL; + int r; + + // Make a new object + o = pakfire_json_new_object(); + if (!o) { + r = -errno; + goto ERROR; + } + + // Set version + r = pakfire_json_add_string(o, "imageLayoutVersion", "1.0.0"); + if (r < 0) + goto ERROR; + + // Write the file + r = pakfire_archive_writer_create_file_from_json(self->image, "oci-layout", 0644, o); + if (r < 0) + goto ERROR; + +ERROR: + if (o) + json_object_put(o); + + return r; +} + static int pakfire_oci_writer_write_layer_version(struct pakfire_oci_writer* self) { char filename[PATH_MAX]; int r; @@ -267,6 +295,13 @@ int pakfire_oci_mkimage(struct pakfire* pakfire, FILE* f) { if (r < 0) goto ERROR; + // Write oci-layout file + r = pakfire_oci_writer_write_oci_layout(&writer); + if (r < 0) { + ERROR(writer.ctx, "Failed to write the OCI layout file: %s\n", strerror(-r)); + goto ERROR; + } + // Make the layer r = pakfire_oci_writer_make_layer(&writer); if (r < 0)