summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-08-29 00:56:46 +0000
committerMike Frysinger <vapier@gentoo.org>2011-08-29 00:56:46 +0000
commit2d794b803f24686d91375b1917a8c3cb88f1d72a (patch)
tree02b3419b3d5ba463f3c572f6c4ee47701faa5773
parentNew package for bug 377565 (diff)
downloadhistorical-2d794b803f24686d91375b1917a8c3cb88f1d72a.tar.gz
historical-2d794b803f24686d91375b1917a8c3cb88f1d72a.tar.bz2
historical-2d794b803f24686d91375b1917a8c3cb88f1d72a.zip
Make profile switching more atomic #380759.
Package-Manager: portage-2.2.0_alpha51/cvs/Linux x86_64
-rw-r--r--sys-devel/binutils-config/ChangeLog5
-rw-r--r--sys-devel/binutils-config/Manifest10
-rwxr-xr-xsys-devel/binutils-config/files/binutils-config-346
3 files changed, 42 insertions, 19 deletions
diff --git a/sys-devel/binutils-config/ChangeLog b/sys-devel/binutils-config/ChangeLog
index 58e5d0b03297..6e07f87515e6 100644
--- a/sys-devel/binutils-config/ChangeLog
+++ b/sys-devel/binutils-config/ChangeLog
@@ -1,6 +1,9 @@
# ChangeLog for sys-devel/binutils-config
# Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/ChangeLog,v 1.48 2011/08/23 16:09:21 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/ChangeLog,v 1.49 2011/08/29 00:56:45 vapier Exp $
+
+ 29 Aug 2011; Mike Frysinger <vapier@gentoo.org> files/binutils-config-3:
+ Make profile switching more atomic #380759.
23 Aug 2011; Mike Frysinger <vapier@gentoo.org> files/binutils-config-3:
Make sure all the profile specs still work after previous rework.
diff --git a/sys-devel/binutils-config/Manifest b/sys-devel/binutils-config/Manifest
index faf48d2c52ec..e9ab9f8dfb40 100644
--- a/sys-devel/binutils-config/Manifest
+++ b/sys-devel/binutils-config/Manifest
@@ -3,17 +3,17 @@ Hash: SHA256
AUX binutils-config-1.9 11043 RMD160 6f7f95d0c4719d747acb939441e9247e9705d98d SHA1 2f801cb2f4bf167207407d0a3e6481e01a1317b8 SHA256 20becd27cd1161d3afcd079ebff883b8eba3e698171937d82a9575dfa19a2373
AUX binutils-config-2 11440 RMD160 fdb4906f1a9d0fc3f18d450583ce7a5bd72f6068 SHA1 38d11d772da3aeef242d3c67d8b41e2e71d8544b SHA256 5e923d1445910b9b9d1e455e52313087098689359846db0dc3fa52d33b63b192
-AUX binutils-config-3 13114 RMD160 5c44a385eca8446eecedfb2cd38590e861d07308 SHA1 77a0795c77fa68f2ab6c4cc1876b4e007eb5a451 SHA256 53030f8a4782e6e9c01110767b4b1aae522d228a642773c520f705b5ce910e70
+AUX binutils-config-3 13820 RMD160 65ae330994fb66b1da0413c399b5f8de28717fec SHA1 35677db03178e471d8620e2618423214e412de5f SHA256 bd0cd956b74434081ce5ce2738a7cc301a0f80e4fa6fe957414496771c6cb365
AUX binutils-config.8 4113 RMD160 7eea52f777b889b08b58e6d836de187e9505be8b SHA1 e97d7ca363524bbfb3c8cf8e17c5775dc6236be7 SHA256 ec7cb82331c80e15581e0936a5bf5edb3cde78bec3c3ede647926821086a1e6f
EBUILD binutils-config-1.9-r4.ebuild 626 RMD160 e3018b7b6f690abddde9e2a25ce8a727dfcf14d0 SHA1 dd3547d1bbe52d600e3f59b9a45e806a327ea070 SHA256 4445f3282acda5b7c96146974adefc47315c437b5eb008daab9ac5f87a18d99d
EBUILD binutils-config-2-r1.ebuild 627 RMD160 aa041873d7910e368022522fe1281af8cc16d2ad SHA1 2469140bb41e5ba03e85d4326194587e83701644 SHA256 06d97c5306e671ccf55fcad8eec8dcd20e1c6c3bb8e4646771d62af5f1e1754f
EBUILD binutils-config-3.ebuild 636 RMD160 9c8011de431f2b997aa1d4e181d4232b09c1c860 SHA1 bf31e1b75bad413cba7957324d44fab2a22ea157 SHA256 e6b4c164d4b751353321ca257a13017d538bb14c4031e9dc82db4ac87b1f3317
-MISC ChangeLog 8225 RMD160 a770c23a731885f303438fe1f53e70d88bcda21e SHA1 7a5fa99568c0e8351126c446c799b16a20b4f389 SHA256 086c870c59b5abf01b6a39e0db7947c839923fedefb3b37688237a8faf9e6746
+MISC ChangeLog 8347 RMD160 a5db20e9c4fc55104c79ff63df1acd310723a5ae SHA1 a1e3df029600af9cf9b95624ffcfe6372b0737a9 SHA256 1a63758fa37a2aeef62003dd75eebfd5aeeb8097ddeef3ea4caf1cbd876f0bfc
MISC metadata.xml 162 RMD160 d002486a43522f2116b1d9d59828c484956d66e2 SHA1 d6b4923897f6ae673b4f93646f5b4ba61d5a2c3c SHA256 65a915d44de1f01d4b7f72d313b4192c38374a9835d24988c00c1e73dca5805a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)
-iF4EAREIAAYFAk5T0LcACgkQaC/OocHi7JZKqwD/Sud/QWL2doNPISSTSGV1+OPv
-jnEMgJE119qL7oZhizcA/RGJNTYpEB8Cdb+SfePTNk7tmLQV0cJFX47lRMGUvNVE
-=bUzc
+iF4EAREIAAYFAk5a48UACgkQaC/OocHi7JZujgD+KngejZKZLgTOn5PGlBGsJNs8
+Brng0rb9CmyNywgcIuoA+wbrT0hK3CyFR7Ev//gduicWCT61aqJJ354G9Gwi2a8W
+=qAj+
-----END PGP SIGNATURE-----
diff --git a/sys-devel/binutils-config/files/binutils-config-3 b/sys-devel/binutils-config/files/binutils-config-3
index 734b2d54e14e..725ae43aa6f3 100755
--- a/sys-devel/binutils-config/files/binutils-config-3
+++ b/sys-devel/binutils-config/files/binutils-config-3
@@ -1,7 +1,7 @@
#!/bin/bash
# Copyright 1999-2011 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-3,v 1.4 2011/08/23 16:09:21 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/binutils-config-3,v 1.5 2011/08/29 00:56:46 vapier Exp $
# Format of /etc/env.d/binutils/:
# config-TARGET: CURRENT=version for TARGET
@@ -59,6 +59,26 @@ mv_if_diff() {
mv -f "$1" "$2"
fi
}
+atomic_ln() {
+ local target=$1 linkdir=$2 linkname=$3 linktmp linkfull
+ linktmp="${linkdir}/.binutils-config.tmp.${linkname}"
+ linkfull="${linkdir}/${linkname}"
+ if [[ -d ${linkfull} ]] ; then
+ # if linking to a dir, we need a little magic to
+ # make it atomic since `mv -T` is not portable
+ rm -rf "${linktmp}"
+ mkdir -p "${linktmp}"
+ ln -sf "${target}" "${linktmp}/${linkname}"
+ mv "${linktmp}/${linkname}" "${linktmp}/../"
+ rmdir "${linktmp}"
+ else
+ # `ln` will expand into unlink();symlink(); which
+ # is not atomic for a small amount of time, but
+ # `mv` is a single rename() call
+ ln -sf "${target}" "${linktmp}"
+ mv "${linktmp}" "${linkfull}"
+ fi
+}
setup_env() {
unset TARGET VER LIBPATH FAKE_TARGETS
@@ -122,14 +142,14 @@ switch_profile() {
cd "${ROOT}/${BINPATH}" || exit 1
mkdir -p "${ROOT}/${BINPATH_LINKS}" "${ROOT}/usr/bin"
for x in * ; do
- ln -sf "${BINPATH}/${x}" "${ROOT}/${BINPATH_LINKS}/${x}"
- ln -sf "${BINPATH_LINKS}/${x}" "${ROOT}"/usr/bin/${TARGET}-${x}
+ atomic_ln "${BINPATH}/${x}" "${ROOT}/${BINPATH_LINKS}" "${x}"
+ atomic_ln "${BINPATH_LINKS}/${x}" "${ROOT}/usr/bin/" "${TARGET}-${x}"
for fake in ${FAKE_TARGETS} ; do
[[ -f ${ENV_D}/config-${fake} ]] && continue
- ln -sf "${BINPATH_LINKS}/${x}" "${ROOT}"/usr/bin/${fake}-${x}
+ atomic_ln "${BINPATH_LINKS}/${x}" "${ROOT}/usr/bin" "${fake}-${x}"
done
if [[ ${TARGET} == ${HOST} ]] ; then
- ln -sf ${TARGET}-${x} "${ROOT}"/usr/bin/${x}
+ atomic_ln "${TARGET}-${x}" "${ROOT}/usr/bin" "${x}"
fi
done
@@ -147,12 +167,12 @@ switch_profile() {
rmdir "${ROOT}"/usr/${TARGET}/lib >& /dev/null
fi
# When upgrading, we need to clean up ldscripts and libs
- rm -rf "${dstlib}/ldscripts" "${ROOT}/${BINPATH_LINKS}"/ldscripts
mkdir -p "${dstlib}"
- ln -sf "${LIBPATH}/ldscripts" "${dstlib}"/ldscripts
- find -L "${dstlib}" -type l -exec rm {} +
+ rm -rf "${ROOT}/${BINPATH_LINKS}"/ldscripts
+ atomic_ln "${LIBPATH}/ldscripts" "${dstlib}" "ldscripts"
+ find -L "${dstlib}" -type l -exec rm -v {} +
for x in lib* ; do
- ln -sf "${LIBPATH}/${x}" "${dstlib}/${x}"
+ atomic_ln "${LIBPATH}/${x}" "${dstlib}" "${x}"
done
#
@@ -164,7 +184,7 @@ switch_profile() {
if [[ ${HOST} == ${TARGET} ]] ; then
mkdir -p "${ROOT}/usr/include"
for x in * ; do
- ln -sf "${INCPATH}/${x}" "${ROOT}/usr/include/${x}"
+ atomic_ln "${INCPATH}/${x}" "${ROOT}/usr/include" "${x}"
done
else
# Clean out old path -- cannot use '-exec {} +' syntax here
@@ -337,14 +357,14 @@ switch_linker() {
setup_env || return 1
# does this binutils even support the requested linker ?
- if [[ ! -e ${BINPATH}/ld.${ld} ]] ; then
+ if [[ ! -e ${ROOT}/${BINPATH}/ld.${ld} ]] ; then
eerror "${argv0}: sorry, but ${PROFILE} doesn't support the ${ld} linker"
exit 1
fi
# switch it up
ebegin "Setting default linker to ${ld} for ${PROFILE}"
- ln -sf ld.${ld} "${BINPATH}"/ld
+ atomic_ln ld.${ld} "${ROOT}/${BINPATH}" ld
eend $?
}
switch_linker_gold() { switch_linker gold ; }
@@ -389,7 +409,7 @@ while [[ $# -gt 0 ]] ; do
-h|--help) usage 0 ;;
-V|--version)
unset Header
- cvsver="$Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/binutils-config-3,v 1.4 2011/08/23 16:09:21 vapier Exp $"
+ cvsver="$Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/binutils-config-3,v 1.5 2011/08/29 00:56:46 vapier Exp $"
cvsver=${cvsver##*binutils-config-}
bver=${cvsver%%,v *}
cvsver=${cvsver#* }