return r;
}
+static int pakfire_build_install_source_package(
+ struct pakfire_build* build, struct pakfire_package* package) {
+ struct pakfire_request* request = NULL;
+ struct pakfire_transaction* transaction = NULL;
+ int r;
+
+ // Create a new request
+ r = pakfire_request_create(&request, build->pakfire, 0);
+ if (r)
+ goto ERROR;
+
+ // Add the package
+ r = pakfire_request_add_package(request, PAKFIRE_REQ_INSTALL, package,
+ PAKFIRE_REQUEST_ESSENTIAL);
+ if (r)
+ goto ERROR;
+
+ // Solve the request
+ r = pakfire_request_solve(request);
+ if (r)
+ goto ERROR;
+
+ // Fetch the transaction
+ r = pakfire_request_get_transaction(request, &transaction);
+ if (r)
+ goto ERROR;
+
+ // Set how many packages have been changed
+ const size_t changes = pakfire_transaction_count(transaction);
+
+ // Sanity check to see if we actually try to install anything
+ if (!changes) {
+ ERROR(build->pakfire, "The source package did not get installed\n");
+ r = 1;
+ goto ERROR;
+ }
+
+ // Run the transaction
+ r = pakfire_transaction_run(transaction, 0);
+ if (r)
+ goto ERROR;
+
+ERROR:
+ if (transaction)
+ pakfire_transaction_unref(transaction);
+ if (request)
+ pakfire_request_unref(request);
+
+ return r;
+}
+
PAKFIRE_EXPORT int pakfire_build_exec(struct pakfire_build* build, const char* path) {
struct pakfire_package* package = NULL;
struct pakfire_parser* makefile = NULL;
if (r)
goto ERROR;
- const char* packages[] = {
- path, NULL
- };
-
- // Install the package into the build environment
- r = pakfire_install(build->pakfire, 0, 0, packages, NULL, PAKFIRE_REQUEST_ESSENTIAL,
- NULL, NULL, NULL);
+ // Install the source package
+ r = pakfire_build_install_source_package(build, package);
if (r) {
- ERROR(build->pakfire, "Could not install %s\n", path);
+ ERROR(build->pakfire, "Could not install the source package: %m\n");
goto ERROR;
}