From 95fd3e751964c69f63572ed8a09483db20a80e93 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 19 Oct 2024 15:07:22 +0000 Subject: [PATCH] build: Lint the archives after build Signed-off-by: Michael Tremer --- src/libpakfire/build.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index f24d9eaad..521d8069b 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -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) -- 2.39.5