return r;
}
-static int pakfire_oci_writer_write_layer_version(struct pakfire_oci_writer* self) {
- char filename[PATH_MAX];
- int r;
-
- const char* version = "1.0";
-
- // Make the filename of the layer version
- r = pakfire_path_format(filename, "%s/VERSION", self->layer_hexdigest);
- if (r < 0)
- return r;
-
- // Write the version file
- r = pakfire_archive_writer_create_file(self->image,
- filename, 0644, version, strlen(version));
- if (r < 0)
- return r;
-
- return 0;
-}
-
-static int pakfire_oci_writer_write_layer_json(struct pakfire_oci_writer* self) {
- struct json_object* o = NULL;
- char filename[PATH_MAX];
- char created[64];
- int r;
-
- // Make a new object
- o = pakfire_json_new_object();
- if (!o) {
- r = -errno;
- goto ERROR;
- }
-
- // Add the ID
- r = pakfire_json_add_string(o, "id", self->layer_hexdigest);
- if (r < 0)
- goto ERROR;
-
- // Format the current time
- r = pakfire_strftime_now(created, "%Y-%m-%dT%H:%M:%SZ");
- if (r < 0)
- goto ERROR;
-
- // Add the creation timestamp
- r = pakfire_json_add_string(o, "created", created);
- if (r < 0)
- goto ERROR;
-
- // Vendor
- const char* vendor = pakfire_get_distro_vendor(self->pakfire);
- if (vendor) {
- r = pakfire_json_add_string(o, "author", vendor);
- if (r < 0)
- goto ERROR;
- }
-
- const char* arch = pakfire_oci_arch(self->pakfire);
-
- // Architecture
- r = pakfire_json_add_string(o, "architecture", arch);
- if (r < 0)
- goto ERROR;
-
- // OS
- r = pakfire_json_add_string(o, "os", "linux");
- if (r < 0)
- goto ERROR;
-
- // Version ID
- const char* version_id = pakfire_get_distro_version_id(self->pakfire);
- if (version_id) {
- r = pakfire_json_add_string(o, "os.version", version_id);
- if (r < 0)
- goto ERROR;
- }
-
- // Make the path
- r = pakfire_path_format(filename, "%s/json", self->layer_hexdigest);
- if (r < 0)
- goto ERROR;
-
- // Write the file to the image
- r = pakfire_archive_writer_create_file_from_json(self->image, filename, 0644, o);
- if (r < 0)
- goto ERROR;
-
-ERROR:
- if (o)
- json_object_put(o);
-
- return r;
-}
-
static int pakfire_oci_writer_make_layer(struct pakfire_oci_writer* self) {
char path[PATH_MAX] = PAKFIRE_TMP_DIR "/pakfire-oci-layer.XXXXXX";
struct pakfire_archive_writer* layer = NULL;
if (r < 0)
goto ERROR;
- // Write the version file
- r = pakfire_oci_writer_write_layer_version(self);
- if (r < 0)
- goto ERROR;
-
- // Write the json file
- r = pakfire_oci_writer_write_layer_json(self);
- if (r < 0)
- goto ERROR;
-
// Make the filename of the layer file
r = pakfire_path_format(filename, "%s/layer.tar", self->layer_hexdigest);
if (r < 0)