From: Michael Tremer Date: Fri, 29 Sep 2023 14:59:37 +0000 (+0000) Subject: build: Add implicit dist() when a makefile is passed X-Git-Tag: 0.9.30~1599 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=654035882d0a7e6657406e779bdb825f2df274e6;p=pakfire.git build: Add implicit dist() when a makefile is passed Signed-off-by: Michael Tremer --- diff --git a/src/cli/lib/build.c b/src/cli/lib/build.c index 328788865..2e739bcfa 100644 --- a/src/cli/lib/build.c +++ b/src/cli/lib/build.c @@ -168,8 +168,6 @@ int cli_build(struct pakfire* pakfire, int argc, char* argv[]) { // Process all packages for (int i = optind; i < argc; i++) { - // XXX implement dist - // Run the build r = pakfire_build_exec(build, argv[i]); if (r) { diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index 08a7fbb99..38776c1cd 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -1408,6 +1409,31 @@ struct pakfire_repo* pakfire_get_installed_repo(struct pakfire* pakfire) { return pakfire_repo_create_from_repo(pakfire, pakfire->pool->installed); } +/* + Convenience function to dist() a package on the fly +*/ +static int pakfire_commandline_dist(struct pakfire* pakfire, struct pakfire_repo* repo, + const char* path, struct pakfire_package** package) { + char* result = NULL; + int r; + + // XXX result is not unique! + + // Run dist() + r = pakfire_dist(pakfire, path, PAKFIRE_TMP_DIR, &result); + if (r) + goto ERROR; + + // Try to add the package to the repository + r = pakfire_repo_add(repo, result, package); + +ERROR: + if (result) + free(result); + + return r; +} + /* Convenience function to add a package to the @commandline repository */ @@ -1425,8 +1451,14 @@ int pakfire_commandline_add(struct pakfire* pakfire, const char* path, // Add the package r = pakfire_repo_add(repo, path, package); - if (r) - goto ERROR; + switch (-r) { + case ENOMSG: + r = pakfire_commandline_dist(pakfire, repo, path, package); + break; + + default: + goto ERROR; + } ERROR: if (repo)