blob: f54f553964b9c277b9ace2a0f9115101860a5a69 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
#!@SHELL@
name='@name@'
ver='0.7.3'
# Copyright (C) 2009 Luke Shumaker
#
# This file is part of rvs.
#
# rvs is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2, or (at your option) any later version.
#
# rvs is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with rvs; see the file COPYING.
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
RVS="$0" #RVS="@rvs@"
libexecdir="@libexecdir@/$name"
_error() {
echo "$name: $1" >> /dev/stderr
exit 1
}
_repo() {
repo=".$name"
pwd=`pwd`
owd="$pwd"
while [ "$pwd" != "`pwd`" ] && [ ! -e "`pwd`/$repo" ]; do
pwd=`pwd`
cd ..
done
if [ -e "`pwd`/$repo" ]; then
echo "`pwd`/$repo"
else
_error "no $name repository found"
fi
cd "$owd"
}
_init() {
repo=`_repo 2> /dev/null`
if [ -z "$repo" ]; then
repo=".$name"
install -d "$repo"
install -T $libexecdir/plugins $repo/plugins
while read plugin; do
echo "initializing plugin \`$plugin'"
install -d "$repo/$plugin"
export REPO=.rvs/$plugin
if [ -e "$libexecdir/$plugin/init" ]; then
"$libexecdir/$plugin/init"
fi
done < $repo/plugins
else
_error "repository already exists at \`$repo'"
fi
}
_install() {
id=$1
dir=${2-$id}
name=`echo $id | sed 's/-.*$//'`
if (grep "^$name-" "$libexecdir/plugins" &> /dev/null); then
# an entry for this plugin already exists, though possibly a
# different version
sed -i "s/^$name-.*$/$id/" "$libexecdir/plugins"
else
echo "$id" >> "$libexecdir/plugins"
fi
rm -rf "$libexecdir/$id"
cp -rpT "$dir" "$libexecdir/$id"
}
_uninstall() {
id=$1
sed -i "/^$id$/ d" "$libexecdir/plugins"
rm -rf "$libexecdir/$id"
}
_treebranch() {
branch="$1"
for com in "$branch"; do
var="r_$com"
if [ -z "\$$var" ]; then
exec r$var="`$libexecdir/$com $param`"
var="_$com"
_treebranch "\$$var"
else
_error "plugin dependancy loop detected"
fi
done
}
_runcom() {
com="$1"
tmp_mast="`tempfile`"
# bash optimized version
#grep -E "^$com(:.*)?$" "$libexecdir/*/plugin.conf" | sed \
# -e 's/\#.*//' \
# -e "s:^${libexecdir//':'/'\:'}/::" \
# -e 's@plugin.conf\:@@' > "$tmp_mast"
# POSIX version
grep -E "^$com(:.*)?$" $libexecdir/*/plugin.conf | sed \
-e 's/\#.*//' \
-e "s:^`echo "$libexecdir" |sed 's@:@\\:@g'`/::" \
-e 's@plugin.conf\:@@' > "$tmp_mast"
# start processing-------------------------------------------
if [ "`wc -c < "$tmp_mast"`" = '0' ]; then
_error "unrecognized command \`$com'"
else
# create tree
tmp_work="`tempfile`"
lev1="`sed \
-e "/\:/w '$tmp_work'" \
-e '/\:/d' "$tmp_mast"`"
while read line; do
com="`echo "$line" | sed 's/\:.*$/'`"
dep="_`echo "$line" | sed 's/.*\:$/'`"
# bash optimized version
# eval $dep=\"${!dep} $com\"
# POSIX version
eval $dep=\"\$$dep $com\"
done < "$tmp_work"
rm "$tmp_work"
# cycle through tree
_treebranch "$lev1"
fi
rm "$tmp_mast"
}
# START OPTION HANDLING #
com=$1;
# END OPTION HANDLING #
case "$com" in
'') _error 'no command specified';;
# 'repo') _repo; exit $?;;
'init') _init; exit $?;;
'install') shift; _install $@; exit $?;;
'uninstall') shift; _uninstall $@; exit $?;;
*) repo=`_repo`
if [ "$?" = '0' ]; then
shift
param="$@"
_runcom
exit $?
else
_error "cannot find an existing repository"
fi
:;;
esac
# Copy/Paste Virus 1.3c Please copy and paste this text anywhere. Track
# its progress by searching for this MD5#f7eac285ebfe21c4587bfebb9582f90d
|