Imported Upstream version 4.14.1
[platform/upstream/rpm.git] / scripts / brp-strip-shared
1 #!/bin/sh
2 # Conectiva brp - strip shared libraries. Based on Red Hat's brp-strip.
3 # Thu Apr 20 - Guilherme Manika <gwm@conectiva.com.br>
4 #              Created file
5
6 if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
7         exit 0
8 fi
9
10 STRIP=${1:-strip}
11
12 case `uname -a` in
13 Darwin*) exit 0 ;;
14 *) ;;
15 esac
16
17 # Strip ELF shared objects
18 # Please note we don't restrict our search to executable files because
19 # our libraries are not (should not be, at least) +x.
20 for f in `find "$RPM_BUILD_ROOT" -type f -a -exec file {} \; | \
21         grep -v "^${RPM_BUILD_ROOT}/\?usr/lib/debug"  | \
22         grep ' shared object,' | \
23         sed -n -e 's/^\(.*\):[  ]*ELF.*, not stripped.*/\1/p'`; do
24         $STRIP --strip-unneeded "$f"
25 done