blob: 3ac35268580c2c7d109453b996eb974ce1d88d58 (
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
|
#!@SHELL@
name='@name@'
ver='0.7.0'
# Copyright (C) 2009 Luke Shumaker
# This program 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.
#
# Originally written by Luke Shumaker <lukeshu@sbcglobal.net>.
RVSDIR="@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" >> /dev/stderr
fi
cd "$owd"
}
init() {
repo=`repo 2> /dev/null`
if [ -z "$repo" ]; then
repo=".$name"
install -d "$repo"
install -T $RVSDIR/plugins $repo/plugins
while read plugin; do
echo "initializing plugin \`$plugin'"
echo 'foo0'
install -d "$repo/$plugin"
echo 'foo1'
export REPO=.rvs/$plugin
echo 'foo2'
if [ -e "$RVSDIR/$plugin/init" ]; then
"$RVSDIR/$plugin/init"
fi
echo 'foo3'
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-" "$RVSDIR/plugins" &> /dev/null); then
# an entry for this plugin already exists, though possibly a
# different version
sed -i "s/^$name-.*$/$id/" "$RVSDIR/plugins"
else
echo "$id" >> "$RVSDIR/plugins"
fi
cp -rp "$dir" "$RVSDIR/$id"
}
uninstall() {
id=$1
sed -i "/^$id$/ d" "$RVSDIR/plugins"
rm -rf "$RVSDIR/$id"
}
# 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 $?;;
*)
if [ -f "$RVSDIR/$com" ]; then
export RVSDIR
$RVSDIR/$@
done='yes'
else
while read plugin; do
if [ -f "$RVSDIR/$plugin/$com" ]; then
done='yes'
export RVSDIR=$RVSDIR/$plugin
export REPO=`repo`/$plugin
$RVSDIR/$@
exit $?
break
fi
done < $REPO/plugins
fi
if [ "$done" != 'yes' ]; then
error "unrecognized command \`$com'"
fi
:;;
esac
#args=`getopt -n "$name" -o "${sopt}" -l "${lopt}" -- "$@"`
#if [ $? == 0 ]; then
# set -- $args
# while [ $# -gt 0 ]; do
# case "$1" in
# -V | --version) mode='version';;
# -h | -H | -\? | --help) mode='help';;
#
# -v | --verbose) volume='-v';;
# -q | --quiet) volume='-q';;
#
# --) shift; break;;
# esac
# shift;
# done
#else
# error
#fi
|