From fc8d2f56a8104e755766fbbca4729906000cf78d Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 3 Aug 2009 19:03:08 -0400 Subject: 0.7.2 -- refactor slightly, flesh out plugin: users --- plugins/repo/commit.d.sh | 10 ++++---- plugins/repo/commit.f.sh | 6 ++--- plugins/repo/commit.sh | 10 ++++---- plugins/repo/get.d.sh | 10 ++++---- plugins/repo/get.f.sh | 6 ++--- plugins/repo/get.sh | 10 ++++---- plugins/repo/lib/stdio.sh | 4 ++-- plugins/users/commit.sh | 21 +++++++++++++++++ plugins/users/init.sh | 6 +++-- plugins/users/lib/stdio.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++++ plugins/users/login.sh | 20 ++++++++++++++++ plugins/users/logout.sh | 19 +++++++++++++++ plugins/users/mkuser.sh | 8 ++++--- plugins/users/rmuser.sh | 14 +++++++---- rvs.sh | 8 ++++--- 15 files changed, 171 insertions(+), 40 deletions(-) create mode 100644 plugins/users/commit.sh create mode 100644 plugins/users/lib/stdio.sh create mode 100644 plugins/users/login.sh create mode 100644 plugins/users/logout.sh diff --git a/plugins/repo/commit.d.sh b/plugins/repo/commit.d.sh index 3c6709d..1175a07 100644 --- a/plugins/repo/commit.d.sh +++ b/plugins/repo/commit.d.sh @@ -1,6 +1,6 @@ #!@SHELL@ -name='rvs commit.d' -ver='0.7.0' +name='rvs repo commit.d' +ver='0.7.2' # 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 @@ -9,7 +9,7 @@ ver='0.7.0' # # Originally written by Luke Shumaker . -#source "$RVSDIR/lib/stdio" +#source "$libexecdir/lib/stdio" # commit.d DIRNAME dir="$1" @@ -17,10 +17,10 @@ tmp=`tempfile` cd "$dir" for file in *; do - hash=`"$RVSDIR/commit" "$file"` + hash=`"$libexecdir/commit" "$file"` echo "$file:$hash" >> "$tmp" done -"$RVSDIR/commit.f" "$tmp" +"$libexecdir/commit.f" "$tmp" rm "$tmp" diff --git a/plugins/repo/commit.f.sh b/plugins/repo/commit.f.sh index ebc8214..15ba700 100644 --- a/plugins/repo/commit.f.sh +++ b/plugins/repo/commit.f.sh @@ -1,6 +1,6 @@ #!@SHELL@ -name='rvs commit.f' -ver='0.7.0' +name='rvs repo commit.f' +ver='0.7.2' # 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 @@ -9,7 +9,7 @@ ver='0.7.0' # # Originally written by Luke Shumaker . -#source "$RVSDIR/lib/stdio" +#source "$libexecdir/lib/stdio" # commit.f FILENAME file="$1" diff --git a/plugins/repo/commit.sh b/plugins/repo/commit.sh index fbfd7ca..d85dd01 100644 --- a/plugins/repo/commit.sh +++ b/plugins/repo/commit.sh @@ -1,6 +1,6 @@ #!@SHELL@ -name='rvs commit' -ver='0.7.0' +name='rvs repo commit' +ver='0.7.2' # 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 @@ -9,7 +9,7 @@ ver='0.7.0' # # Originally written by Luke Shumaker . -source "$RVSDIR/lib/stdio" +source "$libexecdir/lib/stdio" # commit FILE file=${1-.} @@ -30,7 +30,7 @@ elif [ -s $file ]; then type='s'; # socket else error "could not identify file type of \`$file'" fi -ret=`"$RVSDIR/commit.$type" "$file"` +ret=`"$libexecdir/commit.$type" "$file"` tmp=`tempfile` cat << __EOF__ > "$tmp" @@ -42,6 +42,6 @@ owner:$owner license:$license __EOF__ -"$RVSDIR/commit.f" "$tmp" +"$libexecdir/commit.f" "$tmp" rm "$tmp" diff --git a/plugins/repo/get.d.sh b/plugins/repo/get.d.sh index 9b1b5bc..834d8f5 100644 --- a/plugins/repo/get.d.sh +++ b/plugins/repo/get.d.sh @@ -1,6 +1,6 @@ #!@SHELL@ -name='rvs get.d' -ver='0.7.0' +name='rvs repo get.d' +ver='0.7.2' # 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 @@ -9,14 +9,14 @@ ver='0.7.0' # # Originally written by Luke Shumaker . -#source "$RVSDIR/lib/stdio" +#source "$libexecdir/lib/stdio" # get.d ID DIRNAME id="$1" dir="$2" tmp=`tempfile` -"$RVSDIR/get.f" "$id" "$tmp" +"$libexecdir/get.f" "$id" "$tmp" #install -d "$dir" mkdir -p "$dir" @@ -30,7 +30,7 @@ while read line; do # POSIX version hash=`echo "$line" | sed 's/^.*://'` name=`echo "$line" | sed "s/:$hash$//"` - "$RVSDIR/get" "$hash" "$name" + "$libexecdir/get" "$hash" "$name" done < "$tmp" rm "$tmp" diff --git a/plugins/repo/get.f.sh b/plugins/repo/get.f.sh index 37d7b26..c37d77f 100644 --- a/plugins/repo/get.f.sh +++ b/plugins/repo/get.f.sh @@ -1,6 +1,6 @@ #!@SHELL@ -name='rvs get.f' -ver='0.7.0' +name='rvs repo get.f' +ver='0.7.2' # 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 @@ -9,7 +9,7 @@ ver='0.7.0' # # Originally written by Luke Shumaker . -#source "$RVSDIR/lib/stdio" +#source "$libexecdir/lib/stdio" # get.f ID FILENAME id="$1" diff --git a/plugins/repo/get.sh b/plugins/repo/get.sh index fcb602a..52edc27 100644 --- a/plugins/repo/get.sh +++ b/plugins/repo/get.sh @@ -1,6 +1,6 @@ #!@SHELL@ -name='rvs get' -ver='0.7.0' +name='rvs repo get' +ver='0.7.2' # 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 @@ -9,18 +9,18 @@ ver='0.7.0' # # Originally written by Luke Shumaker . -source "$RVSDIR/lib/stdio" +source "$libexecdir/lib/stdio" # get ID [FILE] id="$1" tmp=`tempfile` -"$RVSDIR/get.f" "$id" "$tmp" +"$libexecdir/get.f" "$id" "$tmp" type="`sed -n 's/^type://p' "$tmp"`" file="${2-`sed -n 's/^name://p' "$tmp"`}" hash="`sed -n 's/^hash://p' "$tmp"`" out "-$type `pwd`/$file:$hash" -"$RVSDIR/get.$type" "$hash" "$file" +"$libexecdir/get.$type" "$hash" "$file" rm "$tmp" diff --git a/plugins/repo/lib/stdio.sh b/plugins/repo/lib/stdio.sh index 3207db8..2975440 100644 --- a/plugins/repo/lib/stdio.sh +++ b/plugins/repo/lib/stdio.sh @@ -1,6 +1,6 @@ #!@SHELL@ -#name='rvs stdio' -#ver='0.7.0' +#name='rvs repo stdio' +#ver='0.7.2' # 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 diff --git a/plugins/users/commit.sh b/plugins/users/commit.sh new file mode 100644 index 0000000..f272013 --- /dev/null +++ b/plugins/users/commit.sh @@ -0,0 +1,21 @@ +#!@SHELL@ +name='rvs users commit' +ver='0.7.2' +# 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 "$libexecdir/lib/stdio" + +ret=`$RVS repo-0.7beta/commit $@` +if [ -f "$REPO/user" ]; then + cp "$REPO/user" "$REPO/repo/$ret" + echo "$ret" +else + error 'you must be logged in to commit files' +fi + diff --git a/plugins/users/init.sh b/plugins/users/init.sh index 6d703ec..cdb291c 100644 --- a/plugins/users/init.sh +++ b/plugins/users/init.sh @@ -1,6 +1,6 @@ #!@SHELL@ -name='rvs init' -ver='0.7.0' +name='rvs users init' +ver='0.7.2' # 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 @@ -9,6 +9,8 @@ ver='0.7.0' # # Originally written by Luke Shumaker . +#source "$libexecdir/lib/stdio" + mkdir -p "$REPO"/{users,repo} cat << __EOF__ > "$REPO/users/Public Domain" author:anonymous diff --git a/plugins/users/lib/stdio.sh b/plugins/users/lib/stdio.sh new file mode 100644 index 0000000..cad1b74 --- /dev/null +++ b/plugins/users/lib/stdio.sh @@ -0,0 +1,59 @@ +#!@SHELL@ +#name='rvs users stdio' +#ver='0.7.2' +# 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 $@ >> /dev/stderr + fi +} + +out() { + if [ "$volume" != '-q' ]; then + echo $@ >> /dev/stderr + fi +} + +warn () { + echo "$name: $1" >> /dev/stderr + echo "$name: $1" >> "$repo/../rvs.log" +} + +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/login.sh b/plugins/users/login.sh new file mode 100644 index 0000000..615f4c0 --- /dev/null +++ b/plugins/users/login.sh @@ -0,0 +1,20 @@ +#!@SHELL@ +name='rvs users login' +ver='0.7.2' +# 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 "$libexecdir/lib/stdio" + +user="$1" +if [ -f "$REPO/users/$user" ]; then + install -m 644 -T "$REPO/users/$user" "$REPO/user" +else + error "User \`$user' does not exist" +fi + diff --git a/plugins/users/logout.sh b/plugins/users/logout.sh new file mode 100644 index 0000000..e3207a6 --- /dev/null +++ b/plugins/users/logout.sh @@ -0,0 +1,19 @@ +#!@SHELL@ +name='rvs users logout' +ver='0.7.2' +# 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 "$libexecdir/lib/stdio" + +if [ -f "$REPO/user" ]; then + rm "$REPO/user" +else + error 'you must be logged in to logout' +fi + diff --git a/plugins/users/mkuser.sh b/plugins/users/mkuser.sh index f07235b..6de768e 100644 --- a/plugins/users/mkuser.sh +++ b/plugins/users/mkuser.sh @@ -1,6 +1,6 @@ #!@SHELL@ -name='rvs mkuser' -ver='0.7.0' +name='rvs users mkuser' +ver='0.7.2' # 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 @@ -9,6 +9,8 @@ ver='0.7.0' # # Originally written by Luke Shumaker . +source "$libexecdir/lib/stdio" + read -p 'username: ' author echo "$author" read -p 'give copyright to: ' owner @@ -18,7 +20,7 @@ if [ "$owner" != 'Public Domain' ]; then else license='' fi -cat << __EOF__ > "$REPO/$author" +cat << __EOF__ > "$REPO/users/$author" author:$author owner:$owner license:$license diff --git a/plugins/users/rmuser.sh b/plugins/users/rmuser.sh index 85ba64a..bad801e 100644 --- a/plugins/users/rmuser.sh +++ b/plugins/users/rmuser.sh @@ -1,6 +1,6 @@ #!@SHELL@ -name='rvs rmuser' -ver='0.7.0' +name='rvs users rmuser' +ver='0.7.2' # 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 @@ -9,6 +9,12 @@ ver='0.7.0' # # Originally written by Luke Shumaker . -uname=$1 -rm "$REPO/$uname" +source "$libexecdir/lib/stdio" + +user="$1" +if [ -f "$REPO/users/$user" ]; then + rm "$REPO/users/$user" +else + error "User \`$user' does not exist" +fi diff --git a/rvs.sh b/rvs.sh index b2a3f93..c124116 100644 --- a/rvs.sh +++ b/rvs.sh @@ -1,6 +1,6 @@ #!@SHELL@ name='@name@' -ver='0.7.0' +ver='0.7.2' # 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 @@ -9,7 +9,8 @@ ver='0.7.0' # # Originally written by Luke Shumaker . -RVSDIR="@libexecdir@/$name" +RVS="$0" #RVS="@rvs@" +libexecdir="@libexecdir@/$name" _error() { echo "$name: $1" >> /dev/stderr @@ -88,8 +89,9 @@ case "$com" in while read plugin; do if [ -f "$RVSDIR/$plugin/$com" ]; then done='yes' - export RVSDIR=$RVSDIR/$plugin + export libexecdir=$libexecdir/$plugin export REPO=$repo/$plugin + export RVS $RVSDIR/$@ exit $? break -- cgit v1.2.3-2-g168b