From: Michael Tremer Date: Sat, 23 Sep 2023 09:42:20 +0000 (+0000) Subject: transaction: Log any solving problems to the debug logger X-Git-Tag: 0.9.30~1664 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a0e382d26295e49b3ef37b78bf652d9991da9cbd;p=pakfire.git transaction: Log any solving problems to the debug logger Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/transaction.c b/src/libpakfire/transaction.c index c172d67ee..765ceb7a0 100644 --- a/src/libpakfire/transaction.c +++ b/src/libpakfire/transaction.c @@ -558,6 +558,7 @@ Solver* pakfire_transaction_get_solver(struct pakfire_transaction* transaction) PAKFIRE_EXPORT int pakfire_transaction_solve(struct pakfire_transaction* transaction, int flags, char** problems) { + char* p = NULL; int solved = 0; int r; @@ -566,13 +567,11 @@ PAKFIRE_EXPORT int pakfire_transaction_solve(struct pakfire_transaction* transac // 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 @@ -612,15 +611,23 @@ RETRY: 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; @@ -640,11 +647,14 @@ 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; }