]> git.ipfire.org Git - pakfire.git/commitdiff
build: Remove extra step when installing any custom packages
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 8 Jan 2025 11:31:32 +0000 (11:31 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 8 Jan 2025 11:31:32 +0000 (11:31 +0000)
Since there is only one place where this happens, we can also add this
all to the existing large transaction.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/cli/lib/shell.c
src/pakfire/build.c
src/pakfire/build.h

index 8c5bfdc384e65ece1995b3f0f3c7abb2e9163e54..30609e59b29287a7e53eb16a6a890966c72d48ad 100644 (file)
@@ -114,15 +114,9 @@ int cli_shell(void* data, int argc, char* argv[]) {
        if (r < 0)
                goto ERROR;
 
-       // Install any additional packages
-       if (local_args.num_packages) {
-               r = pakfire_build_install(build, local_args.packages);
-               if (r)
-                       goto ERROR;
-       }
-
        // Run the command
-       r = pakfire_build_shell(build, (local_args.argc) ? local_args.argv : NULL);
+       r = pakfire_build_shell(build,
+               (local_args.argc) ? local_args.argv : NULL, local_args.packages);
 
 ERROR:
        if (build)
index b57a66e603d6b6a7dbb60f11e90d52775e564bc8..306c66f7472ef2cfd10a1c56eea901172a8673d0 100644 (file)
@@ -2286,7 +2286,7 @@ static int pakfire_build_perform(struct pakfire_build* build,
 ERROR:
        // Drop to a shell for debugging
        if (pakfire_build_has_flag(build, PAKFIRE_BUILD_INTERACTIVE))
-               pakfire_build_shell(build, NULL);
+               pakfire_build_shell(build, NULL, NULL);
 
        return r;
 }
@@ -2477,7 +2477,8 @@ ERROR:
        return r;
 }
 
-static int pakfire_build_init(struct pakfire_build* build, struct pakfire_package* package) {
+static int pakfire_build_init(struct pakfire_build* build,
+               struct pakfire_package* package, const char** packages) {
        struct pakfire_transaction* transaction = NULL;
        char* problems = NULL;
        int r;
@@ -2503,6 +2504,16 @@ static int pakfire_build_init(struct pakfire_build* build, struct pakfire_packag
                        goto ERROR;
        }
 
+       // Any custom packages
+       if (packages) {
+               for (const char** p = packages; *p; p++) {
+                       r = pakfire_transaction_request(transaction,
+                               PAKFIRE_JOB_INSTALL, *p, PAKFIRE_JOB_ESSENTIAL);
+                       if (r < 0)
+                               goto ERROR;
+               }
+       }
+
        // Also update everything that has already been installed
        r = pakfire_transaction_request(transaction, PAKFIRE_JOB_SYNC, NULL, 0);
        if (r)
@@ -2613,7 +2624,7 @@ int pakfire_build_exec(struct pakfire_build* build, const char* path) {
        }
 
        // Install everything we need and the source package, too
-       r = pakfire_build_init(build, package);
+       r = pakfire_build_init(build, package, NULL);
        if (r) {
                ERROR(build->ctx, "Could not install the source package: %m\n");
                goto ERROR;
@@ -2840,7 +2851,7 @@ int pakfire_build_mkimage(struct pakfire_build* build,
                goto ERROR;
 
        // Install all packages
-       r = pakfire_build_install(build, NULL);
+       r = pakfire_build_init(build, NULL, NULL);
        if (r)
                goto ERROR;
 
@@ -2907,52 +2918,14 @@ ERROR:
        return r;
 }
 
-int pakfire_build_install(struct pakfire_build* build, const char** packages) {
-       struct pakfire_transaction* transaction = NULL;
-       char* problems = NULL;
-       int r;
-
-       // Create a new transaction
-       r = pakfire_transaction_create(&transaction, build->pakfire, 0);
-       if (r)
-               goto ERROR;
-
-       // Install all packages
-       for (const char** p = packages; *p; p++) {
-               r = pakfire_transaction_request(transaction, PAKFIRE_JOB_INSTALL, *p, 0);
-               if (r)
-                       goto ERROR;
-       }
-
-       // Solve the transaction
-       r = pakfire_transaction_solve(transaction, 0, &problems);
-       if (r) {
-               ERROR(build->ctx, "Could not install packages:\n%s\n", problems);
-               goto ERROR;
-       }
-
-       // Run the transaction
-       r = pakfire_transaction_run(transaction);
-       if (r)
-               goto ERROR;
-
-ERROR:
-       if (transaction)
-               pakfire_transaction_unref(transaction);
-       if (problems)
-               free(problems);
-
-       return r;
-}
-
 /*
        Drops the user into a shell
 */
-int pakfire_build_shell(struct pakfire_build* build, const char* argv[]) {
+int pakfire_build_shell(struct pakfire_build* build, const char* argv[], const char** packages) {
        int r;
 
        // Initialize the build environment
-       r = pakfire_build_init(build, NULL);
+       r = pakfire_build_init(build, NULL, packages);
        if (r)
                return r;
 
index f77fa3799f55f2db4a9972cae6c8574741de36c9..920b4b7a3269994733cd3cbdd2702d0c24880f2a 100644 (file)
@@ -49,7 +49,7 @@ void pakfire_build_set_log_callback(struct pakfire_build* build,
 int pakfire_build_set_ccache_path(struct pakfire_build* build, const char* path);
 int pakfire_build_set_target(struct pakfire_build* build, const char* target);
 
-int pakfire_build_shell(struct pakfire_build* build, const char* argv[]);
+int pakfire_build_shell(struct pakfire_build* build, const char* argv[], const char** packages);
 
 int pakfire_build_exec(struct pakfire_build* build, const char* path);
 
@@ -58,6 +58,4 @@ int pakfire_build_mkimage(struct pakfire_build* build,
 
 int pakfire_build_clean(struct pakfire* pakfire, int flags);
 
-int pakfire_build_install(struct pakfire_build* build, const char** packages);
-
 #endif /* PAKFIRE_BUILD_H */