]> git.ipfire.org Git - pakfire.git/commitdiff
repo: Optionally return the package object when importing archives
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 30 Jan 2025 10:54:50 +0000 (10:54 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 30 Jan 2025 10:54:50 +0000 (10:54 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/cli/lib/build.c
src/pakfire/build.c
src/pakfire/repo.c
src/pakfire/repo.h

index 56b984ad9c9f7d79f92c99820417f24e56f51200..cbd6aed9df16026bad1b13104de0cc7f16fb453f 100644 (file)
@@ -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));
index 9f29e0ecd09c87fb9a547c6bfa3432261e397455..394093e1f2f5369f432577b480201e61c9b535b5 100644 (file)
@@ -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;
 
index 554332869bdb9ae1c15712bc5e296e8bd2b4f992..97e729d22afda95019bd1cd301e01156af35ad96 100644 (file)
@@ -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;
index 542f1ac6d65a5918e8bfce803697d7d6b0e28775..5be0d72e676c34c8a59912b06ca47730034be67b 100644 (file)
@@ -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);