return r;
}
+static int __pakfire_package_add_build_packages(struct pakfire* pakfire,
+ struct pakfire_package* pkg, void* p) {
+ struct json_object* object = (struct json_object*)p;
+ int r;
+
+ const char* name = pakfire_package_get_string(pkg, PAKFIRE_PKG_NAME);
+ const char* evr = pakfire_package_get_string(pkg, PAKFIRE_PKG_EVR);
+
+ if (!name || !evr) {
+ ERROR(pakfire, "Could not fetch package information: %m\n");
+ return 1;
+ }
+
+ // Add package information to the list
+ r = pakfire_json_add_string(pakfire, object, name, evr);
+ if (r) {
+ ERROR(pakfire, "Could not add package to packages list: %m\n");
+ return r;
+ }
+
+ return 0;
+}
+
+static int pakfire_package_add_build_packages(struct pakfire_package* pkg,
+ struct json_object* md) {
+ struct pakfire_repo* repo = NULL;
+ struct pakfire_packagelist* packages = NULL;
+ struct json_object* object = NULL;
+ int r;
+
+ // Create a new JSON array
+ object = json_object_new_object();
+ if (!object) {
+ ERROR(pkg->pakfire, "Could not create a new JSON object: %m\n");
+ r = 1;
+ goto ERROR;
+ }
+
+ // Fetch the installed repository
+ repo = pakfire_get_installed_repo(pkg->pakfire);
+ if (!repo) {
+ ERROR(pkg->pakfire, "Could not fetch the installed repository: %m\n");
+ r = 1;
+ goto ERROR;
+ }
+
+ // Fetch all installed packages
+ r = pakfire_repo_create_packagelist(repo, &packages);
+ if (r) {
+ ERROR(pkg->pakfire, "Could not fetch packages from installed repository: %m\n");
+ goto ERROR;
+ }
+
+ // Add all packages to the array
+ r = pakfire_packagelist_walk(packages, __pakfire_package_add_build_packages, object);
+ if (r)
+ goto ERROR;
+
+ // Add object
+ r = json_object_object_add(md, "packages", json_object_get(object));
+ if (r)
+ goto ERROR;
+
+ERROR:
+ if (packages)
+ pakfire_packagelist_unref(packages);
+ if (repo)
+ pakfire_repo_unref(repo);
+ if (object)
+ json_object_put(object);
+
+ return r;
+}
+
static int pakfire_package_add_build_metadata(struct pakfire_package* pkg,
struct json_object* md) {
int r;
goto ERROR;
}
+ // Build Packages
+ if (!pakfire_package_is_source(pkg)) {
+ r = pakfire_package_add_build_packages(pkg, object);
+ if (r)
+ goto ERROR;
+ }
+
// Add object
r = json_object_object_add(md, "build", object);
if (r)