summaryrefslogtreecommitdiffstats
path: root/bin/doins
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-10-05 16:04:31 +0000
committerZac Medico <zmedico@gentoo.org>2008-10-05 16:04:31 +0000
commit55b3150af635a418ba3f1424132359c894db7ec4 (patch)
tree4ce526049f69f3e51be7904eb76a97ef35d36fd1 /bin/doins
parent177c09dcc037d568fe421de0b5d7ddc3c618f352 (diff)
downloadportage-55b3150af635a418ba3f1424132359c894db7ec4.tar.gz
portage-55b3150af635a418ba3f1424132359c894db7ec4.tar.bz2
portage-55b3150af635a418ba3f1424132359c894db7ec4.zip
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
Diffstat (limited to 'bin/doins')
-rwxr-xr-xbin/doins22
1 files changed, 17 insertions, 5 deletions
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