#include <pakfire/packager.h>
#include <pakfire/parser.h>
#include <pakfire/private.h>
+#include <pakfire/problem.h>
#include <pakfire/repo.h>
#include <pakfire/request.h>
#include <pakfire/scriptlet.h>
#include <pakfire/snapshot.h>
+#include <pakfire/solution.h>
#include <pakfire/string.h>
#include <pakfire/util.h>
return r;
}
+static int pakfire_build_install_package(struct pakfire* pakfire,
+ struct pakfire_package* pkg, void* p) {
+ struct pakfire_request* request = (struct pakfire_request*)p;
+
+ return pakfire_request_install_package(request, pkg);
+}
+
+static int pakfire_build_install_test(struct pakfire_build* build) {
+ struct pakfire_request* request = NULL;
+ struct pakfire_problem* problem = NULL;
+ struct pakfire_solution* solution = NULL;
+ const char* s = NULL;
+ int r;
+
+ // Create a new request
+ r = pakfire_request_create(&request, build->pakfire, 0);
+ if (r)
+ goto ERROR;
+
+ // Add all packages
+ r = pakfire_packagelist_walk(build->packages, pakfire_build_install_package, request);
+
+ // Solve the request
+ r = pakfire_request_solve(request, NULL, NULL);
+ switch (r) {
+ // All okay
+ case 0:
+ break;
+
+ // Dependency Error
+ case 2:
+ ERROR(build->pakfire, "Install test failed:\n");
+
+ // Walk through all problems
+ for (;;) {
+ r = pakfire_request_next_problem(request, &problem);
+ if (r)
+ goto ERROR;
+
+ // There are no more problems
+ if (!problem)
+ break;
+
+ // Format the problem into something human-readable
+ s = pakfire_problem_to_string(problem);
+ if (!s)
+ continue;
+
+ ERROR(build->pakfire, " * %s\n", s);
+
+ // Walk through all solutions
+ for (;;) {
+ r = pakfire_problem_next_solution(problem, &solution);
+ if (r)
+ goto ERROR;
+
+ // There are no more solutions
+ if (!solution)
+ break;
+
+ // Format the solution into something human-readable
+ s = pakfire_solution_to_string(solution);
+ if (!s)
+ continue;
+
+ ERROR(build->pakfire, " * %s\n", s);
+ }
+ }
+
+ break;
+
+ // Any other errors
+ default:
+ goto ERROR;
+ }
+
+ERROR:
+ if (r)
+ ERROR(build->pakfire, "Install test failed: %m\n");
+ if (request)
+ pakfire_request_unref(request);
+ if (problem)
+ pakfire_problem_unref(problem);
+ if (solution)
+ pakfire_solution_unref(solution);
+
+ return r;
+}
+
static int pakfire_build_post_check(struct pakfire_build* build) {
int r;
if (r)
return r;
-#if 0
// Perform install test
r = pakfire_build_install_test(build);
if (r)
return r;
-#endif
return 0;
}