aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2006-01-13 07:58:05 +0000
committerMike Frysinger <vapier@gentoo.org>2006-01-13 07:58:05 +0000
commit2ef74a4c8dd1ef5dab77264c7a9f2d85a3d5fb19 (patch)
treec089bfd93e09622dfefa5f53661335f800151f75 /bin/prepstrip
parentdon't inline code, do __name__=="__main__" so the module can be used instead ... (diff)
downloadportage-2ef74a4c8dd1ef5dab77264c7a9f2d85a3d5fb19.tar.gz
portage-2ef74a4c8dd1ef5dab77264c7a9f2d85a3d5fb19.tar.bz2
portage-2ef74a4c8dd1ef5dab77264c7a9f2d85a3d5fb19.zip
clean up coding style/quoting, figure out what objdump to run same as strip, and add support for STRIP_MASK
svn path=/main/trunk/; revision=2561
Diffstat (limited to 'bin/prepstrip')
-rwxr-xr-xbin/prepstrip52
1 files changed, 33 insertions, 19 deletions
diff --git a/bin/prepstrip b/bin/prepstrip
index f93fe9eaa..2cff7a42b 100755
--- a/bin/prepstrip
+++ b/bin/prepstrip
@@ -3,13 +3,17 @@
# Distributed under the terms of the GNU General Public License v2
# $Id: /var/cvsroot/gentoo-src/portage/bin/prepstrip,v 1.23.2.3 2005/08/15 02:58:20 vapier Exp $
-if [ "${FEATURES//*nostrip*/true}" == "true" ] || [ "${RESTRICT//*nostrip*/true}" == "true" ] ; then
- echo "nostrip"
+if [[ " ${FEATURES} " == *" nostrip "* ]] || \
+ [[ " ${RESTRICT} " == *" nostrip "* ]] || \
+ [[ " ${RESTRICT} " == *" strip "* ]]
+then
exit 0
fi
-STRIP="${STRIP:-${CHOST}-strip}"
+STRIP=${STRIP:-${CHOST}-strip}
type -p -- ${STRIP} > /dev/null || STRIP=strip
+OBJCOPY=${OBJCOPY:-${CHOST}-objcopy}
+type -p -- ${OBJCOPY} > /dev/null || OBJCOPY=objcopy
PORTAGE_STRIP_FLAGS=${PORTAGE_STRIP_FLAGS:---strip-unneeded}
@@ -19,42 +23,52 @@ save_elf_debug() {
local x=$1
local y="${D}/usr/lib/debug/${x:${#D}:${#x}}"
- [ "${FEATURES//*splitdebug*/true}" != "true" ] && return 0
+ [[ " ${FEATURES} " != *" splitdebug "* ]] && return 0
# dont save debug info twice.
- [ "${x:7}" == ".debug" ] && return 0
+ [[ ${x:7} == ".debug" ]] && return 0
- mkdir -p $(dirname ${y})
- ${CHOST}-objcopy --only-keep-debug ${x} ${y}.debug
- ${CHOST}-objcopy --add-gnu-debuglink=${y}.debug ${x}
+ mkdir -p $(dirname "${y}")
+ ${OBJCOPY} --only-keep-debug ${x} ${y}.debug
+ ${OBJCOPY} --add-gnu-debuglink=${y}.debug ${x}
- [ "${FEATURES//*installsources*/true}" != "true" ] && return 0
+ [[ " ${FEATURES} " != *" installsources "* ]] && return 0
- if [ -x /usr/bin/debugedit ] ; then
- debugedit -b ${WORKDIR} -d /usr/src/debug/${P} -l ${T}/debug.sources "$x"
- if [ -s ${T}/debug.sources ]; then
- [ -d ${D}/usr/src/debug/${P} ] || mkdir -p ${D}/usr/src/debug/${P}
- cat ${T}/debug.sources | (cd ${WORKDIR}; LANG=C sort -z -u | xargs -0 -- cp --parents -p --target-directory="${D}/usr/src/debug/${P}" )
+ if [[ -x "/usr/bin/debugedit" ]] ; then
+ debugedit -b "${WORKDIR}" -d /usr/src/debug/${PF} -l "${T}"/debug.sources "${x}"
+ if [[ -s ${T}/debug.sources ]] ; then
+ [[ -d ${D}/usr/src/debug/${P} ]] || mkdir -p "${D}/usr/src/debug/${PF}"
+ cat "${T}"/debug.sources | (cd "${WORKDIR}"; LANG=C sort -z -u | xargs -0 -- cp --parents -p --target-directory="${D}/usr/src/debug/${P}" )
fi
fi
}
-for x in $(scanelf -yRBF%F "$@") $(for y in "$@"; do find $y -type f -name '*.a' -print0 ; done); do
- if [ ${banner} -eq 1 ] ; then
+for x in $(scanelf -yRBF%F "$@") $(for y in "$@"; do find "${y}" -type f -name '*.a' -print0 ; done); do
+ if [[ ${banner} -eq 1 ]] ; then
echo "strip: ${STRIP} ${PORTAGE_STRIP_FLAGS}"
banner=0
fi
f=$(file "${x}") || continue
- [ -z "${f}" ] && continue
+ [[ -z ${f} ]] && continue
+
+ # The noglob funk is to support STRIP_MASK="/*/booga" and to keep
+ # the for loop from expanding the globs.
+ # The eval echo is to support STRIP_MASK="/*/{booga,bar}" sex.
+ set -o noglob
+ skipstrip=0
+ for m in $(eval echo ${STRIP_MASK}) ; do
+ [[ ${x} == ${m} ]] && skipstrip=1 && break
+ done
+ set +o noglob
if [[ ${f} == *"current ar archive"* ]] ; then
echo " ${x:${#D}:${#x}}"
- ${STRIP} -g "${x}"
+ [[ ${skipstrip} -eq 1 ]] && ${STRIP} -g "${x}"
fi
if [[ ${f} == *"SB executable"* || ${f} == *"SB shared object"* ]] ; then
echo " ${x:${#D}:${#x}}"
save_elf_debug "${x}"
- ${STRIP} ${PORTAGE_STRIP_FLAGS} "${x}"
+ [[ ${skipstrip} -eq 1 ]] && ${STRIP} ${PORTAGE_STRIP_FLAGS} "${x}"
fi
done