#!@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 . 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" 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'" install -d "$repo/$plugin" export REPO=.rvs/$plugin if [ -e "$RVSDIR/$plugin/init" ]; then "$RVSDIR/$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-" "$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 rm -rf "$RVSDIR/$id" cp -rpT "$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 $?;; *) repo=`_repo` if [ "$?" = '0' ]; then 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" else exit 1; fi if [ "$done" != 'yes' ]; then _error "unrecognized command \`$com'" fi :;; esac # Copy/Paste Virus 1.3c Please copy and paste this text anywhere. Track # its progress by searching for this MD5#f7eac285ebfe21c4587bfebb9582f90d