2002-10-05 02:45:05 +04:00
#!/bin/sh -ef
2002-03-25 23:37:46 +03:00
#
# strip_files - strip files helper.
#
2004-01-25 21:09:26 +03:00
# Copyright (C) 2000-2004 Dmitry V. Levin <ldv@altlinux.org>
2002-03-25 23:37:46 +03:00
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
2003-11-09 19:47:45 +03:00
. @RPMCONFIGDIR@/functions
ValidateBuildRoot
2002-03-25 23:37:46 +03:00
DoStrip()
{
f="$1"
shift
local opts=
2005-09-29 19:12:05 +04:00
[ -n "$STRIP_FORCED" ] || opts="-p -R .comment $*"
2002-03-25 23:37:46 +03:00
strip $opts $STRIP_FORCED_OPTS "$f"
}
2002-09-05 15:49:12 +04:00
rc=0
2002-03-25 23:37:46 +03:00
for f in "$@"; do
2002-09-05 15:49:12 +04:00
if [ ! -f "$f" ]; then
2003-11-09 19:47:45 +03:00
Info "$f: file unavailable"
2002-09-05 15:49:12 +04:00
rc=1
continue
fi
2002-12-30 02:33:01 +03:00
fname="${f#$RPM_BUILD_ROOT}"
fname="${fname#.}"
2002-09-27 17:41:26 +04:00
if [ -n "$RPM_STRIP_SKIPLIST" ]; then
for skip in $RPM_STRIP_SKIPLIST; do
2004-01-25 20:19:42 +03:00
if [ -z "${fname##$skip}" ]; then
2002-09-05 15:49:12 +04:00
continue 2
fi
done
fi
2002-03-25 23:37:46 +03:00
2008-02-27 19:29:33 +03:00
t="$(file -b "$f")"
2002-03-25 23:37:46 +03:00
if [ -z "${t/*ELF*executable,*/}" ]; then
if [ -n "$STRIP_EXECUTABLE" ]; then
DoStrip "$f"
fi
continue
fi
if [ -z "${t/*ELF*relocatable,*/}" ]; then
if [ -n "$STRIP_RELOCATABLE" ]; then
DoStrip "$f" --strip-unneeded
fi
continue
fi
if [ -z "${t/*ELF*shared object,*/}" ]; then
if [ -n "$STRIP_SHARED" ]; then
DoStrip "$f" --strip-unneeded
fi
continue
fi
if [ -z "${t/*current ar archive/}" ]; then
if [ -n "$STRIP_STATIC" ]; then
DoStrip "$f" --strip-unneeded
fi
continue
fi
done
2002-09-05 15:49:12 +04:00
exit $rc