1 |
Author: zmedico |
2 |
Date: 2008-03-28 12:29:46 +0000 (Fri, 28 Mar 2008) |
3 |
New Revision: 9563 |
4 |
|
5 |
Modified: |
6 |
main/branches/2.1.2/bin/doins |
7 |
Log: |
8 |
Bug #210575 - Optimize doins -r so that it doesn't call itself recursively, |
9 |
since it's faster to handle the recursion internally. Thanks to Benedikt |
10 |
B?\195?\182hm <hollow@g.o> for the initial patch. (trunk r9485) |
11 |
|
12 |
|
13 |
Modified: main/branches/2.1.2/bin/doins |
14 |
=================================================================== |
15 |
--- main/branches/2.1.2/bin/doins 2008-03-28 12:28:25 UTC (rev 9562) |
16 |
+++ main/branches/2.1.2/bin/doins 2008-03-28 12:29:46 UTC (rev 9563) |
17 |
@@ -16,11 +16,6 @@ |
18 |
else |
19 |
DOINSRECUR=n |
20 |
fi |
21 |
-[[ -z ${INSDEPTH} ]] && declare -i INSDEPTH=0 |
22 |
-if [[ ${INSDEPTH} -gt 30 ]] ; then |
23 |
- echo "${0##*/}: sanity check ... 30 directories is too much :(" 2>&1 |
24 |
- exit 1 |
25 |
-fi |
26 |
|
27 |
if [[ ${INSDESTTREE#${D}} != "${INSDESTTREE}" ]]; then |
28 |
vecho "-------------------------------------------------------" 1>&2 |
29 |
@@ -32,24 +27,38 @@ |
30 |
|
31 |
[[ ! -d ${D}${INSDESTTREE} ]] && dodir "${INSDESTTREE}" |
32 |
|
33 |
+_doins() { |
34 |
+ local mysrc="$1" mydir="$2" |
35 |
+ |
36 |
+ if [ -L "$mysrc" ] ; then |
37 |
+ cp "$mysrc" "${T}" |
38 |
+ mysrc="${T}/${mysrc##*/}" |
39 |
+ fi |
40 |
+ |
41 |
+ install ${INSOPTIONS} "${mysrc}" "${D}${INSDESTTREE}/${mydir}" |
42 |
+} |
43 |
+ |
44 |
+_xdoins() { |
45 |
+ while read -d $'\0' x ; do |
46 |
+ _doins "$x" "${x%/*}" |
47 |
+ done |
48 |
+} |
49 |
+ |
50 |
for x in "$@" ; do |
51 |
- if [ -L "$x" ] ; then |
52 |
- cp "$x" "${T}" |
53 |
- mysrc="${T}/$(/usr/bin/basename "${x}")" |
54 |
- elif [ -d "$x" ] ; then |
55 |
+ if [ -d "$x" ] ; then |
56 |
if [ "${DOINSRECUR}" == "n" ] ; then |
57 |
continue |
58 |
fi |
59 |
|
60 |
- mydir="${INSDESTTREE}/$(basename "${x}")" |
61 |
- find "${x}" -mindepth 1 -maxdepth 1 -exec \ |
62 |
- env \ |
63 |
- INSDESTTREE="${mydir}" \ |
64 |
- INSDEPTH=$((INSDEPTH+1)) \ |
65 |
- doins -r {} \; |
66 |
- continue |
67 |
+ if [ $x = "${x%/*}" ] ; then |
68 |
+ pushd "$PWD" >/dev/null |
69 |
+ else |
70 |
+ pushd "${x%/*}" >/dev/null |
71 |
+ fi |
72 |
+ find "${x##*/}" -type d -exec dodir "${INSDESTTREE}/{}" \; |
73 |
+ find "${x##*/}" \( -type f -or -type l \) -print0 | _xdoins |
74 |
+ popd >/dev/null |
75 |
else |
76 |
- mysrc="${x}" |
77 |
+ _doins "${x}" |
78 |
fi |
79 |
- install ${INSOPTIONS} "${mysrc}" "${D}${INSDESTTREE}" |
80 |
done |
81 |
|
82 |
-- |
83 |
gentoo-commits@l.g.o mailing list |