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 in /usr/lib/debug are stripped, making
them useless for debugging. This is because the command to strip debug
information interpreted part of the $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
2 people authored and ffesti committed Dec 16, 2024
1 parent f9f124a commit 0a8a0ed
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 0a8a0ed

Please sign in to comment.