summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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