]> git.ipfire.org Git - pakfire.git/commitdiff
build: Lint the archives after build
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 19 Oct 2024 15:07:22 +0000 (15:07 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 19 Oct 2024 15:07:22 +0000 (15:07 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/build.c

index f24d9eaadda8659b30ee65364a07572084656b7f..521d8069b8fe477d2a125766a547e637161c583f 100644 (file)
@@ -2063,6 +2063,34 @@ ERROR:
        return r;
 }
 
+static int pakfire_build_lint_package(
+               struct pakfire_ctx* ctx, struct pakfire_package* pkg, void* data) {
+       struct pakfire_archive* archive = NULL;
+       int r;
+
+       // Fetch the archive
+       archive = pakfire_package_get_archive(pkg);
+       if (!archive) {
+               r = -errno;
+               goto ERROR;
+       }
+
+       // Run the linter
+       r = pakfire_archive_lint(archive, NULL, NULL);
+       if (r < 0)
+               goto ERROR;
+
+ERROR:
+       if (archive)
+               pakfire_archive_unref(archive);
+
+       return r;
+}
+
+static int pakfire_build_lint(struct pakfire_build* build) {
+       return pakfire_packagelist_walk(build->packages, pakfire_build_lint_package, build);
+}
+
 PAKFIRE_EXPORT int pakfire_build_exec(struct pakfire_build* build, const char* path) {
        struct pakfire_package* package = NULL;
        struct pakfire_parser* makefile = NULL;
@@ -2152,6 +2180,11 @@ PAKFIRE_EXPORT int pakfire_build_exec(struct pakfire_build* build, const char* p
        if (r)
                goto ERROR;
 
+       // Lint the packages
+       r = pakfire_build_lint(build);
+       if (r < 0)
+               goto ERROR;
+
        // Copy packages to their destination
        r = pakfire_build_copy_packages(build);
        if (r)