From: Michael Tremer Date: Mon, 19 Sep 2022 19:15:47 +0000 (+0000) Subject: build: Abort if there are any unpackaged files X-Git-Tag: 0.9.28~298 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f9bb14d7af2e0b164eaf27307da0a0779c9b97b;p=pakfire.git build: Abort if there are any unpackaged files Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index e26a3f0a4..1b026d4ba 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -519,6 +519,7 @@ static int pakfire_build_package(struct pakfire_build* build, struct pakfire_par } INFO(build->pakfire, "Building package '%s'...\n", name); + DEBUG(build->pakfire, " buildroot = %s\n", buildroot); // Fetch build architecture const char* arch = pakfire_get_arch(build->pakfire); @@ -1220,6 +1221,60 @@ ERROR: return r; } +static int __pakfire_build_unpackaged_file(struct pakfire* pakfire, + struct pakfire_file* file, void* p) { + char* s = pakfire_file_dump(file); + if (s) + ERROR(pakfire, "%s\n", s); + + return 0; +} + +static int pakfire_build_check_unpackaged_files(struct pakfire_build* build) { + struct pakfire_filelist* filelist = NULL; + int r; + + // Create a new filelist + r = pakfire_filelist_create(&filelist, build->pakfire); + if (r) + goto ERROR; + + // Scan for all files in BUILDROOT + r = pakfire_filelist_scan(filelist, build->buildroot, NULL, NULL); + if (r) + goto ERROR; + + const size_t length = pakfire_filelist_size(filelist); + + if (length) { + ERROR(build->pakfire, "Unpackaged files found:\n"); + + r = pakfire_filelist_walk(filelist, __pakfire_build_unpackaged_file, NULL); + if (r) + goto ERROR; + + // Report an error + r = 1; + } + +ERROR: + if (filelist) + pakfire_filelist_unref(filelist); + + return r; +} + +static int pakfire_build_post_check(struct pakfire_build* build) { + int r; + + // Check for unpackaged files + r = pakfire_build_check_unpackaged_files(build); + if (r) + return r; + + return 0; +} + PAKFIRE_EXPORT int pakfire_build_exec(struct pakfire_build* build, const char* path) { struct pakfire_archive* archive = NULL; struct pakfire_package* package = NULL; @@ -1291,6 +1346,11 @@ PAKFIRE_EXPORT int pakfire_build_exec(struct pakfire_build* build, const char* p goto ERROR; } + // Perform post build checks + r = pakfire_build_post_check(build); + if (r) + goto ERROR; + ERROR: if (makefile) pakfire_parser_unref(makefile);