return r;
}
+static int __pakfire_package_add_json_filelist(struct pakfire* pakfire,
+ struct pakfire_file* file, void* data) {
+ struct json_object* filelist = (struct json_object*)data;
+ int r = 1;
+
+ // Fetch the file path
+ const char* path = pakfire_file_get_path(file);
+
+ // Create a new JSON string
+ struct json_object* object = json_object_new_string(path);
+ if (!object)
+ goto ERROR;
+
+ // Append the string
+ r = json_object_array_add(filelist, object);
+ if (r)
+ goto ERROR;
+
+ return 0;
+
+ERROR:
+ // Free JSON string
+ if (object)
+ json_object_put(object);
+
+ return r;
+}
+
+static int pakfire_package_add_json_filelist(
+ struct pakfire_package* pkg, struct json_object* md) {
+ struct pakfire_filelist* filelist = NULL;
+ struct json_object* object = NULL;
+ int r;
+
+ // Fetch the filelist
+ filelist = pakfire_package_get_filelist(pkg);
+ if (!filelist) {
+ ERROR(pkg->pakfire, "Could not fetch package filelist\n");
+ r = 1;
+ goto ERROR;
+ }
+
+ // Create a new JSON array
+ object = json_object_new_array();
+ if (!object) {
+ ERROR(pkg->pakfire, "Could not create a JSON array\n");
+ r = 1;
+ goto ERROR;
+ }
+
+ // Walk through the filelist
+ r = pakfire_filelist_walk(filelist, __pakfire_package_add_json_filelist, object);
+ if (r)
+ goto ERROR;
+
+ // Add object
+ r = json_object_object_add(md, "filelist", object);
+ if (r)
+ goto ERROR;
+
+ERROR:
+ // Free JSON object on error
+ if (r)
+ json_object_put(object);
+ if (filelist)
+ pakfire_filelist_unref(filelist);
+
+ return r;
+}
+
static int pakfire_package_add_build_metadata(struct pakfire_package* pkg,
struct json_object* md) {
int r;
if (r)
goto ERROR;
+ // Generate filelist
+ r = pakfire_package_add_json_filelist(pkg, md);
+ if (r)
+ goto ERROR;
+
// Generate build metadata
r = pakfire_package_add_build_metadata(pkg, md);
if (r)