Skip to content

Commit

Permalink
brp-remove-la-files: Remove symlinks, too
Browse files Browse the repository at this point in the history
As we check for file contents delete symlink before looking at regular
files.

Resolves: #3304
  • Loading branch information
ffesti committed Sep 18, 2024
1 parent c8ceb9b commit 4936c42
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
12 changes: 9 additions & 3 deletions scripts/brp-remove-la-files
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ set(TESTSUITE_AT
rpmconfig.at
rpmconfig2.at
rpmconfig3.at
rpmbrp.at
)

FILE(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/rpmtests.at)
Expand Down
28 changes: 28 additions & 0 deletions tests/rpmbrp.at
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4936c42

Please sign in to comment.