summaryrefslogtreecommitdiffstats
path: root/bin/doins
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-03-28 12:29:46 +0000
committerZac Medico <zmedico@gentoo.org>2008-03-28 12:29:46 +0000
commitafb2b118c825f8a72c67c8b34c685b867b4135a1 (patch)
tree44a21b2e42e0bc0fd9520a8952929c64db0df94b /bin/doins
parentef2adcd146410fecbc0edbbc87cdbaca95ac7fd8 (diff)
downloadportage-afb2b118c825f8a72c67c8b34c685b867b4135a1.tar.gz
portage-afb2b118c825f8a72c67c8b34c685b867b4135a1.tar.bz2
portage-afb2b118c825f8a72c67c8b34c685b867b4135a1.zip
Bug #210575 - Optimize doins -r so that it doesn't call itself recursively,
since it's faster to handle the recursion internally. Thanks to Benedikt Böhm <hollow@gentoo.org> for the initial patch. (trunk r9485) svn path=/main/branches/2.1.2/; revision=9563
Diffstat (limited to 'bin/doins')
-rwxr-xr-xbin/doins45
1 files changed, 27 insertions, 18 deletions
diff --git a/bin/doins b/bin/doins
index c0a495aef..ed0212048 100755
--- a/bin/doins
+++ b/bin/doins
@@ -16,11 +16,6 @@ if [[ "$1" == "-r" ]] ; then
else
DOINSRECUR=n
fi
-[[ -z ${INSDEPTH} ]] && declare -i INSDEPTH=0
-if [[ ${INSDEPTH} -gt 30 ]] ; then
- echo "${0##*/}: sanity check ... 30 directories is too much :(" 2>&1
- exit 1
-fi
if [[ ${INSDESTTREE#${D}} != "${INSDESTTREE}" ]]; then
vecho "-------------------------------------------------------" 1>&2
@@ -32,24 +27,38 @@ fi
[[ ! -d ${D}${INSDESTTREE} ]] && dodir "${INSDESTTREE}"
+_doins() {
+ local mysrc="$1" mydir="$2"
+
+ if [ -L "$mysrc" ] ; then
+ cp "$mysrc" "${T}"
+ mysrc="${T}/${mysrc##*/}"
+ fi
+
+ install ${INSOPTIONS} "${mysrc}" "${D}${INSDESTTREE}/${mydir}"
+}
+
+_xdoins() {
+ while read -d $'\0' x ; do
+ _doins "$x" "${x%/*}"
+ done
+}
+
for x in "$@" ; do
- if [ -L "$x" ] ; then
- cp "$x" "${T}"
- mysrc="${T}/$(/usr/bin/basename "${x}")"
- elif [ -d "$x" ] ; then
+ if [ -d "$x" ] ; then
if [ "${DOINSRECUR}" == "n" ] ; then
continue
fi
- mydir="${INSDESTTREE}/$(basename "${x}")"
- find "${x}" -mindepth 1 -maxdepth 1 -exec \
- env \
- INSDESTTREE="${mydir}" \
- INSDEPTH=$((INSDEPTH+1)) \
- doins -r {} \;
- continue
+ if [ $x = "${x%/*}" ] ; then
+ pushd "$PWD" >/dev/null
+ else
+ pushd "${x%/*}" >/dev/null
+ fi
+ find "${x##*/}" -type d -exec dodir "${INSDESTTREE}/{}" \;
+ find "${x##*/}" \( -type f -or -type l \) -print0 | _xdoins
+ popd >/dev/null
else
- mysrc="${x}"
+ _doins "${x}"
fi
- install ${INSOPTIONS} "${mysrc}" "${D}${INSDESTTREE}"
done