From: Michael Tremer Date: Thu, 30 Jan 2025 10:54:50 +0000 (+0000) Subject: repo: Optionally return the package object when importing archives X-Git-Tag: 0.9.30~272 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84337f753510335f3132974b9832fdfa007727f1;p=pakfire.git repo: Optionally return the package object when importing archives Signed-off-by: Michael Tremer --- diff --git a/src/cli/lib/build.c b/src/cli/lib/build.c index 56b984ad..cbd6aed9 100644 --- a/src/cli/lib/build.c +++ b/src/cli/lib/build.c @@ -162,7 +162,7 @@ static int result_callback(struct pakfire_ctx* ctx, struct pakfire* pakfire, // Fetch the local repository & import the archive local = pakfire_get_repo(pakfire, PAKFIRE_REPO_LOCAL); if (local) { - r = pakfire_repo_import_archive(local, archive); + r = pakfire_repo_import_archive(local, archive, NULL); if (r < 0) { ERROR(ctx, "Could not import %s to the local repository: %s\n", nevra, strerror(-r)); diff --git a/src/pakfire/build.c b/src/pakfire/build.c index 9f29e0ec..394093e1 100644 --- a/src/pakfire/build.c +++ b/src/pakfire/build.c @@ -1232,7 +1232,7 @@ static int pakfire_build_package(struct pakfire_build* build, struct pakfire_par goto ERROR; // Import the package into the repository - r = pakfire_repo_import_archive(build->repo, archive); + r = pakfire_repo_import_archive(build->repo, archive, NULL); if (r < 0) goto ERROR; diff --git a/src/pakfire/repo.c b/src/pakfire/repo.c index 55433286..97e729d2 100644 --- a/src/pakfire/repo.c +++ b/src/pakfire/repo.c @@ -427,7 +427,8 @@ int pakfire_repo_add_archive(struct pakfire_repo* repo, return pakfire_archive_make_package(archive, repo, package); } -int pakfire_repo_import_archive(struct pakfire_repo* self, struct pakfire_archive* archive) { +int pakfire_repo_import_archive(struct pakfire_repo* self, + struct pakfire_archive* archive, struct pakfire_package** package) { struct pakfire_package* pkg = NULL; const char* uuid = NULL; char relpath[PATH_MAX]; @@ -500,6 +501,10 @@ ERROR: // XXX REMOVE THE PACKAGE METDATA FROM THIS REPOSITORY END: + // Return the package if requested + if (package) + *package = pakfire_package_ref(pkg); + if (pkg) pakfire_package_unref(pkg); @@ -2133,7 +2138,7 @@ int pakfire_repo_compose(struct pakfire* pakfire, const char* path, } // Import the archive - r = pakfire_repo_import_archive(repo, archive); + r = pakfire_repo_import_archive(repo, archive, NULL); if (r < 0) { ERROR(ctx, "Could not import %s: %s\n", *file, strerror(-r)); goto OUT; diff --git a/src/pakfire/repo.h b/src/pakfire/repo.h index 542f1ac6..5be0d72e 100644 --- a/src/pakfire/repo.h +++ b/src/pakfire/repo.h @@ -121,7 +121,8 @@ Id pakfire_repo_add_solvable(struct pakfire_repo* repo); int pakfire_repo_add_archive(struct pakfire_repo* repo, struct pakfire_archive* archive, struct pakfire_package** package); -int pakfire_repo_import_archive(struct pakfire_repo* self, struct pakfire_archive* archive); +int pakfire_repo_import_archive(struct pakfire_repo* self, + struct pakfire_archive* archive, struct pakfire_package** package); int pakfire_repo_download_package(struct pakfire_xfer** xfer, struct pakfire_repo* repo, struct pakfire_package* pkg);