return pakfire_string_set(build->target, target);
}
-static int pakfire_build_install_packages(struct pakfire_build* build,
- int* snapshot_needs_update) {
+static int pakfire_build_install_packages(
+ struct pakfire_build* build, int* snapshot_needs_update) {
+ struct pakfire_transaction* transaction = NULL;
+ char* problems = NULL;
int r;
- int changed = 0;
+ // Create a new transaction
+ r = pakfire_transaction_create(&transaction, build->pakfire, 0);
+ if (r)
+ goto ERROR;
- // Install everything
- r = pakfire_install(build->pakfire, 0, 0, PAKFIRE_BUILD_PACKAGES, NULL, 0,
- &changed, NULL, NULL);
- if (r) {
- ERROR(build->pakfire, "Could not install build dependencies: %m\n");
- return r;
+ // Install all build dependencies
+ for (const char** p = PAKFIRE_BUILD_PACKAGES; *p; p++) {
+ r = pakfire_transaction_request(transaction,
+ PAKFIRE_JOB_INSTALL, *p, PAKFIRE_JOB_ESSENTIAL);
+ if (r)
+ goto ERROR;
}
- // Mark snapshot as changed if new packages were installed
- if (changed)
- *snapshot_needs_update = 1;
+ // Also update everything that has already been installed
+ r = pakfire_transaction_request(transaction, PAKFIRE_JOB_SYNC, NULL, 0);
+ if (r)
+ goto ERROR;
- // Update everything
- r = pakfire_sync(build->pakfire, 0, 0, &changed, NULL, NULL);
+ // Solve the transaction
+ r = pakfire_transaction_solve(transaction, 0, &problems);
if (r) {
- ERROR(build->pakfire, "Could not update packages: %m\n");
- return r;
+ ERROR(build->pakfire, "Could not install build dependencies:\n%s\n", problems);
+ goto ERROR;
}
- // Has anything changed?
- if (changed)
+ // If there are changes, we have to update the snapshot
+ if (pakfire_transaction_count(transaction))
*snapshot_needs_update = 1;
- return 0;
+ // Run the transaction
+ r = pakfire_transaction_run(transaction);
+ if (r)
+ goto ERROR;
+
+ERROR:
+ if (transaction)
+ pakfire_transaction_unref(transaction);
+ if (problems)
+ free(problems);
+
+ return r;
}
/*