]> git.donarmstrong.com Git - debhelper.git/blob - dh_strip
r108: Initial Import
[debhelper.git] / dh_strip
1 #!/bin/sh -e
2 #
3 # Strip files.
4
5 PATH=debian:$PATH:/usr/lib/debhelper
6 . dh_lib
7
8 # This reads in a list of files, and excludes any that match what's in
9 # DH_EXCLUDE_GREP.
10 filelist_excluded () {
11         if [ "$DH_EXCLUDE_GREP" ]; then
12                 # Use grep -F so we don't have to worry about regexp's.
13                 grep -v -F "`(cd $TMP; echo "$DH_EXCLUDE_GREP" | tr "|" "\n")`"
14         else
15                 # Just pass all files through.
16                 cat
17         fi
18 }
19
20 for PACKAGE in $DH_DOPACKAGES; do
21         TMP=`tmpdir $PACKAGE`
22
23         # Handle executables and shared libraries.
24         for file in `(cd $TMP; find -type f \( -perm +111 -or -name "*.so*" \) 2>/dev/null) | filelist_excluded` ; do
25                 case "`file $TMP/$file`" in
26                         *ELF*shared*)
27                                 doit "strip --strip-unneeded $TMP/$file"
28                         ;;
29                         *ELF*executable*)
30                                 doit "strip --remove-section=.comment --remove-section=.note $TMP/$file"
31                         ;;
32                 esac
33         done
34
35         # Handle static libraries.
36         for file in `(cd $TMP; find -type f -name "lib*.a" 2>/dev/null) | filelist_excluded` ; do
37                 # Don't strip debug libraries.
38                 if ! expr "$file" : ".*_g\.a" >/dev/null ; then
39                         doit "strip --strip-debug $TMP/$file"
40                 fi
41         done
42 done