return r;
}
+static int pakfire_archive_make_filelist_from_json(struct pakfire_archive* archive,
+ struct pakfire_filelist** filelist) {
+ struct json_object* array = NULL;
+ int r;
+
+ struct pakfire_filelist* list = NULL;
+ struct pakfire_file* file = NULL;
+
+ // Fetch the array with the filelist
+ array = pakfire_archive_metadata_get_object(archive, "filelist", NULL);
+ if (!array) {
+ ERROR(archive->pakfire, "Archive has no filelist: %m\n");
+ return 1;
+ }
+
+ // Determine the length of the array
+ const size_t length = json_object_array_length(array);
+
+ // End here if the array is empty
+ if (!length)
+ return 0;
+
+ // Create a new filelist object
+ r = pakfire_filelist_create(&list, archive->pakfire);
+ if (r)
+ goto ERROR;
+
+ // Walk through all items in this array
+ for (unsigned int i = 0; i < length; i++) {
+ struct json_object* item = json_object_array_get_idx(array, i);
+ if (!item)
+ continue;
+
+ // Extract the path value
+ const char* path = json_object_get_string(item);
+ if (!path)
+ continue;
+
+ // Create a new file object
+ r = pakfire_file_create(&file, archive->pakfire);
+ if (r)
+ goto ERROR;
+
+ // Set path
+ r = pakfire_file_set_path(file, path);
+ if (r) {
+ pakfire_file_unref(file);
+ goto ERROR;
+ }
+
+ // Append the file to the filelist
+ r = pakfire_filelist_append(list, file);
+ if (r) {
+ pakfire_file_unref(file);
+ goto ERROR;
+ }
+
+ // Cleanup
+ pakfire_file_unref(file);
+ }
+
+ // Reference the filelist
+ *filelist = pakfire_filelist_ref(list);
+
+ERROR:
+ if (list)
+ pakfire_filelist_unref(list);
+
+ return r;
+}
+
static int pakfire_archive_make_package_from_json(struct pakfire_archive* archive,
struct pakfire_repo* repo, struct pakfire_package** package) {
+ struct pakfire_filelist* filelist = NULL;
int r;
// Calculate digest
}
}
+ // Fetch the filelist
+ r = pakfire_archive_make_filelist_from_json(archive, &filelist);
+ if (r)
+ goto ERROR;
+
+ // Store the filelist
+ if (filelist) {
+ r = pakfire_package_set_filelist(pkg, filelist);
+ if (r)
+ goto ERROR;
+ }
+
// Success!
*package = pkg;
- return 0;
+ r = 0;
ERROR:
+ if (filelist)
+ pakfire_filelist_unref(filelist);
+
return r;
}