- update to elfutils-0.56.
[platform/upstream/rpm.git] / scripts / brp-strip-comment-note
1 #!/bin/sh
2 # If using normal root, avoid changing anything.
3 if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
4         exit 0
5 fi
6
7 # Strip .comment and .note sections (the latter only if it is not allocated)
8 # for already stripped elf files in the build root
9 for f in `find $RPM_BUILD_ROOT -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 \) -exec file {} \; | \
10         grep -v "^${RPM_BUILD_ROOT}/\?usr/lib/debug"  | \
11         sed -n -e 's/^\(.*\):[  ]*ELF.*, stripped/\1/p'`; do
12         note="-R .note"
13         if objdump -h $f | grep '^[     ]*[0-9]*[       ]*.note[        ]' -A 1 | \
14                 grep ALLOC >/dev/null; then
15                 note=
16         fi
17         strip -R .comment $note $f || :
18 done