PAKFIRE_EXPORT int pakfire_transaction_solve(struct pakfire_transaction* transaction,
int flags, char** problems) {
+ char* p = NULL;
int solved = 0;
int r;
// Prepare pool
pakfire_pool_internalize(transaction->pakfire);
-#ifdef ENABLE_DEBUG
Pool* pool = pakfire_get_solv_pool(transaction->pakfire);
const char* selection = pool_selection2str(pool, &transaction->jobs, 0);
if (selection)
DEBUG(transaction->pakfire, "Solving: %s\n", selection);
-#endif
RETRY:
// Save time when we starting solving
solver_printallsolutions(transaction->solver);
#endif
- // Return the problems as string
- if (problems)
- *problems = pakfire_transaction_get_problem_string(transaction, flags);
+ // Fetch the reason why we could not solve the request
+ p = pakfire_transaction_get_problem_string(transaction, flags);
+
+ if (p) {
+ DEBUG(transaction->pakfire,
+ "Could not solve request: %s\n%s\n", selection, p);
+
+ // Return the problems
+ if (problems)
+ *problems = strdup(p);
+ }
// Ask the user to pick a solution
if (flags & PAKFIRE_REQ_SOLVE_INTERACTIVE) {
r = pakfire_ui_pick_solution(transaction->pakfire, transaction);
if (r)
- return r;
+ goto ERROR;
// Retry solving
goto RETRY;
// Return zero if solved, otherwise return non-zero
if (solved)
- return 0;
-
- return 2;
+ r = 0;
+ else
+ r = 2;
ERROR:
+ if (p)
+ free(p);
+
return r;
}