From 5154a58b73b773d36c54bfe9c7debb93f0d99648 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Tue, 17 Sep 2024 13:13:13 +0200 Subject: [PATCH] brp-remove-la-files: Remove symlinks, too As we check for file contents delete symlink before looking at regular files. Resolves: #3304 --- scripts/brp-remove-la-files | 12 +++++++++--- tests/CMakeLists.txt | 1 + tests/rpmbrp.at | 28 ++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 tests/rpmbrp.at diff --git a/scripts/brp-remove-la-files b/scripts/brp-remove-la-files index 58c513bf88..0e6e58f31a 100755 --- a/scripts/brp-remove-la-files +++ b/scripts/brp-remove-la-files @@ -5,6 +5,12 @@ if [ -z "$RPM_BUILD_ROOT" ] || [ "$RPM_BUILD_ROOT" = "/" ]; then exit 0 fi -find "$RPM_BUILD_ROOT" -type f -name '*.la' 2>/dev/null -print0 | - xargs -0 grep --fixed-strings '.la - a libtool library file' --files-with-matches --null | - xargs -0 rm --force +# Check and remove symlinks first then regular files +for FILETYPE in l f +do + + find "$RPM_BUILD_ROOT" -type $FILETYPE -name '*.la' 2>/dev/null -print0 | + xargs -0 grep --fixed-strings '.la - a libtool library file' --files-with-matches --null | + xargs -0 rm --force + +done diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1fcd3fa488..adc09aea98 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -51,6 +51,7 @@ set(TESTSUITE_AT rpmconfig.at rpmconfig2.at rpmconfig3.at + rpmbrp.at ) FILE(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/rpmtests.at) diff --git a/tests/rpmbrp.at b/tests/rpmbrp.at new file mode 100644 index 0000000000..0a688a89f6 --- /dev/null +++ b/tests/rpmbrp.at @@ -0,0 +1,28 @@ +# rpmbrp.at: rpm build root policy scripts tests + +AT_BANNER([RPM build root policy scripts]) + +# ------------------------------ +# Check brp-remove-la-files +AT_SETUP([brp-remove-la-files]) +AT_KEYWORDS([build brp]) +RPMTEST_CHECK([ +TD=/tmp/brp-remove-la-files + +runroot_other rm -rf $TD +runroot_other mkdir -p $TD +runroot_other echo ".la - a libtool library file" > $TD/test1.la +runroot_other echo ".la - a not libtool library file" > $TD/test2.la +runroot_other echo "other file" > $TD/test.txt +runroot_other ln -s test1.la $TD/test.la +runroot_other ln -s test2.la $TD/testfalse.la +runroot_other --setenv RPM_BUILD_ROOT $TD ${RPM_CONFIGDIR_PATH}/brp-remove-la-files +runroot_other ls -1 $TD/* +], +[0], +[/tmp/brp-remove-la-files/test.txt +/tmp/brp-remove-la-files/test2.la +/tmp/brp-remove-la-files/testfalse.la +], +[ignore]) +RPMTEST_CLEANUP