From fcdf806858f9dd8fd7a111cca26853820eac562c Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 19 Mar 2008 10:24:26 +0000 Subject: =?UTF-8?q?Bug=20#210575=20-=20Optimize=20doins=20-r=20so=20that?= =?UTF-8?q?=20it=20doesn't=20call=20itself=20recursively,=20since=20it's?= =?UTF-8?q?=20faster=20to=20handle=20the=20recursion=20internally.=20Thank?= =?UTF-8?q?s=20to=20Benedikt=20B=C3=B6hm=20=20for=20the?= =?UTF-8?q?=20initial=20patch.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn path=/main/trunk/; revision=9485 --- bin/doins | 45 +++++++++++++++++++++++++++------------------ 1 file 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 -- cgit v1.2.3-1-g7c22