From 0f0ce909a21d7b9ae9b5a82b3eedefa3813d7891 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 16 Feb 2025 15:15:01 +0000 Subject: [PATCH] build: Fix check for BUILDROOT The actual variable was not reachable which is changed in this patch. Signed-off-by: Michael Tremer --- src/pakfire/build.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/pakfire/build.c b/src/pakfire/build.c index 77f27349..e3081938 100644 --- a/src/pakfire/build.c +++ b/src/pakfire/build.c @@ -1369,6 +1369,13 @@ enum { PAKFIRE_BUILD_SHOW_PROGRESS = (1 << 2), }; +struct pakfire_build_post_process_state { + struct pakfire_build* build; + + // Filelist with files to remove + struct pakfire_filelist* removees; +}; + /* This helper function takes a callback which is expected to add any files to the given filelist which will optionally be all removed after. @@ -1384,8 +1391,13 @@ static int pakfire_build_post_process_files(struct pakfire_build* build, if (r) goto ERROR; + struct pakfire_build_post_process_state state = { + .build = build, + .removees = removees, + }; + // Find all files that need to be removed - r = pakfire_filelist_walk(filelist, callback, removees, + r = pakfire_filelist_walk(filelist, callback, &state, (flags & PAKFIRE_BUILD_SHOW_PROGRESS) ? PAKFIRE_FILELIST_SHOW_PROGRESS : 0, NULL); if (r) goto ERROR; @@ -1423,7 +1435,7 @@ ERROR: static int __pakfire_build_remove_static_libraries( struct pakfire_ctx* ctx, struct pakfire_file* file, void* data) { - struct pakfire_filelist* removees = (struct pakfire_filelist*)data; + const struct pakfire_build_post_process_state* state = data; char path[PATH_MAX]; int r; @@ -1441,7 +1453,7 @@ static int __pakfire_build_remove_static_libraries( // Only delete if there is a shared object with the same name if (pakfire_path_exists(path)) - return pakfire_filelist_add(removees, file); + return pakfire_filelist_add(state->removees, file); } return 0; @@ -1457,11 +1469,11 @@ static int pakfire_build_post_remove_static_libraries( static int __pakfire_build_remove_libtool_archives( struct pakfire_ctx* ctx, struct pakfire_file* file, void* data) { - struct pakfire_filelist* removees = (struct pakfire_filelist*)data; + const struct pakfire_build_post_process_state* state = data; // Find all libtool archive files if (pakfire_file_matches(file, "**.la")) - return pakfire_filelist_add(removees, file); + return pakfire_filelist_add(state->removees, file); return 0; } @@ -1476,14 +1488,14 @@ static int pakfire_build_post_remove_libtool_archives( static int __pakfire_build_check_broken_symlinks( struct pakfire_ctx* ctx, struct pakfire_file* file, void* data) { - struct pakfire_filelist* broken = (struct pakfire_filelist*)data; + const struct pakfire_build_post_process_state* state = data; int r; // Ignore anything that isn't a symlink switch (pakfire_file_get_type(file)) { case S_IFLNK: if (!pakfire_file_symlink_target_exists(file)) { - r = pakfire_filelist_add(broken, file); + r = pakfire_filelist_add(state->removees, file); if (r) return r; } @@ -1532,7 +1544,7 @@ static int pakfire_build_fix_script_interpreter( static int pakfire_build_check_buildroot( struct pakfire_ctx* ctx, struct pakfire_file* file, void* data) { - struct pakfire_filelist* broken = (struct pakfire_filelist*)data; + const struct pakfire_build_post_process_state* state = data; int r; // Skip Python byte-code files @@ -1546,16 +1558,13 @@ static int pakfire_build_check_buildroot( else if (pakfire_file_matches(file, "**.packlist")) return 0; -#warning We actually need to access the real buildroot here - const char* buildroot = "/var/tmp/pakfire-buildroot"; - // Check if the file contains the pattern - r = pakfire_file_contains(file, buildroot, -1); + r = pakfire_file_contains(file, state->build->buildroot, -1); if (r <= 0) return r; // The file contains the pattern, let's list it as broken - r = pakfire_filelist_add(broken, file); + r = pakfire_filelist_add(state->removees, file); if (r < 0) return r; -- 2.39.5