]> git.ipfire.org Git - pakfire.git/commitdiff
linter: Base this on archives rather than packages
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 19 Oct 2024 13:58:04 +0000 (13:58 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 19 Oct 2024 13:58:04 +0000 (13:58 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/include/pakfire/linter.h
src/libpakfire/linter.c

index abe09f97c0bb78517a49326398055c92e84d43c1..cbc9b3d729649d5928fce2641992c00e36a941c5 100644 (file)
 #ifndef PAKFIRE_LINTER_H
 #define PAKFIRE_LINTER_H
 
+#include <pakfire/archive.h>
 #include <pakfire/ctx.h>
-#include <pakfire/package.h>
 
 struct pakfire_linter;
 
 int pakfire_linter_create(struct pakfire_linter** linter,
-       struct pakfire_ctx* ctx, struct pakfire_package* pkg);
+       struct pakfire_ctx* ctx, struct pakfire_archive* archive);
 
 struct pakfire_linter* pakfire_linter_ref(struct pakfire_linter* linter);
 struct pakfire_linter* pakfire_linter_unref(struct pakfire_linter* linter);
index 0b2d37f40b2a386f716eab583ccff34dc55461cf..204b18b8d7165d77aec3a8180b83834e1f9eabf6 100644 (file)
@@ -21,6 +21,7 @@
 #include <errno.h>
 #include <stdlib.h>
 
+#include <pakfire/archive.h>
 #include <pakfire/linter.h>
 #include <pakfire/logging.h>
 #include <pakfire/package.h>
@@ -29,11 +30,16 @@ struct pakfire_linter {
        struct pakfire_ctx* ctx;
        int nrefs;
 
+       // Archive
+       struct pakfire_archive* archive;
+
        // Package
        struct pakfire_package* pkg;
 };
 
 static void pakfire_linter_free(struct pakfire_linter* linter) {
+       if (linter->archive)
+               pakfire_archive_unref(linter->archive);
        if (linter->pkg)
                pakfire_package_unref(linter->pkg);
        if (linter->ctx)
@@ -42,8 +48,9 @@ static void pakfire_linter_free(struct pakfire_linter* linter) {
 }
 
 int pakfire_linter_create(struct pakfire_linter** linter,
-               struct pakfire_ctx* ctx, struct pakfire_package* pkg) {
+               struct pakfire_ctx* ctx, struct pakfire_archive* archive) {
        struct pakfire_linter* l = NULL;
+       int r;
 
        // Allocate a new object
        l = calloc(1, sizeof(*l));
@@ -56,13 +63,25 @@ int pakfire_linter_create(struct pakfire_linter** linter,
        // Initialize reference counter
        l->nrefs = 1;
 
-       // Store the package
-       l->pkg = pakfire_package_ref(pkg);
+       // Store the archive
+       l->archive = pakfire_archive_ref(archive);
+
+       // Fetch the package
+       r = pakfire_archive_make_package(l->archive, NULL, &l->pkg);
+       if (r < 0) {
+               CTX_ERROR(l->ctx, "Could not open the package in %s: %s\n",
+                       pakfire_archive_get_path(l->archive), strerror(-r));
+               goto ERROR;
+       }
 
        // Return the pointer
-       *linter = l;
+       *linter = pakfire_linter_ref(l);
 
-       return 0;
+ERROR:
+       if (l)
+               pakfire_linter_unref(l);
+
+       return r;
 }
 
 struct pakfire_linter* pakfire_linter_ref(struct pakfire_linter* linter) {