]> git.ipfire.org Git - pakfire.git/commitdiff
transaction: Log any solving problems to the debug logger
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 23 Sep 2023 09:42:20 +0000 (09:42 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 23 Sep 2023 09:42:20 +0000 (09:42 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/transaction.c

index c172d67eea325646b91199b6049f0be21ccd81df..765ceb7a05b05938684b6b61fba6e485795b40c6 100644 (file)
@@ -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;
 }