]> git.ipfire.org Git - pakfire.git/commitdiff
builds: Install tools that are required to build a certain image
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 19 Jun 2023 15:42:57 +0000 (15:42 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 19 Jun 2023 15:42:57 +0000 (15:42 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/build.c

index ae3da46eb70787c29758e01996e8303277fb940f..963149e2112a39e07c8ee232e8312198a83169be 100644 (file)
@@ -2210,6 +2210,61 @@ ERROR:
        return r;
 }
 
+static int pakfire_build_mkimage_install_deps(struct pakfire_build* build,
+               const char* type) {
+       struct pakfire_request* request = NULL;
+       struct pakfire_transaction* transaction = NULL;
+       char requires[NAME_MAX];
+       int r;
+
+       // Format requires
+       r = pakfire_string_format(requires, "mkimage(%s)", type);
+       if (r)
+               goto ERROR;
+
+       // Create a new request
+       r = pakfire_request_create(&request, build->pakfire, 0);
+       if (r) {
+               ERROR(build->pakfire, "Could not create request: %m\n");
+               goto ERROR;
+       }
+
+       // Add requires to the request
+       r = pakfire_request_add(request, PAKFIRE_REQ_INSTALL, requires,
+               PAKFIRE_REQUEST_ESSENTIAL);
+       if (r) {
+               ERROR(build->pakfire, "Could not add '%s' to the request: %m\n", requires);
+               goto ERROR;
+       }
+
+       // Solve the request
+       r = pakfire_request_solve(request, 0);
+       if (r) {
+               ERROR(build->pakfire, "Could not solve the request\n");
+               goto ERROR;
+       }
+
+       // Fetch the transaction
+       r = pakfire_request_get_transaction(request, &transaction);
+       if (r) {
+               ERROR(build->pakfire, "Could not fetch the transaction: %m\n");
+               goto ERROR;
+       }
+
+       // Run the transaction
+       r = pakfire_transaction_run(transaction, 0);
+       if (r)
+               goto ERROR;
+
+ERROR:
+       if (request)
+               pakfire_request_unref(request);
+       if (transaction)
+               pakfire_transaction_unref(transaction);
+
+       return r;
+}
+
 static int pakfire_build_collect_packages(struct pakfire_build* build, const char* path) {
        struct pakfire_request* request = NULL;
        struct pakfire_transaction* transaction = NULL;
@@ -2339,6 +2394,11 @@ PAKFIRE_EXPORT int pakfire_build_mkimage(struct pakfire_build* build,
        if (r)
                goto ERROR;
 
+       // Install all dependencies
+       r = pakfire_build_mkimage_install_deps(build, type);
+       if (r)
+               goto ERROR;
+
        const char* args[] = {
                type,
                pakfire_relpath(build->pakfire, path),