Skip to content

Commit

Permalink
Fix brp-strip when using regex-unsafe build root
Browse files Browse the repository at this point in the history
By default, the build root contains NAME-VERSION-RELEASE.ARCH. Some of these
may contain characters that are not taken as plain characters when interpreting
a regex, such as "." or "+".

This may lead to a situation where files are not stripped, because the find
command interpreted part of the supposed $RPM_BUILD_ROOT as part of a regex.

To fix this, first change to the build root directory, and run the find command
relative to that directory, ensuring we don't have to make the build root part
of the regex.

Co-authored-by: Lars Ellenberg <[email protected]>
  • Loading branch information
WanzenBug and lge committed Dec 16, 2024
1 parent f9f124a commit 74f0ab4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions scripts/brp-strip
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ strip_elf_binaries()
local nlinks="${1}"
local nprocs="${2}"

find "$RPM_BUILD_ROOT" -type f \
! -regex "${RPM_BUILD_ROOT}/*usr/lib/debug.*" \
cd "$RPM_BUILD_ROOT" || return 0
find . -type f \
! -regex '\./usr/lib/debug.*' \
! -name "*.py" ! -name "*.js" ! -name "*.rb" \
! -name "*.go" -links "${nlinks}" -print0 | \
xargs -0 -r -P${nprocs} -n${MAX_ARGS} sh -c "file \"\$@\" | \
Expand Down
3 changes: 2 additions & 1 deletion scripts/brp-strip-static-archive
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ Darwin*) exit 0 ;;
esac

# Strip static libraries.
find "$RPM_BUILD_ROOT" -type f \! -regex "${RPM_BUILD_ROOT}/*usr/lib/debug.*" -print0 | \
cd "$RPM_BUILD_ROOT" || exit 0
find . -type f \! -regex '\./usr/lib/debug.*' -print0 | \
xargs -0 -r -P$NCPUS -n32 sh -c "file \"\$@\" | sed 's/: */: /' | grep 'current ar archive' | sed -n -e 's/^\(.*\):[ ]*current ar archive/\1/p' | xargs -d '\n' -I\{\} $STRIP -g \{\}" ARG0

0 comments on commit 74f0ab4

Please sign in to comment.