From 13ac989be47ce85bd9776c9787c9dc17ddda92f8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 26 Jul 2009 18:00:01 -0400 Subject: oops, I forgot to `bzr add' all the moved files :) --- plugins/repo/Makefile.orig | 65 +++++++++++++++++++++++++++ plugins/repo/commit.d.sh | 25 +++++++++++ plugins/repo/commit.f.sh | 23 ++++++++++ plugins/repo/commit.sh | 47 ++++++++++++++++++++ plugins/repo/get.d.sh | 29 ++++++++++++ plugins/repo/get.f.sh | 19 ++++++++ plugins/repo/get.sh | 24 ++++++++++ plugins/repo/lib/stdio.sh | 58 ++++++++++++++++++++++++ plugins/users/init.sh | 17 +++++++ plugins/users/mkuser.sh | 24 ++++++++++ plugins/users/rmuser.sh | 14 ++++++ rvs.sh | 107 +++++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 452 insertions(+) create mode 100644 plugins/repo/Makefile.orig create mode 100644 plugins/repo/commit.d.sh create mode 100644 plugins/repo/commit.f.sh create mode 100644 plugins/repo/commit.sh create mode 100644 plugins/repo/get.d.sh create mode 100644 plugins/repo/get.f.sh create mode 100644 plugins/repo/get.sh create mode 100644 plugins/repo/lib/stdio.sh create mode 100644 plugins/users/init.sh create mode 100644 plugins/users/mkuser.sh create mode 100644 plugins/users/rmuser.sh create mode 100644 rvs.sh diff --git a/plugins/repo/Makefile.orig b/plugins/repo/Makefile.orig new file mode 100644 index 0000000..00ffc5f --- /dev/null +++ b/plugins/repo/Makefile.orig @@ -0,0 +1,65 @@ +#!/usr/bin/make -f +name = repo +# version 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 . + + +# Variables ######################################################## +RM ?= rm -f +CP ?= cp +INSTALL = install +MKDIR ?= $(INSTALL) -d #mkdir -p +INSTALL_PROGRAM ?= $(INSTALL) +INSTALL_DATA ?= $(INSTALL) -m 644 + +SHELL ?= @SHELL@ +rvsdir ?= @rvsdir@/rvs +srcdir ?= @srcdir@ + +libdir = $(rvsdir)/$(name) +reldir = plugins/$(name) + +VPATH = $(srcdir)/$(reldir) + +# phony targets #################################################### +all : $(name) +.PHONY : $(name) install clean remove +.SUFFIXES : + +# targets ########################################################## +srcFiles = $(filter-out %/Makefile.orig,$(shell find $(VPATH)/ -type f)) +shFiles = $(patsubst $(VPATH)/%,%,$(basename $(filter %.sh,$(srcFiles)))) + +$(name) : $(shFiles) +#$(name) : + + +# install/clean/remove ############################################# + +#install : + +clean : + $(RM) -r ./* + $(RM) Makefile + +remove : + $(RM) -r $(libdir) + +# implicit rules ################################################### + +# 'build' shell scripts +% : %.sh + $(MKDIR) $(dir $@) + $(CP) $< $@ + +# install +$(libdir)/% : % + $(MKDIR) $(dir $@) + $(INSTALL_PROGRAM) $< $@ + diff --git a/plugins/repo/commit.d.sh b/plugins/repo/commit.d.sh new file mode 100644 index 0000000..7cfe98a --- /dev/null +++ b/plugins/repo/commit.d.sh @@ -0,0 +1,25 @@ +#!$$SHELL$$ +name='rvs commit.d' +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 . + +#source "$RVSDIR/lib/stdio" + +# commit.d DIRNAME +dir="$1" + +tmp=`tempfile` +for file in $dir/*; do + hash=`"$RVSDIR/commit" "$file"` + echo "$file:$hash" >> "$tmp" +done + +"$RVSDIR/commit.f" "$tmp" +rm "$tmp" + diff --git a/plugins/repo/commit.f.sh b/plugins/repo/commit.f.sh new file mode 100644 index 0000000..c3a652c --- /dev/null +++ b/plugins/repo/commit.f.sh @@ -0,0 +1,23 @@ +#!$$SHELL$$ +name='rvs commit.f' +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 . + +#source "$RVSDIR/lib/stdio" + +# commit.f FILENAME +file="$1" + +#hash=`md5sum $file | sed "s/ .*$//"` +hash=`sha1sum $file | sed "s/ .*$//"` +if [ ! -f "$REPO/$hash" ]; then + install -m 644 -o $USER -g $USER -T "$file" "$REPO/$hash" +fi +echo "$hash" + diff --git a/plugins/repo/commit.sh b/plugins/repo/commit.sh new file mode 100644 index 0000000..e5e8eba --- /dev/null +++ b/plugins/repo/commit.sh @@ -0,0 +1,47 @@ +#!$$SHELL$$ +name='rvs commit' +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 . + +source "$RVSDIR/lib/stdio" + +# commit FILE +file=${1-.} + +warn "$file" + +if [ ! -e $file ]; then error "file \`$file' does not exist"; +# START file type list +elif [ -L $file ]; then type='l'; # symbolic link +elif [ -b $file ]; then type='b'; # block (buffered) special +elif [ -c $file ]; then type='c'; # character (unbuffered) special +elif [ -d $file ]; then type='d'; # directory +elif [ -p $file ]; then type='p'; # named pipe (FIFO) +elif [ -f $file ]; then type='f'; # regular file +elif [ -s $file ]; then type='s'; # socket +#elif [ -D $file ]; then type='D'; # door (Solaris only) +# END file type list +else error "could not identify file type of \`$file'" +fi + +ret=`"$RVSDIR/commit.$type" "$file"` + +tmp=`tempfile` +cat << __EOF__ > "$tmp" +name:$file +hash:$ret +type:$type +author:$user +owner:$owner +license:$license +__EOF__ + +"$RVSDIR/commit.f" "$tmp" +rm "$tmp" + diff --git a/plugins/repo/get.d.sh b/plugins/repo/get.d.sh new file mode 100644 index 0000000..77107c2 --- /dev/null +++ b/plugins/repo/get.d.sh @@ -0,0 +1,29 @@ +#!$$SHELL$$ +name='rvs get.d' +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 . + +#source "$RVSDIR/lib/stdio" + +# get.d ID DIRNAME +id="$1" +dir="$2" + +tmp=`tempfile` +"$RVSDIR/get.f" `sed -n 's/^hash://p' "$db"` "$tmp" + +mkdir "$dir" +while read line; do + hash=`echo "$line" | sed 's/^.*://'` + name=`echo "$line" | sed "s/:$hash$//"` + "$RVSDIR/get" "$dir/$file" +done < "$tmp" + +rm "$tmp" + diff --git a/plugins/repo/get.f.sh b/plugins/repo/get.f.sh new file mode 100644 index 0000000..f6ab761 --- /dev/null +++ b/plugins/repo/get.f.sh @@ -0,0 +1,19 @@ +#!$$SHELL$$ +name='rvs get.f' +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 . + +#source "$RVSDIR/lib/stdio" + +# get.f ID FILENAME +id="$1" +file="$2" + +install -T "$REPO/$id" "$file" + diff --git a/plugins/repo/get.sh b/plugins/repo/get.sh new file mode 100644 index 0000000..e1289f7 --- /dev/null +++ b/plugins/repo/get.sh @@ -0,0 +1,24 @@ +#!$$SHELL$$ +name='rvs get' +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 . + +#source "$RVSDIR/lib/stdio" + +# get ID [FILE] +id="$1" + +tmp=`tempfile` +"$RVSDIR/get.f" "$id" "$tmp" +type=`sed -n 's/^type://p' "$tmp"` +file="${2-`sed -n 's/^name://p' "$tmp"`}" + +"$RVSDIR/get.$type" "$id" "$file" + +rm "$tmp" diff --git a/plugins/repo/lib/stdio.sh b/plugins/repo/lib/stdio.sh new file mode 100644 index 0000000..e20cb7f --- /dev/null +++ b/plugins/repo/lib/stdio.sh @@ -0,0 +1,58 @@ +#!$$SHELL$$ +#name='rvs stdio' +#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 . + +verbose() { + if [ "$volume" == '-v' ]; then + echo $@ + fi +} + +out() { + if [ "$volume" != '-q' ]; then + echo $@ + fi +} + +warn () { + echo "$name: $1" >> /dev/stderr +} + +fatal () { + warn "$1" + exit 1 +} + +error() { + warn "$1" + cat << __error__ >> /dev/stderr +Usage: $name $usage + +Try \`$name --help\' for more options. +__error__ + exit 1 +} + +version() { + echo "$name $ver" + if [ "$volume" != '-q' ]; then + cat << __disclaimer__ +$name is 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 . +__disclaimer__ + fi + exit 0 +} + diff --git a/plugins/users/init.sh b/plugins/users/init.sh new file mode 100644 index 0000000..ee570ff --- /dev/null +++ b/plugins/users/init.sh @@ -0,0 +1,17 @@ +#!$$SHELL$$ +name='rvs init' +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 . + +cat << __EOF__ > "$repo/Public Domain" +author:anonymous +owner:Public Domain +license: +__EOF__ + diff --git a/plugins/users/mkuser.sh b/plugins/users/mkuser.sh new file mode 100644 index 0000000..594c024 --- /dev/null +++ b/plugins/users/mkuser.sh @@ -0,0 +1,24 @@ +#!$$SHELL$$ +name='rvs mkuser' +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 . + +read -p 'username: ' author +read -p 'give copyright to: ' owner +if [ "$owner" != 'Public Domain' ]; then + read -p 'use the license: ' license +else + license='' +fi +cat << __EOF__ > "$REPO/$author" +author:$author +owner:$owner +license:$license +__EOF__ + diff --git a/plugins/users/rmuser.sh b/plugins/users/rmuser.sh new file mode 100644 index 0000000..598bae9 --- /dev/null +++ b/plugins/users/rmuser.sh @@ -0,0 +1,14 @@ +#!$$SHELL$$ +name='rvs rmuser' +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 . + +uname=$1 +rm "$REPO/$uname" + diff --git a/rvs.sh b/rvs.sh new file mode 100644 index 0000000..d26c94d --- /dev/null +++ b/rvs.sh @@ -0,0 +1,107 @@ +#!$$SHELL$$ +name='rvs' +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='$$libdir$$' +REPO=`$RVSDIR/repo` + +error() { + echo "$name: $1" >> /dev/stderr + exit 1 +} + +repo() { + repo='.rvs' + pwd=`pwd` + owd="$pwd" + + while [ "$pwd" != "`pwd`" ] && [ ! -e "`pwd`/$repo" ]; do + pwd=`pwd` + cd .. + done + + if [ -e "`pwd`/$repo" ]; then + echo "`pwd`/$repo" + else + echo "$name: no rvs repository found" >> /dev/stderr + exit 1 + fi + cd "$owd" +} + + +init() { + repo=`repo` + if [ -z "$repo" ]; then + repo='.rvs' + install -d "$repo" + fi + + if diff -q $RVSDIR/plugins $repo/plugins; then + install -T $RVSDIR/plugins $repo/plugins + while read plugin; do + if [ ! -e "$repo/$plugin" ]; then + install -d "$repo/$plugin" + if [ -e "$RVSDIR/$plugin/init" ]; then + $RVSDIR/$plugin/init + fi + fi + done < $repo/plugins + fi +} + +# START OPTION HANDLING # +com=$1; +# END OPTION HANDLING # +case "$com" in + '') error 'no command specified';; + 'repo') repo;; + 'init') init;; + *) + if [ -f "$RVSDIR/$com" ]; then + export RVSDIR + $RVSDIR/$@ + done='yes' + else + while read plugin; do + if [ -f "$RVSDIR/$plugin/$com" ]; then + export RVSDIR=$RVSDIR/$plugin + export REPO=$REPO/$plugin + $RVSDIR/$@ + done='yes' + 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 + -- cgit v1.2.3