summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--binutils-config76
1 files changed, 50 insertions, 26 deletions
diff --git a/binutils-config b/binutils-config
index f7e03a7..bbb8f8d 100644
--- a/binutils-config
+++ b/binutils-config
@@ -1,13 +1,13 @@
#!/bin/bash
-# Copyright 1999-2007 Gentoo Foundation
+# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/binutils-config-1.9,v 1.10 2007/05/06 09:04:01 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/binutils-config-2,v 1.3 2011/04/03 21:44:42 vapier Exp $
# Format of /etc/env.d/binutils/:
# config-TARGET: CURRENT=version for TARGET
# TARGET-VER: has a TARGET and VER variable
-[[ -z ${ROOT} ]] && ROOT="/"
+: ${ROOT:=/}
[[ ${ROOT} != */ ]] && ROOT="${ROOT}/"
[[ ${ROOT} != /* ]] && ROOT="${PWD}${ROOT}"
@@ -45,6 +45,16 @@ For example: ${BRACKET}i686-pc-linux-gnu-2.15.92.0.2${NORMAL}
For more info, please see ${HILITE}binutils-config${NORMAL}(8).
USAGE_END
+
+ exit ${1:-1}
+}
+
+mv_if_diff() {
+ if cmp -s "$1" "$2" ; then
+ rm -f "$1"
+ else
+ mv -f "$1" "$2"
+ fi
}
switch_profile() {
@@ -60,8 +70,8 @@ switch_profile() {
fi
#
- # Older installs don't have 'FAKE_TARGETS' defined, so lets
- # update these env.d entries so that we don't force the poor
+ # Older installs don't have 'FAKE_TARGETS' defined, so lets
+ # update these env.d entries so that we don't force the poor
# user to re-emerge their binutils just for 1 envvar :/
#
if [[ ${FAKE_TARGETS-poor user} == "poor user" ]] ; then
@@ -82,7 +92,7 @@ switch_profile() {
#
# Generate binary symlinks
- # On systems that do 32bit/64bit, we need to fake an
+ # On systems that do 32bit/64bit, we need to fake an
# extra set of binary names (${FAKE_TARGETS})
#
BINPATH=""
@@ -118,7 +128,7 @@ switch_profile() {
#
# Generate library / ldscripts symlinks
#
- LIBPATH=${LIBPATH:-/usr/lib/binutils/${TARGET}/${VER}}
+ : ${LIBPATH:=/usr/lib/binutils/${TARGET}/${VER}}
cd "${ROOT}/${LIBPATH}" || exit 1
if [[ ${TARGET} == ${HOST} ]] ; then
dstlib=${ROOT}/usr/${HOST}/lib
@@ -132,7 +142,7 @@ switch_profile() {
rm -rf "${dstlib}/ldscripts" "${ROOT}/${BINPATH_LINKS}"/ldscripts
mkdir -p "${dstlib}"
ln -sf "${LIBPATH}/ldscripts" "${dstlib}"/ldscripts
- find -L "${dstlib}" -type l -exec rm {} \;
+ find -L "${dstlib}" -type l -exec rm {} +
for x in lib* ; do
ln -sf "${LIBPATH}/${x}" "${dstlib}/${x}"
done
@@ -149,7 +159,7 @@ switch_profile() {
ln -sf "${INCPATH}/${x}" "${ROOT}/usr/include/${x}"
done
else
- # Clean out old path
+ # Clean out old path -- cannot use '-exec {} +' syntax here
find . -type f -exec rm -f "${ROOT}/usr/${TARGET}/usr/include/{}" \;
rmdir "${ROOT}/usr/${TARGET}/usr/include" >& /dev/null
rmdir "${ROOT}/usr/${TARGET}/usr" >& /dev/null
@@ -162,17 +172,29 @@ switch_profile() {
#
if [[ ${TARGET} == ${HOST} ]] ; then
DATAPATH=/usr/share/binutils-data/${TARGET}/${VER}
- [[ -d ${DATAPATH}/man ]] && \
- echo "MANPATH=${DATAPATH}/man" > "${ROOT}"/etc/env.d/05binutils
- [[ -d ${DATAPATH}/info ]] && \
- echo "INFOPATH=${DATAPATH}/info" >> "${ROOT}"/etc/env.d/05binutils
+ local e="${ROOT}"/etc/env.d/05binutils
+ local ee="${e}.tmp"
+ rm -f "${ee}"
+ [[ -d ${DATAPATH}/man ]] && echo "MANPATH=${DATAPATH}/man" >> "${ee}"
+ [[ -d ${DATAPATH}/info ]] && echo "INFOPATH=${DATAPATH}/info" >> "${ee}"
# hmm, `ld` has this in SEARCH_DIR(), but ld.so does not ...
- echo "LDPATH=/usr/${TARGET}/lib" >> "${ROOT}"/etc/env.d/05binutils
+ if [[ -d ${ROOT}/etc/ld.so.conf.d ]] ; then
+ local l="${ROOT}"/etc/ld.so.conf.d/05binutils.conf
+ local ll="${l}.tmp"
+ echo "/usr/${TARGET}/lib" > "${ll}"
+ mv_if_diff "${ll}" "${l}"
+ else
+ echo "LDPATH=/usr/${TARGET}/lib" >> "${ee}"
+ fi
+ mv_if_diff "${ee}" "${e}"
fi
- eend 0
+ local c="${ENV_D}/config-${TARGET}"
+ local cc="${c}.tmp"
+ echo "CURRENT=${VER}" > "${cc}"
+ mv_if_diff "${cc}" "${c}"
- echo "CURRENT=${VER}" > "${ENV_D}/config-${TARGET}"
+ eend 0
#
# Regen env.d if need/can be
@@ -182,7 +204,7 @@ switch_profile() {
echo
ewarn "Please remember to run:"
echo
- ewarn " # source /etc/profile"
+ ewarn " # . /etc/profile"
echo
fi
@@ -207,7 +229,7 @@ uninstall_target() {
exit 1
fi
- rm -f "${ENV_D}"/config-${TARGET}
+ rm -f "${ENV_D}"/config-${TARGET} "${ROOT}"/etc/ld.so.conf.d/05binutils.conf
# XXX: we still leave behind FAKE_TARGETS in /usr/bin ...
for x in addr2line ar as c++filt elf2flt flthdr gprof ld ld.real \
@@ -225,10 +247,12 @@ uninstall_target() {
# Delete broken symlinks
local destdir="${ROOT}/usr/${HOST}/${TARGET}"
rm -f "${destdir}"/lib/ldscripts
- find -L "${destdir}"/lib -type l -exec rm {} \;
- rmdir "${destdir}"/lib "${destdir}" 2>/dev/null
- rmdir "${destdir}"/{bin,include,lib,usr} "${destdir}" 2>/dev/null
- rmdir "${ROOT}"/var/db/pkg/cross-${TARGET} 2>/dev/null
+ find -L "${destdir}"/lib -type l -exec rm {} +
+ rmdir \
+ "${destdir}"/{bin,include,lib,usr} \
+ "${destdir}" \
+ "${ROOT}"/var/db/pkg/cross-${TARGET} \
+ 2>/dev/null
rm -f "${ENV_D}"/${TARGET}-*
}
@@ -330,11 +354,11 @@ while [[ $# -gt 0 ]] ; do
fi
;;
-h|--help)
- usage
- exit 0
+ usage 0
;;
-V|--version)
- cvsver="$Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/binutils-config-1.9,v 1.10 2007/05/06 09:04:01 vapier Exp $"
+ unset Header
+ cvsver="$Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/binutils-config-2,v 1.3 2011/04/03 21:44:42 vapier Exp $"
cvsver=${cvsver##*binutils-config-}
bver=${cvsver%%,v *}
cvsver=${cvsver#* }
@@ -399,7 +423,7 @@ while [[ $# -gt 0 ]] ; do
esac
done
-[[ ${NEED_ACTION} == "yes" ]] && usage && exit 1
+[[ ${NEED_ACTION} == "yes" ]] && usage 1
[[ ${DEBUG} == "yes" ]] && set -x
[[ ${DOIT} != "list_profiles" ]] && set_HOST