From: Michael Tremer Date: Wed, 8 Jan 2025 11:31:32 +0000 (+0000) Subject: build: Remove extra step when installing any custom packages X-Git-Tag: 0.9.30~501 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=759e690192a5882a17ce74ac2e3ecbc11a3aa408;p=pakfire.git build: Remove extra step when installing any custom packages 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 --- diff --git a/src/cli/lib/shell.c b/src/cli/lib/shell.c index 8c5bfdc38..30609e59b 100644 --- a/src/cli/lib/shell.c +++ b/src/cli/lib/shell.c @@ -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) diff --git a/src/pakfire/build.c b/src/pakfire/build.c index b57a66e60..306c66f74 100644 --- a/src/pakfire/build.c +++ b/src/pakfire/build.c @@ -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; diff --git a/src/pakfire/build.h b/src/pakfire/build.h index f77fa3799..920b4b7a3 100644 --- a/src/pakfire/build.h +++ b/src/pakfire/build.h @@ -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 */