From 55b3150af635a418ba3f1424132359c894db7ec4 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 5 Oct 2008 16:04:31 +0000 Subject: Bug #239529 - When doins is called on a symlink to a directory, preserve the name of the symlink for the installed directory. This involves temporarily renaming the directory and then renaming it back again. svn path=/main/trunk/; revision=11629 --- bin/doins | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/doins b/bin/doins index 11025250d..9831fba95 100755 --- a/bin/doins +++ b/bin/doins @@ -25,14 +25,17 @@ if [[ ${INSDESTTREE#${D}} != "${INSDESTTREE}" ]]; then exit 1 fi +TMP=$T/.doins_tmp +mkdir "$TMP" + [[ ! -d ${D}${INSDESTTREE} ]] && dodir "${INSDESTTREE}" _doins() { local mysrc="$1" mydir="$2" cleanup="" rval if [ -L "$mysrc" ] ; then - cp "$mysrc" "${T}" - mysrc="${T}/${mysrc##*/}" + cp "$mysrc" "$TMP" + mysrc="$TMP/${mysrc##*/}" cleanup=${mysrc} fi @@ -65,6 +68,7 @@ for x in "$@" ; do pushd "${x%/*}" >/dev/null fi x=${x##*/} + x_orig=$x # Follow any symlinks recursively until we've got # a normal directory for 'find' to traverse. while [ -L "$x" ] ; do @@ -72,13 +76,21 @@ for x in "$@" ; do x=${PWD##*/} pushd "${PWD%/*}" >/dev/null done - find "$x" -type d -exec dodir "${INSDESTTREE}/{}" \; - find "$x" \( -type f -or -type l \) -print0 | _xdoins + if [[ $x != $x_orig ]] ; then + mv "$x" "$TMP/$x_orig" + pushd "$TMP" >/dev/null + fi + find "$x_orig" -type d -exec dodir "${INSDESTTREE}/{}" \; + find "$x_orig" \( -type f -or -type l \) -print0 | _xdoins + if [[ $x != $x_orig ]] ; then + popd >/dev/null + mv "$TMP/$x_orig" "$x" + fi while popd >/dev/null 2>&1 ; do true ; done ((++success)) else _doins "${x}" && ((++success)) fi done - +rm -rf "$TMP" [ $success -gt 0 ] && exit 0 || exit 1 -- cgit v1.2.3-1-g7c22