From 30f1fbf2aab8ae6c45907bab2eafdb0e09998c15 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 28 Mar 2010 12:25:08 -0400 Subject: Rework rvs a lot (no longer needs complex C dependency tracker!) Rework ./configure, and how it uses `srcdir'. Probably broke all the other packages. Oh well, everything only half-works right now. --- config | 7 +- main.mk.in | 44 ++++++------ plugins/filedata/bin/commit | 33 +++++++++ plugins/filedata/bin/commit.sh | 33 +++++++++ plugins/filedata/bin/get | 23 +++++++ plugins/filedata/bin/get.sh | 23 +++++++ plugins/filedata/commit.sh | 33 --------- plugins/filedata/get.sh | 23 ------- plugins/filedata/info.mk.in | 1 + plugins/filedata/plugin.conf.in | 4 -- plugins/files/bin/commit | 36 ++++++++++ plugins/files/bin/commit.d.sh | 35 ++++++++++ plugins/files/bin/commit.f.sh | 32 +++++++++ plugins/files/bin/commit.sh | 36 ++++++++++ plugins/files/bin/get.d.sh | 45 +++++++++++++ plugins/files/bin/get.f.sh | 27 ++++++++ plugins/files/bin/get.sh | 34 ++++++++++ plugins/files/commit.d.sh | 35 ---------- plugins/files/commit.f.sh | 32 --------- plugins/files/commit.sh | 41 ----------- plugins/files/etc/3-d.sh | 20 ++++++ plugins/files/etc/5-f.sh | 20 ++++++ plugins/files/get.d.sh | 45 ------------- plugins/files/get.f.sh | 27 -------- plugins/files/get.sh | 34 ---------- plugins/files/info.mk.in | 1 + plugins/files/lib/stdio.sh | 66 ++++++++++++++++++ plugins/files/plugin.conf.in | 8 --- plugins/files/stdio.sh | 66 ------------------ plugins/main.mk.in | 31 ++++++--- plugins/plugin.mk.in | 53 +++++++++------ plugins/users/bin/commit.sh | 29 ++++++++ plugins/users/bin/init.sh | 28 ++++++++ plugins/users/bin/login.sh | 28 ++++++++ plugins/users/bin/logout.sh | 27 ++++++++ plugins/users/bin/mkuser.sh | 29 ++++++++ plugins/users/bin/rmuser.sh | 28 ++++++++ plugins/users/commit.sh | 29 -------- plugins/users/init.sh | 28 -------- plugins/users/lib/stdio.sh | 66 ++++++++++++++++++ plugins/users/login.sh | 28 -------- plugins/users/logout.sh | 27 -------- plugins/users/mkuser.sh | 29 -------- plugins/users/plugin.conf.in | 7 -- plugins/users/rmuser.sh | 28 -------- plugins/users/stdio.sh | 66 ------------------ wrapper/TODO | 18 ----- wrapper/main.mk.in | 57 +++++++--------- wrapper/plugin-depend.c | 146 ---------------------------------------- wrapper/plugin-depend.h | 83 ----------------------- wrapper/plugin-find.c | 103 ---------------------------- wrapper/plugin-find.h | 64 ------------------ wrapper/plugin-load.c | 78 --------------------- wrapper/plugin-load.h | 47 ------------- wrapper/plugin-parse.c | 132 ------------------------------------ wrapper/plugin-parse.h | 49 -------------- wrapper/plugin-run.c | 89 ------------------------ wrapper/plugin-run.h | 47 ------------- wrapper/plugins.c | 71 ------------------- wrapper/plugins.h | 69 ------------------- wrapper/runcom.c | 92 ------------------------- wrapper/rvs.c | 117 -------------------------------- wrapper/rvs.h | 76 --------------------- wrapper/rvs.sh | 138 +++++++++++++++++++++++++------------ 64 files changed, 899 insertions(+), 2002 deletions(-) create mode 100644 plugins/filedata/bin/commit create mode 100644 plugins/filedata/bin/commit.sh create mode 100644 plugins/filedata/bin/get create mode 100644 plugins/filedata/bin/get.sh delete mode 100644 plugins/filedata/commit.sh delete mode 100644 plugins/filedata/get.sh delete mode 100644 plugins/filedata/plugin.conf.in create mode 100644 plugins/files/bin/commit create mode 100644 plugins/files/bin/commit.d.sh create mode 100644 plugins/files/bin/commit.f.sh create mode 100644 plugins/files/bin/commit.sh create mode 100644 plugins/files/bin/get.d.sh create mode 100644 plugins/files/bin/get.f.sh create mode 100644 plugins/files/bin/get.sh delete mode 100644 plugins/files/commit.d.sh delete mode 100644 plugins/files/commit.f.sh delete mode 100644 plugins/files/commit.sh create mode 100644 plugins/files/etc/3-d.sh create mode 100644 plugins/files/etc/5-f.sh delete mode 100644 plugins/files/get.d.sh delete mode 100644 plugins/files/get.f.sh delete mode 100644 plugins/files/get.sh create mode 100644 plugins/files/lib/stdio.sh delete mode 100644 plugins/files/plugin.conf.in delete mode 100644 plugins/files/stdio.sh create mode 100644 plugins/users/bin/commit.sh create mode 100644 plugins/users/bin/init.sh create mode 100644 plugins/users/bin/login.sh create mode 100644 plugins/users/bin/logout.sh create mode 100644 plugins/users/bin/mkuser.sh create mode 100644 plugins/users/bin/rmuser.sh delete mode 100644 plugins/users/commit.sh delete mode 100644 plugins/users/init.sh create mode 100644 plugins/users/lib/stdio.sh delete mode 100644 plugins/users/login.sh delete mode 100644 plugins/users/logout.sh delete mode 100644 plugins/users/mkuser.sh delete mode 100644 plugins/users/plugin.conf.in delete mode 100644 plugins/users/rmuser.sh delete mode 100644 plugins/users/stdio.sh delete mode 100644 wrapper/TODO delete mode 100644 wrapper/plugin-depend.c delete mode 100644 wrapper/plugin-depend.h delete mode 100644 wrapper/plugin-find.c delete mode 100644 wrapper/plugin-find.h delete mode 100644 wrapper/plugin-load.c delete mode 100644 wrapper/plugin-load.h delete mode 100644 wrapper/plugin-parse.c delete mode 100644 wrapper/plugin-parse.h delete mode 100644 wrapper/plugin-run.c delete mode 100644 wrapper/plugin-run.h delete mode 100644 wrapper/plugins.c delete mode 100644 wrapper/plugins.h delete mode 100644 wrapper/runcom.c delete mode 100644 wrapper/rvs.c delete mode 100644 wrapper/rvs.h diff --git a/config b/config index afce4b7..140c270 100644 --- a/config +++ b/config @@ -1,4 +1,9 @@ _name='rvs' _RVS='$(bindir)/$(rvs)' -vars="$vars name RVS" + _sysconfdir='$(prefix)/etc/$(name)' + _BINDIR='$(sysconfdir)/bin' + _TMPDIR='$(sysconfdir)/tmp' + _LIBDIR='$(sysconfdir)/lib' + _ETCDIR='$(sysconfdir)/etc' +vars="$vars name RVS sysconfdir BINDIR TMPDIR LIBDIR ETCDIR" diff --git a/main.mk.in b/main.mk.in index 2d55793..11fca5c 100644 --- a/main.mk.in +++ b/main.mk.in @@ -17,11 +17,16 @@ ver = 0.9 # along with this program; see the file COPYING. # If not, see . -rvs = $(name) -dirs += $(libexecdir)/$(rvs) +sysconfdir ?= @sysconfdir@ +BINDIR ?= @BINDIR@ +TMPDIR ?= @TMPDIR@ +LIBDIR ?= @LIBDIR@ +ETCDIR ?= @ETCDIR@ +dirs += $(sysconfdir) $(BINDIR) $(TMPDIR) $(LIBDIR) $(ETCDIR) # phony targets ###################################################### -all : wrapper p-build +.PHONY: all +all : wrapper plugins .SUFFIXES : VPATH = $(srcdir) filelist = \ @@ -35,25 +40,11 @@ filelist = \ $(patsubst $(srcdir)/%,%,$(shell find $(srcdir)/*/* -type f)) # install ############################################################ -install : install-wrapper libexec p-install - -# $(libexecdir)/rvs/* -libexec : $(DESTDIR)$(libexecdir)/$(rvs)/plugins -$(DESTDIR)$(libexecdir)/$(rvs)/plugins : $(DESTDIR)$(libexecdir)/$(rvs) - touch $@ - -# uninstall ########################################################## - -uninstall : - $(RM) $(DESTDIR)$(bindir)/$(rvs) - $(RM) -r $(DESTDIR)$(libexecdir)/$(rvs) - -# clean ############################################################## - -clean : $(clean-plugins) clean-wrapper - -distclean : clean $(distclean-plugins) distclean-wrapper - $(RM) Makefile +install : install-wrapper install-plugins +uninstall : uninstall-wrapper uninstall-plugins +clean : clean-wrapper clean-plugins +distclean : clean distclean-wrapper distclean-plugins + $(RM) Makefile *.mk # wrapper ############################################################ @@ -69,5 +60,12 @@ $(RVS) : install-wrapper # plugins ############################################################ -p-% : plugins/Makefile ; $(MAKE) -C plugins $* +plugins : build-plugins +build-plugins : plugins/ plugins/Makefile ; $(MAKE) -C $< +uninstall-plugins : plugins/ plugins/Makefile ; $(MAKE) -C $< uninstall +clean-plugins : plugins/ plugins/Makefile ; $(MAKE) -C $< clean +distclean-plugins : plugins/ plugins/Makefile ; $(MAKE) -C $< distclean +dist-plugins : plugins/ plugins/Makefile ; $(MAKE) -C $< dist +install-plugins : plugins/ plugins/Makefile \ + plugins $(RVS) ; $(MAKE) -C $< install diff --git a/plugins/filedata/bin/commit b/plugins/filedata/bin/commit new file mode 100644 index 0000000..9b7f59a --- /dev/null +++ b/plugins/filedata/bin/commit @@ -0,0 +1,33 @@ +#!/bin/sh +name='rvs filedata commit' +ver=0.9 +# Copyright (C) 2009 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +out="$1" +file="$2" +hash="`cat /dev/stdin`" + +temp=`mktemp` +echo "Hash: $hash" > "$temp" +stat "$file" >> "$temp" + +meta=`sha1sum "$temp" | sed "s/ .*$//"` +if [ ! -f "$REPO/@ID@/$hash" ]; then + install -m 644 -o $USER -g $USER -T "$temp" "$REPO/@ID@/$meta" +fi +echo "$meta" + diff --git a/plugins/filedata/bin/commit.sh b/plugins/filedata/bin/commit.sh new file mode 100644 index 0000000..9b7f59a --- /dev/null +++ b/plugins/filedata/bin/commit.sh @@ -0,0 +1,33 @@ +#!/bin/sh +name='rvs filedata commit' +ver=0.9 +# Copyright (C) 2009 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +out="$1" +file="$2" +hash="`cat /dev/stdin`" + +temp=`mktemp` +echo "Hash: $hash" > "$temp" +stat "$file" >> "$temp" + +meta=`sha1sum "$temp" | sed "s/ .*$//"` +if [ ! -f "$REPO/@ID@/$hash" ]; then + install -m 644 -o $USER -g $USER -T "$temp" "$REPO/@ID@/$meta" +fi +echo "$meta" + diff --git a/plugins/filedata/bin/get b/plugins/filedata/bin/get new file mode 100644 index 0000000..321d5f8 --- /dev/null +++ b/plugins/filedata/bin/get @@ -0,0 +1,23 @@ +#!/bin/sh +name='rvs filedata get' +ver=0.9 +# Copyright (C) 2009 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +out="$1" + +echo "yeah, this hasn't been coded yet, sorry!" + diff --git a/plugins/filedata/bin/get.sh b/plugins/filedata/bin/get.sh new file mode 100644 index 0000000..321d5f8 --- /dev/null +++ b/plugins/filedata/bin/get.sh @@ -0,0 +1,23 @@ +#!/bin/sh +name='rvs filedata get' +ver=0.9 +# Copyright (C) 2009 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +out="$1" + +echo "yeah, this hasn't been coded yet, sorry!" + diff --git a/plugins/filedata/commit.sh b/plugins/filedata/commit.sh deleted file mode 100644 index f046db4..0000000 --- a/plugins/filedata/commit.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -name='rvs filedata commit' -ver=0.9 -# Copyright (C) 2009 Luke Shumaker -# -# This program 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 of the -# License, or (at your option) any later version. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING. -# If not, see . - -out="$1" -file="$2" -hash="`cat /dev/stdin`" - -temp=`mktemp` -echo "Hash: $hash" > "$temp" -stat "$file" >> "$temp" - -meta=`sha1sum $temp | sed "s/ .*$//"` -if [ ! -f "$REPO/@ID@/$hash" ]; then - install -m 644 -o $USER -g $USER -T "$temp" "$REPO/@ID@/$meta" -fi -echo "$meta" - diff --git a/plugins/filedata/get.sh b/plugins/filedata/get.sh deleted file mode 100644 index 321d5f8..0000000 --- a/plugins/filedata/get.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -name='rvs filedata get' -ver=0.9 -# Copyright (C) 2009 Luke Shumaker -# -# This program 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 of the -# License, or (at your option) any later version. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING. -# If not, see . - -out="$1" - -echo "yeah, this hasn't been coded yet, sorry!" - diff --git a/plugins/filedata/info.mk.in b/plugins/filedata/info.mk.in index 77643cd..0746843 100644 --- a/plugins/filedata/info.mk.in +++ b/plugins/filedata/info.mk.in @@ -1,2 +1,3 @@ name = filedata ver = 0.9 +priority = 1 diff --git a/plugins/filedata/plugin.conf.in b/plugins/filedata/plugin.conf.in deleted file mode 100644 index d7c834c..0000000 --- a/plugins/filedata/plugin.conf.in +++ /dev/null @@ -1,4 +0,0 @@ -# rvs @name@ plugins.conf -# ver=@ver@ -commit:repo-0.9/commit -get diff --git a/plugins/files/bin/commit b/plugins/files/bin/commit new file mode 100644 index 0000000..63eaac1 --- /dev/null +++ b/plugins/files/bin/commit @@ -0,0 +1,36 @@ +#!/bin/sh +name='rvs files commit' +ver=0.9 +# Copyright (C) 2009-2010 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +source "$libexecdir/@ID@/stdio" + +# commit FILE +file=${1-.} # take arg1 as the file, default to the current directory + +if [ ! -e "$file" ]; then + error "file \`$file' does not exist"; +else + foundMod='false'; + for type in select/*; do + if "$type" "$file"; then foundMod='true'; break; fi + done + if [ "$foundMod" == 'false' ]; then + error "cannot handle file type of \`$file'" + fi +fi + diff --git a/plugins/files/bin/commit.d.sh b/plugins/files/bin/commit.d.sh new file mode 100644 index 0000000..f5b432b --- /dev/null +++ b/plugins/files/bin/commit.d.sh @@ -0,0 +1,35 @@ +#!/bin/sh +name='rvs files commit.d' +ver=0.9 +# Copyright (C) 2009 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +source "$libexecdir/@ID@/stdio" + +# commit.d DIRNAME +out="$1" +dir="$2" +tmp=`mktemp` + +cd "$dir" +for file in *; do + hash=`"$RVS" commit "$file"` + echo "$file:$hash" >> "$tmp" +done + +"$RVS" commit.f "$out" "$tmp" +rm "$tmp" + diff --git a/plugins/files/bin/commit.f.sh b/plugins/files/bin/commit.f.sh new file mode 100644 index 0000000..a86e5b5 --- /dev/null +++ b/plugins/files/bin/commit.f.sh @@ -0,0 +1,32 @@ +#!/bin/sh +name='rvs files commit.f' +ver=0.9 +# Copyright (C) 2009 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +#source "$libexecdir/@ID@/stdio" + +# commit.f FILENAME +out="$1" +file="$2" + +#hash=`md5sum $file | sed "s/ .*$//"` +hash=`sha1sum $file | sed "s/ .*$//"` +if [ ! -f "$REPO/@ID@/$hash" ]; then + install -m 644 -o $USER -g $USER -T "$file" "$REPO/@ID@/$hash" +fi +echo "$hash" >> "$out" + diff --git a/plugins/files/bin/commit.sh b/plugins/files/bin/commit.sh new file mode 100644 index 0000000..63eaac1 --- /dev/null +++ b/plugins/files/bin/commit.sh @@ -0,0 +1,36 @@ +#!/bin/sh +name='rvs files commit' +ver=0.9 +# Copyright (C) 2009-2010 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +source "$libexecdir/@ID@/stdio" + +# commit FILE +file=${1-.} # take arg1 as the file, default to the current directory + +if [ ! -e "$file" ]; then + error "file \`$file' does not exist"; +else + foundMod='false'; + for type in select/*; do + if "$type" "$file"; then foundMod='true'; break; fi + done + if [ "$foundMod" == 'false' ]; then + error "cannot handle file type of \`$file'" + fi +fi + diff --git a/plugins/files/bin/get.d.sh b/plugins/files/bin/get.d.sh new file mode 100644 index 0000000..46e1eeb --- /dev/null +++ b/plugins/files/bin/get.d.sh @@ -0,0 +1,45 @@ +#!/bin/sh +name='rvs files get.d' +ver=0.9 +# Copyright (C) 2009 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +#source "$libexecdir/@ID@/stdio" + +# get.d ID DIRNAME +id="$1" +dir="$2" + +tmp=`mktemp` +"$RVS" get.f "$id" "$tmp" + +#install -d "$dir" +mkdir -p "$dir" + +cd "$dir" +rm -rf ./* +while read line; do + # GNU bash optimized version + #hash=${line/#*:/} + #name=${line/%:${hash}/} + # POSIX version + hash=`echo "$line" | sed 's/^.*://'` + name=`echo "$line" | sed "s/:$hash$//"` + "$RVS" get "$hash" "$name" +done < "$tmp" + +rm "$tmp" + diff --git a/plugins/files/bin/get.f.sh b/plugins/files/bin/get.f.sh new file mode 100644 index 0000000..e6b79d5 --- /dev/null +++ b/plugins/files/bin/get.f.sh @@ -0,0 +1,27 @@ +#!/bin/sh +name='rvs files get.f' +ver=0.9 +# Copyright (C) 2009 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +#source "$libexecdir/@ID@/stdio" + +# get.f ID FILENAME +id="$1" +file="$2" + +install -T "$REPO/@ID@/$id" "$file" + diff --git a/plugins/files/bin/get.sh b/plugins/files/bin/get.sh new file mode 100644 index 0000000..4d0d48f --- /dev/null +++ b/plugins/files/bin/get.sh @@ -0,0 +1,34 @@ +#!/bin/sh +name='rvs files get' +ver=0.9 +# Copyright (C) 2009 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +source "$libexecdir/@ID@/stdio" + +# get ID [FILE] +id="$1" +tmp=`mktemp` +"$RVS" 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" +"$RVS" get.$type "$hash" "$file" + +rm "$tmp" + diff --git a/plugins/files/commit.d.sh b/plugins/files/commit.d.sh deleted file mode 100644 index f5b432b..0000000 --- a/plugins/files/commit.d.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -name='rvs files commit.d' -ver=0.9 -# Copyright (C) 2009 Luke Shumaker -# -# This program 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 of the -# License, or (at your option) any later version. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING. -# If not, see . - -source "$libexecdir/@ID@/stdio" - -# commit.d DIRNAME -out="$1" -dir="$2" -tmp=`mktemp` - -cd "$dir" -for file in *; do - hash=`"$RVS" commit "$file"` - echo "$file:$hash" >> "$tmp" -done - -"$RVS" commit.f "$out" "$tmp" -rm "$tmp" - diff --git a/plugins/files/commit.f.sh b/plugins/files/commit.f.sh deleted file mode 100644 index a86e5b5..0000000 --- a/plugins/files/commit.f.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -name='rvs files commit.f' -ver=0.9 -# Copyright (C) 2009 Luke Shumaker -# -# This program 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 of the -# License, or (at your option) any later version. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING. -# If not, see . - -#source "$libexecdir/@ID@/stdio" - -# commit.f FILENAME -out="$1" -file="$2" - -#hash=`md5sum $file | sed "s/ .*$//"` -hash=`sha1sum $file | sed "s/ .*$//"` -if [ ! -f "$REPO/@ID@/$hash" ]; then - install -m 644 -o $USER -g $USER -T "$file" "$REPO/@ID@/$hash" -fi -echo "$hash" >> "$out" - diff --git a/plugins/files/commit.sh b/plugins/files/commit.sh deleted file mode 100644 index 32d3042..0000000 --- a/plugins/files/commit.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -name='rvs files commit' -ver=0.9 -# Copyright (C) 2009 Luke Shumaker -# -# This program 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 of the -# License, or (at your option) any later version. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING. -# If not, see . - -source "$libexecdir/@ID@/stdio" - -# commit FILE -file=${1-.} - -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 - -out "+$type `pwd`/$file" -"$RVS" commit.$type "$file" - diff --git a/plugins/files/etc/3-d.sh b/plugins/files/etc/3-d.sh new file mode 100644 index 0000000..91163dc --- /dev/null +++ b/plugins/files/etc/3-d.sh @@ -0,0 +1,20 @@ +#!/bin/sh +#name='' +#ver=0.9 +# Copyright (C) 2009-2010 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +if [ -f $file ]; then echo 'd'; fi diff --git a/plugins/files/etc/5-f.sh b/plugins/files/etc/5-f.sh new file mode 100644 index 0000000..975992a --- /dev/null +++ b/plugins/files/etc/5-f.sh @@ -0,0 +1,20 @@ +#!/bin/sh +#name='' +#ver=0.9 +# Copyright (C) 2009-2010 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +if [ -f $file ]; then echo 'f'; fi diff --git a/plugins/files/get.d.sh b/plugins/files/get.d.sh deleted file mode 100644 index 46e1eeb..0000000 --- a/plugins/files/get.d.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -name='rvs files get.d' -ver=0.9 -# Copyright (C) 2009 Luke Shumaker -# -# This program 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 of the -# License, or (at your option) any later version. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING. -# If not, see . - -#source "$libexecdir/@ID@/stdio" - -# get.d ID DIRNAME -id="$1" -dir="$2" - -tmp=`mktemp` -"$RVS" get.f "$id" "$tmp" - -#install -d "$dir" -mkdir -p "$dir" - -cd "$dir" -rm -rf ./* -while read line; do - # GNU bash optimized version - #hash=${line/#*:/} - #name=${line/%:${hash}/} - # POSIX version - hash=`echo "$line" | sed 's/^.*://'` - name=`echo "$line" | sed "s/:$hash$//"` - "$RVS" get "$hash" "$name" -done < "$tmp" - -rm "$tmp" - diff --git a/plugins/files/get.f.sh b/plugins/files/get.f.sh deleted file mode 100644 index e6b79d5..0000000 --- a/plugins/files/get.f.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -name='rvs files get.f' -ver=0.9 -# Copyright (C) 2009 Luke Shumaker -# -# This program 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 of the -# License, or (at your option) any later version. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING. -# If not, see . - -#source "$libexecdir/@ID@/stdio" - -# get.f ID FILENAME -id="$1" -file="$2" - -install -T "$REPO/@ID@/$id" "$file" - diff --git a/plugins/files/get.sh b/plugins/files/get.sh deleted file mode 100644 index 4d0d48f..0000000 --- a/plugins/files/get.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -name='rvs files get' -ver=0.9 -# Copyright (C) 2009 Luke Shumaker -# -# This program 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 of the -# License, or (at your option) any later version. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING. -# If not, see . - -source "$libexecdir/@ID@/stdio" - -# get ID [FILE] -id="$1" -tmp=`mktemp` -"$RVS" 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" -"$RVS" get.$type "$hash" "$file" - -rm "$tmp" - diff --git a/plugins/files/info.mk.in b/plugins/files/info.mk.in index d7ccb97..7552306 100644 --- a/plugins/files/info.mk.in +++ b/plugins/files/info.mk.in @@ -1,2 +1,3 @@ name = files ver = 0.9 +priority = 0 diff --git a/plugins/files/lib/stdio.sh b/plugins/files/lib/stdio.sh new file mode 100644 index 0000000..9062683 --- /dev/null +++ b/plugins/files/lib/stdio.sh @@ -0,0 +1,66 @@ +#!/bin/sh +#name='rvs files stdio' +#ver=0.9 +# Copyright (C) 2009 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +verbose() { + if [ "$volume" == '-v' ]; then + echo $@ >> /dev/stderr + fi +} + +out() { + if [ "$volume" != '-q' ]; then + echo $@ >> /dev/stderr + 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/files/plugin.conf.in b/plugins/files/plugin.conf.in deleted file mode 100644 index 2359dd5..0000000 --- a/plugins/files/plugin.conf.in +++ /dev/null @@ -1,8 +0,0 @@ -# rvs @name@ plugins.conf -# ver=@ver@ -commit -commit.d -commit.f -get -get.d -get.f diff --git a/plugins/files/stdio.sh b/plugins/files/stdio.sh deleted file mode 100644 index 9062683..0000000 --- a/plugins/files/stdio.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh -#name='rvs files stdio' -#ver=0.9 -# Copyright (C) 2009 Luke Shumaker -# -# This program 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 of the -# License, or (at your option) any later version. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING. -# If not, see . - -verbose() { - if [ "$volume" == '-v' ]; then - echo $@ >> /dev/stderr - fi -} - -out() { - if [ "$volume" != '-q' ]; then - echo $@ >> /dev/stderr - 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/main.mk.in b/plugins/main.mk.in index f0401d1..3039c1f 100644 --- a/plugins/main.mk.in +++ b/plugins/main.mk.in @@ -17,22 +17,37 @@ # along with this program; see the file COPYING. # If not, see . +sysconfdir ?= @sysconfdir@ +BINDIR ?= @BINDIR@ +TMPDIR ?= @TMPDIR@ +LIBDIR ?= @LIBDIR@ +ETCDIR ?= @ETCDIR@ +dirs += $(sysconfdir) $(BINDIR) $(TMPDIR) $(LIBDIR) $(ETCDIR) + mods = $(patsubst ./%,%,$(shell find ./* -maxdepth 0 -type d)) +mods-build = $(addprefix build-,$(mods)) +mods-install = $(addprefix install-,$(mods)) +mods-clean = $(addprefix clean-,$(mods)) +mods-distclean = $(addprefix distclean-,$(mods)) .PHONY : all all : build -.PHONY : install build -install : $(addprefix install-,$(mods)) -build : $(addprefix build-,$(mods)) +.PHONY : build install clean distclean +# $(mods-build) $(mods-install) $(mods-clean) $(mods-distclean) +build : $(mods-build) +install : $(mods-install) +clean : $(mods-clean) +distclean : $(mods-distclean) + $(RM) Makefile *.mk .SECONDARY: %/main.mk : plugin.mk %/; cp $< $@ -complete-% : %/ %/main.mk; : -build-% : %/ complete-% %/main.mk; $(MAKE) -C $< -install-% : %/ complete-% %/main.mk; $(MAKE) -C $< install -clean-% : %/ complete-% %/main.mk; $(MAKE) -C $< clean -distclean-% : %/ complete-% %/main.mk; $(MAKE) -C $< distclean +complete-% : %/ %/main.mk; : +build-% : %/ complete-% %/main.mk; $(MAKE) -C $< +install-% : %/ complete-% %/main.mk; $(MAKE) -C $< install +clean-% : %/ complete-% %/main.mk; -$(MAKE) -C $< clean +distclean-% : %/ complete-% %/main.mk; $(MAKE) -C $< distclean diff --git a/plugins/plugin.mk.in b/plugins/plugin.mk.in index 6980538..8af5fcc 100644 --- a/plugins/plugin.mk.in +++ b/plugins/plugin.mk.in @@ -18,37 +18,51 @@ include info.mk # this contains the actuall name/version for the plugin # along with this program; see the file COPYING. # If not, see . +sysconfdir ?= @sysconfdir@ +BINDIR ?= @BINDIR@ +TMPDIR ?= @TMPDIR@ +LIBDIR ?= @LIBDIR@ +ETCDIR ?= @ETCDIR@ +dirs += $(sysconfdir) $(BINDIR) $(TMPDIR) $(LIBDIR) $(ETCDIR) + rvs = @name@ id = $(name)-$(ver) # phony targets #################################################### all : $(name) -.PHONY : $(name) install uninstall clean distclean dist +.PHONY : $(name) install uninstall clean distclean .SUFFIXES : # build ############################################################ -mysrcdir = $(srcdir)/plugins/$(name) -myoutdir = out +$(info srcdir:$(srcdir)) -srcFiles = $(filter-out %/Makefile.in,$(shell find $(mysrcdir)/ -type f)) +srcFiles = $(filter-out %/Makefile.in,$(shell find $(srcdir)/ -type f)) shSrcFiles = $(filter %.sh,$(srcFiles)) -shOutFiles = $(patsubst $(mysrcdir)/%,$(myoutdir)/%,$(basename $(shSrcFiles))) +shOutFiles = $(patsubst $(srcdir)/%,%,$(basename $(shSrcFiles))) -$(name) : $(myoutdir) $(shOutFiles) $(myoutdir)/plugin.conf - -$(myoutdir)/plugin.conf : $(mysrcdir)/plugin.conf.in - $(INSTALL_DATA) $< $@ - $(SED) -i \ - -e 's/$bname@/$(subst /,\/,$(name))/g' \ - -e 's/$bver@/$(subst /,\/,$(ver))/g' \ - $@ +outFiles = $(shOutFiles) +outBin = $(addprefix bin-,$(notdir $(filter bin/%,$(outFiles)))) +outEtc = $(addprefix $(ETCDIR)/$(name),$(notdir $(filter etc/%,$(outFiles)))) +outLib = $(addprefix $(LIBDIR)/$(name),$(notdir $(filter lib/%,$(outFiles)))) +$(name) : $(myoutdir) $(shOutFiles) # (un)install ###################################################### -install : all - $(RVS) install $(name)-$(ver) $(myoutdir) +install : $(outBin) $(outEtc) $(outLib) + +unbin-% : bin/% + $(RVS) uninstall $(notdir $<) $(name) + +bin-% : bin/% + $(RVS) install $< $(notdir $<) $(name) $(priority) + +$(ECTDIR)/$(name)/% : etc/% + $(CP) $< $@ + +$(LIBDIR)/$(name)/% : lib/% + $(CP) $< $@ uninstall : $(RVS) uninstall $(name) @@ -58,14 +72,14 @@ uninstall : clean : distclean : clean - $(RM) Makefile - $(RM) -r out + find ./ -name Makefile -exec $(RM) '{}' \; + find ./ -name '*.mk' -exec $(RM) '{}' \; # implicit rules ################################################### b := @ # build shell scripts -$(myoutdir)/% : $(mysrcdir)/%.sh $(myoutdir) +% : %.sh $(INSTALL_PROGRAM) $< $@ $(SED) -i \ -e 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' \ @@ -73,6 +87,3 @@ $(myoutdir)/% : $(mysrcdir)/%.sh $(myoutdir) -e 's/$bID@/$(subst /,\/,$(id))/g' \ $@ -$(DESTDIR)$(libexecdir)/$(rvs) $(myoutdir) : - $(MKDIR) $@ - diff --git a/plugins/users/bin/commit.sh b/plugins/users/bin/commit.sh new file mode 100644 index 0000000..1fa2e52 --- /dev/null +++ b/plugins/users/bin/commit.sh @@ -0,0 +1,29 @@ +#!/bin/sh +name='rvs users commit' +ver=0.9 +# Copyright (C) 2009 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +source "$libexecdir/@ID@/stdio" + +ret=`$RVS repo-0.7beta/commit $@` +if [ -f "$REPO/@ID@/user" ]; then + cp "$REPO/@ID@/user" "$REPO/@ID@/repo/$ret" + echo "$ret" +else + error 'you must be logged in to commit files' +fi + diff --git a/plugins/users/bin/init.sh b/plugins/users/bin/init.sh new file mode 100644 index 0000000..142f54c --- /dev/null +++ b/plugins/users/bin/init.sh @@ -0,0 +1,28 @@ +#!/bin/sh +name='rvs users init' +ver=0.9 +# Copyright (C) 2009 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +#source "$libexecdir/@ID@/stdio" + +mkdir -p "$REPO/@ID@"/{users,repo} +cat << __EOF__ > "$REPO/@ID@/users/Public Domain" +author:anonymous +owner:Public Domain +license: +__EOF__ + diff --git a/plugins/users/bin/login.sh b/plugins/users/bin/login.sh new file mode 100644 index 0000000..40a5830 --- /dev/null +++ b/plugins/users/bin/login.sh @@ -0,0 +1,28 @@ +#!/bin/sh +name='rvs users login' +ver=0.9 +# Copyright (C) 2009 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +source "$libexecdir/@ID@/stdio" + +user="$1" +if [ -f "$REPO/@ID@/users/$user" ]; then + install -m 644 -T "$REPO/@ID@/users/$user" "$REPO/@ID@/../user" +else + error "User \`$user' does not exist" +fi + diff --git a/plugins/users/bin/logout.sh b/plugins/users/bin/logout.sh new file mode 100644 index 0000000..260846e --- /dev/null +++ b/plugins/users/bin/logout.sh @@ -0,0 +1,27 @@ +#!/bin/sh +name='rvs users logout' +ver=0.9 +# Copyright (C) 2009 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +source "$libexecdir/@ID@/stdio" + +if [ -f "$REPO/@ID@/../user" ]; then + rm "$REPO/@ID@/../user" +else + error 'you must be logged in to logout' +fi + diff --git a/plugins/users/bin/mkuser.sh b/plugins/users/bin/mkuser.sh new file mode 100644 index 0000000..6f72ea9 --- /dev/null +++ b/plugins/users/bin/mkuser.sh @@ -0,0 +1,29 @@ +#!/bin/sh +name='rvs users mkuser' +ver=0.9 +# 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. + +source "$libexecdir/@ID@/stdio" + +author="$1" +touch "$REPO/@ID@/users/$author" +cat << __EOF__ > "$REPO/@ID@/users/$author" +author:$author +__EOF__ + diff --git a/plugins/users/bin/rmuser.sh b/plugins/users/bin/rmuser.sh new file mode 100644 index 0000000..604f359 --- /dev/null +++ b/plugins/users/bin/rmuser.sh @@ -0,0 +1,28 @@ +#!/bin/sh +name='rvs users rmuser' +ver=0.9 +# Copyright (C) 2009 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +source "$libexecdir/@ID@/stdio" + +user="$1" +if [ -f "$REPO/@ID@/users/$user" ]; then + rm "$REPO/@ID@/users/$user" +else + error "User \`$user' does not exist" +fi + diff --git a/plugins/users/commit.sh b/plugins/users/commit.sh deleted file mode 100644 index 1fa2e52..0000000 --- a/plugins/users/commit.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -name='rvs users commit' -ver=0.9 -# Copyright (C) 2009 Luke Shumaker -# -# This program 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 of the -# License, or (at your option) any later version. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING. -# If not, see . - -source "$libexecdir/@ID@/stdio" - -ret=`$RVS repo-0.7beta/commit $@` -if [ -f "$REPO/@ID@/user" ]; then - cp "$REPO/@ID@/user" "$REPO/@ID@/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 deleted file mode 100644 index 142f54c..0000000 --- a/plugins/users/init.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -name='rvs users init' -ver=0.9 -# Copyright (C) 2009 Luke Shumaker -# -# This program 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 of the -# License, or (at your option) any later version. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING. -# If not, see . - -#source "$libexecdir/@ID@/stdio" - -mkdir -p "$REPO/@ID@"/{users,repo} -cat << __EOF__ > "$REPO/@ID@/users/Public Domain" -author:anonymous -owner:Public Domain -license: -__EOF__ - diff --git a/plugins/users/lib/stdio.sh b/plugins/users/lib/stdio.sh new file mode 100644 index 0000000..edf7c01 --- /dev/null +++ b/plugins/users/lib/stdio.sh @@ -0,0 +1,66 @@ +#!/bin/sh +#name='rvs users stdio' +#ver=0.9 +# Copyright (C) 2009 Luke Shumaker +# +# This program 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 of the +# License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . + +verbose() { + if [ "$volume" == '-v' ]; then + echo $@ >> /dev/stderr + 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/login.sh b/plugins/users/login.sh deleted file mode 100644 index 40a5830..0000000 --- a/plugins/users/login.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -name='rvs users login' -ver=0.9 -# Copyright (C) 2009 Luke Shumaker -# -# This program 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 of the -# License, or (at your option) any later version. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING. -# If not, see . - -source "$libexecdir/@ID@/stdio" - -user="$1" -if [ -f "$REPO/@ID@/users/$user" ]; then - install -m 644 -T "$REPO/@ID@/users/$user" "$REPO/@ID@/../user" -else - error "User \`$user' does not exist" -fi - diff --git a/plugins/users/logout.sh b/plugins/users/logout.sh deleted file mode 100644 index 260846e..0000000 --- a/plugins/users/logout.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -name='rvs users logout' -ver=0.9 -# Copyright (C) 2009 Luke Shumaker -# -# This program 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 of the -# License, or (at your option) any later version. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING. -# If not, see . - -source "$libexecdir/@ID@/stdio" - -if [ -f "$REPO/@ID@/../user" ]; then - rm "$REPO/@ID@/../user" -else - error 'you must be logged in to logout' -fi - diff --git a/plugins/users/mkuser.sh b/plugins/users/mkuser.sh deleted file mode 100644 index 6f72ea9..0000000 --- a/plugins/users/mkuser.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -name='rvs users mkuser' -ver=0.9 -# 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. - -source "$libexecdir/@ID@/stdio" - -author="$1" -touch "$REPO/@ID@/users/$author" -cat << __EOF__ > "$REPO/@ID@/users/$author" -author:$author -__EOF__ - diff --git a/plugins/users/plugin.conf.in b/plugins/users/plugin.conf.in deleted file mode 100644 index 9b1b35c..0000000 --- a/plugins/users/plugin.conf.in +++ /dev/null @@ -1,7 +0,0 @@ -# rvs @name@ plugins.conf -# ver=@ver@ -commit:repo-0.9/commit -login -logout -mkuser -rmuser diff --git a/plugins/users/rmuser.sh b/plugins/users/rmuser.sh deleted file mode 100644 index 604f359..0000000 --- a/plugins/users/rmuser.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -name='rvs users rmuser' -ver=0.9 -# Copyright (C) 2009 Luke Shumaker -# -# This program 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 of the -# License, or (at your option) any later version. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING. -# If not, see . - -source "$libexecdir/@ID@/stdio" - -user="$1" -if [ -f "$REPO/@ID@/users/$user" ]; then - rm "$REPO/@ID@/users/$user" -else - error "User \`$user' does not exist" -fi - diff --git a/plugins/users/stdio.sh b/plugins/users/stdio.sh deleted file mode 100644 index edf7c01..0000000 --- a/plugins/users/stdio.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh -#name='rvs users stdio' -#ver=0.9 -# Copyright (C) 2009 Luke Shumaker -# -# This program 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 of the -# License, or (at your option) any later version. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING. -# If not, see . - -verbose() { - if [ "$volume" == '-v' ]; then - echo $@ >> /dev/stderr - 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/wrapper/TODO b/wrapper/TODO deleted file mode 100644 index b1ab1d9..0000000 --- a/wrapper/TODO +++ /dev/null @@ -1,18 +0,0 @@ -#! /bin/less - -* plugin-run.h: - the function _plugin_sh_mktemp() is an ugly hack, it exists - because - a) it is secure - b) it is easier to write a hack using methods I understand, - than learn those I don't - c) point `b' especially when I just want to get it working. - d) point `b' especially since I think I coded it in - studyhall one day, which means I didn't have internet - access (no glibc documenation). -* everything: - with plugin commands, have arg1 be a file to write output to - -~ Luke Shumaker -Happy Hacking! - diff --git a/wrapper/main.mk.in b/wrapper/main.mk.in index ecc6cc6..0f24d6b 100644 --- a/wrapper/main.mk.in +++ b/wrapper/main.mk.in @@ -17,59 +17,48 @@ ver = 0.9 # along with this program; see the file COPYING. # If not, see . -rvs = @name@ -dirs += $(libexecdir)/$(rvs) - -CFLAGS = -g \ - -DNAME=\"$(name)\" \ - -DVER=\"$(ver)\" \ - -Dlibexecdir=\"$(libexecdir)/$(rvs)\" \ - -Dplugin_conf=\"plugin.conf\" +sysconfdir ?= @sysconfdir@ +BINDIR ?= @BINDIR@ +TMPDIR ?= @TMPDIR@ +LIBDIR ?= @LIBDIR@ +ETCDIR ?= @ETCDIR@ +dirs += $(sysconfdir) $(BINDIR) $(TMPDIR) $(LIBDIR) $(ETCDIR) # phony targets #################################################### -all : Makefiles rvs runcom -.PHONY : install uninstall clean distclean dist install-runcom -.SUFFIXES : .c .o -VPATH = $(srcdir)/wrapper -filelist=$(patsubst $(srcdir)/wrapper/%,%,$(shell find $(srcdir)/wrapper/* -type f)) +.PHONY : all +all : Makefiles rvs +VPATH = $(srcdir) +filelist=$(patsubst $(srcdir)/%,%,$(shell find $(srcdir)/* -type f)) # most everything ################################################## -RUNCOM = $(DESTDIR)$(libexecdir)/$(rvs)/runcom -install : $(RVS) $(RUNCOM) -$(RVS) : rvs $(dir $(RVS)) - $(INSTALL_PROGRAM) $< $@ - -OBJ = runcom.o rvs.o plugins.o \ - plugin-depend.o \ - plugin-find.o \ - plugin-load.o \ - plugin-parse.o \ - plugin-run.o \ -runcom: $(OBJ) - $(CC) -o $@ $^ - -$(RUNCOM): runcom $(dir $(RUNCOM)) +# the installed wrapper +$(RVS) : rvs $(dir $(RVS)) $(INSTALL_PROGRAM) $< $@ +# build the wrapper b := @ -# build shell scripts rvs : rvs.sh $(INSTALL_PROGRAM) $< $@ $(SED) -i \ -e 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' \ - -e 's/$bname@/$(rvs)/g' \ - -e 's/$blibexecdir@/$(subst /,\/,$(libexecdir))/g' \ + -e 's/$bname@/$(subst /,\/,$(rvs))/g' \ + -e 's/$bBINDIR@/$(subst /,\/,$(BINDIR))/' \ + -e 's/$bTMPDIR@/$(subst /,\/,$(TMPDIR))/' \ + -e 's/$bLIBDIR@/$(subst /,\/,$(LIBDIR))/' \ + -e 's/$bETCDIR@/$(subst /,\/,$(ETCDIR))/' \ $@ +# standard targes #################################################### +.PHONY : install uninstall clean distclean +install : $(RVS) + uninstall : $(RM) $(RVS) - $(RM) $(DESTDIR)$(libexecdir)/$(rvs)/runcom clean : - $(RM) *.o *.d distclean : clean $(RM) rvs - $(RM) Makefile + $(RM) Makefile *.mk diff --git a/wrapper/plugin-depend.c b/wrapper/plugin-depend.c deleted file mode 100644 index de21a93..0000000 --- a/wrapper/plugin-depend.c +++ /dev/null @@ -1,146 +0,0 @@ -/* wrapper/plugin-depend.c -- load a command dependancy tree - system depends: - 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. -*/ - -#include -#include - -#include "rvs.h" -#include "plugin-find.h" - -#include "plugin-depend.h" - -/* translates a string in format `plugin/command' into a pointer to the command - DON'T plan on using the string again, it will be mutilated! - (so we go ahead and free() it and set the pointer to NULL) */ -struct plugin_command * -plugin_depend_parse (char **string, - struct plugin *plugins, - struct plugin_command *root) -{ - struct plugin_command *command=NULL; - - if (*string==NULL) - command=root; - else { - /* *string is in the format `plugin/command' */ - /* char *del=delimeter */ - char *del=strchr(*string,'/'); - del[0]='\0'; - /* *string = PLUGIN_NAME */ - /* &del[1] = COMMAND_NAME */ - struct plugin *plugin; - plugin =plugin_find_plugin(plugins, *string ); - if (plugin==NULL) - error(EXIT_FAILURE,0,"cannot find plugin `%s'",*string); - command=plugin_find_plugin_command(plugin->commands, &del[1] ); - if (command==NULL) - error(EXIT_FAILURE,0, - "plugin `%s' does not contain command `%s'", - *string,&del[1]); - xfree(*string); - *string=NULL; - } - return command; -} - -/* used by plugin_depend_add */ -void -_plugin_depend_add (struct plugin_command *prev, - struct plugin_command *next) -{ - if (prev->d_next==NULL) { - prev->d_next=next; - } else { - _plugin_depend_add(prev->d_next,next); - } -} - -/* plugin_depend_add(depend,depender) */ -void -plugin_depend_add (struct plugin_command *depend, - struct plugin_command *depender) -{ - if (depend->d_child==NULL) { - depend->d_child=depender; - } else { - _plugin_depend_add(depend->d_child,depender); - } -} - -/* take care of depends for `command' */ -void -plugin_depend_command (struct plugin_command *command, - struct plugin *plugins, - struct plugin_command *root, int ind) -{ - if (command!=NULL) { - if (command->depend == NULL) { - /* the depend still needs to be parsed */ - command->depend=plugin_depend_parse( - &(command->depends),plugins,root); - } - plugin_depend_add(command->depend,command); - } -} - -/* take care of commands for a `plugin', and those after it (linked list) */ -void -plugin_depend_plugin_all (struct plugin *plugin, - struct plugin *plugins, - struct plugin_command *root) -{ - plugin_depend_command(plugin->commands,plugins,root,0); - if (plugin->next != NULL) { - plugin_depend_plugin_all(plugin->next,plugins,root); - } -} - -/* take care of all depends */ -struct plugin_command * -plugin_depend_all (struct plugin *plugins) -{ - struct plugin_command *root=plugin_mk_command(); - - plugin_depend_plugin_all(plugins,plugins,root); - return root; -} - -void -_plugin_depend_list (struct plugin_command_list *commands, - struct plugin *plugins, - struct plugin_command *root,int ind) -{ - if (commands!=NULL) { - plugin_depend_command(commands->command,plugins,root,ind++); - _plugin_depend_list(commands->next,plugins,root,ind++); - } -} - -struct plugin_command * -plugin_depend_list (struct plugin_command_list *commands, - struct plugin *plugins) -{ - struct plugin_command *root=plugin_mk_command(); - _plugin_depend_list(commands,plugins,root,0); - return root; -} - diff --git a/wrapper/plugin-depend.h b/wrapper/plugin-depend.h deleted file mode 100644 index 580c03f..0000000 --- a/wrapper/plugin-depend.h +++ /dev/null @@ -1,83 +0,0 @@ -/* wrapper/plugin-parse.h -- parse rvs plugin config files - system depends: - 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. -*/ -#ifndef FILE_plugin_depend_h_SEEN -#define FILE_plugin_depend_h_SEEN - -#include "plugins.h" -#include "plugin-find.h" - -/* translates a string in format `plugin/command' into a pointer to the command - DON'T plan on using the string again, it will be mutilated! - (so we go ahead and free() it and set the pointer to NULL) */ -extern -struct plugin_command * -plugin_depend_parse (char **string, - struct plugin *plugins, - struct plugin_command *root); - -/* used by plugin_depend_add */ -extern -void -_plugin_depend_add (struct plugin_command *prev, - struct plugin_command *next); - -/* plugin_depend_add(depend,depender) */ -extern -void -plugin_depend_add (struct plugin_command *depend, - struct plugin_command *depender); - -/* take care of depends for `command' */ -extern -void -plugin_depend_command (struct plugin_command *command, - struct plugin *plugins, - struct plugin_command *root, int ind); - -/* take care of commands for a `plugin', and those after it (linked list) */ -extern -void -plugin_depend_plugin_all (struct plugin *plugin, - struct plugin *plugins, - struct plugin_command *root); - -/* take care of all depends */ -extern -struct plugin_command * -plugin_depend_all (struct plugin *plugins); - -extern -void -_plugin_depend_list (struct plugin_command_list *commands, - struct plugin *plugins, - struct plugin_command *root,int ind); - -extern -struct plugin_command * -plugin_depend_list (struct plugin_command_list *commands, - struct plugin *plugins); - - - - -#endif - diff --git a/wrapper/plugin-find.c b/wrapper/plugin-find.c deleted file mode 100644 index 98e16af..0000000 --- a/wrapper/plugin-find.c +++ /dev/null @@ -1,103 +0,0 @@ -/* wrapper/plugin-find.h -- search functions for rvs plugins - system depends: - 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. -*/ - -#include /* only uses `strcmp' */ - -#include "rvs.h" -#include "plugins.h" - -#include "plugin-find.h" - -/* returns first plugin with `name' (duplicates are... unwise) */ -struct plugin * -plugin_find_plugin(struct plugin *node, char *name) -{ - - if (node==NULL) - return node; - else { - if (strcmp(node->name,name) == 0) - return node; - else - return plugin_find_plugin(node->next,name); - } -} - -/* returns plugin `name within plugin `node' */ -struct plugin_command * -plugin_find_plugin_command(struct plugin_command *node, char *name) -{ - if (node==NULL) - return node; - else { - if (strcmp(node->name,name) == 0) - return node; - else - return plugin_find_plugin_command(node->next,name); - } -} - -/* returns the first command with `name' it finds */ -struct plugin_command * -plugin_find_command(struct plugin *plugin, char *name) -{ - if (plugin==NULL) - return NULL; - else { - struct plugin_command *ret; - ret=plugin_find_plugin_command(plugin->commands,name); - if (ret == NULL) - ret=plugin_find_command(plugin->next,name); - return ret; - } -} - -/* returns a linked list of all commands with `name' it finds */ -struct plugin_command_list * -plugin_find_commands(struct plugin *plugin, char *name) -{ - if (plugin==NULL) - return NULL; - else { - struct plugin_command *command; - command=plugin_find_command(plugin,name); - struct plugin_command_list *node; - if (command==NULL) - node=plugin_find_commands(plugin->next,name); - else { - node=xmalloc( sizeof *node ); - node->command=command; - node->next=plugin_find_commands(plugin->next,name); - } - return node; - } -} - -void -plugin_free_list(struct plugin_command_list *node) -{ - if (node!=NULL) { - plugin_free_list(node->next); - xfree(node); - } -} - diff --git a/wrapper/plugin-find.h b/wrapper/plugin-find.h deleted file mode 100644 index 0185117..0000000 --- a/wrapper/plugin-find.h +++ /dev/null @@ -1,64 +0,0 @@ -/* wrapper/plugin-find.h -- search functions for rvs plugins - system depends: - 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. -*/ -#ifndef FILE_plugin_find_h_SEEN -#define FILE_plugin_find_h_SEEN - -#include /* only uses `strcmp' */ - -#include "rvs.h" -#include "plugins.h" - -/*------------------------------struct------------------------------*/ -/* a linked list of commands, for use by `plugin_find_commands' */ -struct plugin_command_list -{ - struct plugin_command *command; - struct plugin_command_list *next; -}; - -/*-----------------------------function-----------------------------*/ -/* returns first plugin with `name' (duplicates are... unwise) */ -extern -struct plugin * -plugin_find_plugin(struct plugin *node, char *name); - -/* returns plugin `name within plugin `node' */ -extern -struct plugin_command * -plugin_find_plugin_command(struct plugin_command *node, char *name); - -/* returns the first command with `name' it finds */ -extern -struct plugin_command * -plugin_find_command(struct plugin *plugin, char *name); - -/* returns a linked list of all commands with `name' it finds */ -extern -struct plugin_command_list * -plugin_find_commands(struct plugin *plugin, char *name); - -extern -void -plugin_free_list(struct plugin_command_list *node); - -#endif - diff --git a/wrapper/plugin-load.c b/wrapper/plugin-load.c deleted file mode 100644 index 142fcd5..0000000 --- a/wrapper/plugin-load.c +++ /dev/null @@ -1,78 +0,0 @@ -/* wrapper/plugin-load.h -- load rvs plugins into mem - system depens: , GNU - 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. -*/ - -#include -#include - -#include "rvs.h" -#include "plugins.h" -#include "plugin-parse.h" - -#include "plugin-load.h" - -/*- plugin_load ----------------------------------------------------*\ - now, load plugin plug_name, -\* whose configuration file is plugin_conf */ -struct plugin * -plugin_load (const char *plug_name) -{ - struct plugin *plugin=xmalloc( sizeof(*plugin) ); - plugin->name=stralloc(plug_name); - plugin->next=NULL; - - xchdir(plug_name); - FILE *file = xfopen(plugin_conf,"r"); - plugin->commands=plugin_parse(plugin, file); - fclose( file ); - xchdir(".."); - - return plugin; -} - -/*- load_plugins ---------------------------------------------------*\ - Load all the plugins - assume we're in rvs's libexecdir, where plugins are -\* Use `plugin_conf' as the name of the config file for each plugin */ - -struct plugin * -load_plugins (FILE *list) -{ - struct plugin *first=NULL; /* we return this */ - struct plugin **prev=&first; /* this is the previous plugin->next */ - struct plugin *plugin; /* this is the current plugin */ - - size_t nbytes = 10; - char *plug_name=(char *)xmalloc(nbytes); - while ( getline(&plug_name, &nbytes, list) > 0 ) { - char *del=strchr(plug_name,'\n'); - del[0]='\0'; - /*if (strlen(plug_name)!=0) {*/ - if (plug_name[0]!='\0') {; - plugin=plugin_load(plug_name); - *prev=plugin;/* this sets the last's `next' */ - prev=&plugin->next; - } - } - - return first; -} - diff --git a/wrapper/plugin-load.h b/wrapper/plugin-load.h deleted file mode 100644 index f214151..0000000 --- a/wrapper/plugin-load.h +++ /dev/null @@ -1,47 +0,0 @@ -/* wrapper/plugin-load.h -- load rvs plugins into mem - system depens: , GNU - 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. -*/ -#ifndef FILE_plugin_load_h_SEEN -#define FILE_plugin_load_h_SEEN - -#include -#include - -#include "rvs.h" -#include "plugins.h" -#include "plugin-parse.h" - -/*- plugin_load ----------------------------------------------------*\ - now, load plugin plug_name, -\* whose configuration file is plugin_conf */ -extern -struct plugin * -plugin_load (const char *plug_name); - -/*- load_plugins ---------------------------------------------------*\ - Load all the plugins - assume we're in rvs's libexecdir, where plugins are -\* Use `plugin_conf' as the name of the config file for each plugin */ -extern -struct plugin * -load_plugins (FILE *list); -#endif - diff --git a/wrapper/plugin-parse.c b/wrapper/plugin-parse.c deleted file mode 100644 index 4a35586..0000000 --- a/wrapper/plugin-parse.c +++ /dev/null @@ -1,132 +0,0 @@ -/* wrapper/plugin-parse.c -- parse rvs plugin config files - system depends: - 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. -*/ - -#include -#include -#include /* only used in `plugin_parse_escape' for `error' */ - -#include "rvs.h" -#include "plugins.h" - -#include "plugin-parse.h" - -void -plugin_parse_comment (FILE *file) -{ - char c; - while ( (c=getc(file)) != EOF ) { - if ( c == '\n' ) { - ungetc (c, file); - break; - } - } -} - -char -plugin_parse_escape(FILE *file) -{ - char c=getc(file); - switch (c) { - case 'n': - c = '\n'; - case '\\': - case '#': - case ':': - break; - default: - error(EXIT_FAILURE,0,"syntax error"); - break; - } - return c; -} - -#define _parse_share(string) \ - case '#':\ - plugin_parse_comment(file);\ - break;\ - case '\\':\ - c[0]=plugin_parse_escape(file);\ - default:\ - stradds(&nbytes,string,(char *)&c);\ - break; - -char * -plugin_parse_depend (FILE *file) -{ - size_t nbytes = 10; - char *string = (char *)xmalloc(nbytes); - string[0]='\0'; - - char c[2] = " \0"; - while ( (c[0]=getc(file)) != EOF ) { - switch (c[0]) { - case '\n': - ungetc (c[0], file); - return string; - break; - _parse_share(&string) - } - } - return string; -} - -struct plugin_command * -plugin_parse (struct plugin *plugin, FILE *file) -{ - struct plugin_command *command; - - char c[2] = " \0"; - c[0]=getc(file); - - if (c[0]==EOF) - command=NULL; - else { - ungetc (c[0], file); - command=plugin_mk_command(); - command->plugin=plugin; - - size_t nbytes = 10; - command->name = (char *)xmalloc(nbytes); - command->name[0]='\0'; - - while ( (c[0]=getc(file)) != EOF ) { - switch (c[0]) { - case '\n': - /*if (strlen(command->name)==0) {*/ - if (command->name[0]=='\0') { - plugin_free_command(command); - return plugin_parse(plugin,file); - } else - command->next=plugin_parse( - plugin,file); - break; - case ':': - command->depends=plugin_parse_depend( - file); - break; - _parse_share(&(command->name)) - } - } - } - return command; -} - diff --git a/wrapper/plugin-parse.h b/wrapper/plugin-parse.h deleted file mode 100644 index 67ee06f..0000000 --- a/wrapper/plugin-parse.h +++ /dev/null @@ -1,49 +0,0 @@ -/* wrapper/plugin-parse.c -- parse rvs plugin config files - system depends: - 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. -*/ -#ifndef FILE_plugin_parse_h_SEEN -#define FILE_plugin_parse_h_SEEN - -#include -#include -#include /* only used in `plugin_parse_escape' for `error' */ - -#include "rvs.h" -#include "plugins.h" - -extern -void -plugin_parse_comment (FILE *file); - -extern -char -plugin_parse_escape(FILE *file); - -extern -char * -plugin_parse_depend (FILE *file); - -extern -struct plugin_command * -plugin_parse (struct plugin *plugin, FILE *file); - -#endif - diff --git a/wrapper/plugin-run.c b/wrapper/plugin-run.c deleted file mode 100644 index 26d4480..0000000 --- a/wrapper/plugin-run.c +++ /dev/null @@ -1,89 +0,0 @@ -/* wrapper/plugin-run.c -- run a heiarchy of commands - system depens: - 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. -*/ - -#include -#include - -#include "rvs.h" -#include "plugins.h" -#include "plugin-find.h" - -#include "plugin-run.h" - -/* this function is an ugly hack */ -char * -_plugin_sh_mktemp() -{ - size_t nbytes = 10; - char *string = (char *)malloc(nbytes); - string[0]='\0'; - - FILE *out=popen("mktemp -t rvs-XXXXXXXXXX","r"); - char c[2]=" \0"; - while ( (c[0]=getc(out)) != '\n' ) { - stradds(&nbytes,&string,(char *)&c); - } - pclose(out); - return string; -} - -void -plugin_run_command(struct plugin_command *command, char *args, char *depfile) -{ - if (command!=NULL) { - char *outfile=_plugin_sh_mktemp(); - /* make command string: - `libexecdir/plugin_name/command < depfile > outfile' - */ - int nbytes=20; - char *coms=(char *)xmalloc(nbytes); - coms[0]='\0'; - stradds(&nbytes,&coms,libexecdir); - stradds(&nbytes,&coms,"/"); - stradds(&nbytes,&coms,command->plugin->name); - stradds(&nbytes,&coms,"/"); - stradds(&nbytes,&coms,command->name); - stradds(&nbytes,&coms," "); - stradds(&nbytes,&coms,args); - stradds(&nbytes,&coms," < "); - stradds(&nbytes,&coms,depfile); - stradds(&nbytes,&coms," > "); - stradds(&nbytes,&coms,outfile); - - xsystem(coms); - xfree(coms); - plugin_run_command(command->d_child,args,outfile); - xfree(outfile); - plugin_run_command(command->d_next ,args,depfile); - } -} - -/* needs to take the root command */ -void -plugin_run(struct plugin_command *command,char *args) -{ - /*plugin_run_command(command->d_child,"/dev/null");*/ - char *outfile=_plugin_sh_mktemp(); - plugin_run_command(command->d_child,args,outfile); - xfree(outfile); -} - diff --git a/wrapper/plugin-run.h b/wrapper/plugin-run.h deleted file mode 100644 index 99beff4..0000000 --- a/wrapper/plugin-run.h +++ /dev/null @@ -1,47 +0,0 @@ -/* wrapper/plugin-run.h -- run a heiarchy of commands - system depens: - 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. -*/ -#ifndef FILE_plugin_run_h_SEEN -#define FILE_plugin_run_h_SEEN - -#include -#include - -#include "rvs.h" -#include "plugins.h" -#include "plugin-find.h" - -/* this function is an ugly hack */ -extern -char * -_plugin_sh_mktemp(); - -extern -void -plugin_run_command(struct plugin_command *command, char *args, char *depfile); - -/* needs to take the root command */ -extern -void -plugin_run(struct plugin_command *command, char *args); - -#endif - diff --git a/wrapper/plugins.c b/wrapper/plugins.c deleted file mode 100644 index 70ce3e1..0000000 --- a/wrapper/plugins.c +++ /dev/null @@ -1,71 +0,0 @@ -/* wrapper/plugins.c -- struct definitions and basic functions for rvs plugins - system depends: this file is truly system-independant - 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. -*/ - -#include "rvs.h" - -#include "plugins.h" - -/* create a blank plugin_command */ -struct plugin_command * -plugin_mk_command() -{ - struct plugin_command *command; - command=(struct plugin_command *)xmalloc(sizeof(*command)); - - /* node */ - command->name=NULL; - command->plugin=NULL; - command->depend=NULL; - command->depends=NULL; - - /* linked list */ - command->next=NULL; - - /* depends */ - command->d_child=NULL; - command->d_next=NULL; - - return command; -} - -void -plugin_free_command(struct plugin_command *command) -{ - if (command!=NULL) { - plugin_free_command(command->next); - xfree(command->name); - xfree(command->depends); - xfree(command); - } -} - -void -plugin_free_plugin(struct plugin *plugin) -{ - if (plugin!=NULL) { - xfree(plugin->name); - plugin_free_command(plugin->commands); - plugin_free_plugin(plugin->next); - xfree(plugin); - } -} - diff --git a/wrapper/plugins.h b/wrapper/plugins.h deleted file mode 100644 index 2b5a96e..0000000 --- a/wrapper/plugins.h +++ /dev/null @@ -1,69 +0,0 @@ -/* wrapper/plugins.h -- struct definitions and basic functions for rvs plugins - system depends: this file is truly system-independant - 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. -*/ -#ifndef FILE_plugins_h_SEEN -#define FILE_plugins_h_SEEN - -#include "rvs.h" - -/* a plugin */ -/* a generic binary tree emulating a n-ary tree via linked list */ -struct plugin -{ - char *name; - struct plugin_command *commands;/* left leaf */ - struct plugin *next; /* right leaf */ -}; - -/* a single plugin command */ -struct plugin_command -{ - /* node */ - char *name; - struct plugin *plugin; /* which plugin does it belong to? */ - struct plugin_command *depend; /* what does this depend on? */ - char *depends;/* what does this depend on? (string) */ - - /* linked list */ - struct plugin_command *next; - - /* depends, linked list */ - /* for a dependancy tree, this seems like it should be a *\ - \* separate struct, but this is the simplest way. */ - struct plugin_command *d_child; - struct plugin_command *d_next; -}; - -/* create a blank plugin_command */ -extern -struct plugin_command * -plugin_mk_command(); - -extern -void -plugin_free_command(struct plugin_command *command); - -extern -void -plugin_free_plugin(struct plugin *plugin); - -#endif - diff --git a/wrapper/runcom.c b/wrapper/runcom.c deleted file mode 100644 index 30603a2..0000000 --- a/wrapper/runcom.c +++ /dev/null @@ -1,92 +0,0 @@ -/* wrapper/runcom.c -- main program loop - system depends: this file is truly system-independant - 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. -*/ - -const char *name=NAME; -const char *ver=VER; - -#include "rvs.h" -#include "plugins.h" -#include "plugin-load.h" -#include "plugin-find.h" -#include "plugin-depend.h" -#include "plugin-run.h" - -int -main ( int argc, char *argv[] ) -{ - if (argc > 1) { - /*load*/ - char *cwd=getcwd(NULL,0); - xchdir(libexecdir); - struct plugin *plugins; - plugins=load_plugins(stdin); - struct plugin_command_list *list; - if ( strchr(argv[1],'/') == NULL ) - /* this is a normal command */ - list=plugin_find_commands(plugins,argv[1]); - else { - /* this is a command for a specific plugin */ - - list=xmalloc(sizeof(*list)); list->next=NULL; - - list->command=plugin_depend_parse( - // | command-name |plugins|ret if name==""| - stralloc(argv[1]),plugins,NULL); - if ( list->command == NULL ) { - // `command->list' should be NULL if - // no plugin/command was found - // no command was specified (argv[1]=="") - plugin_free_list(list); - list=NULL; - } - } - if (list==NULL) - error(EXIT_FAILURE,0,"unrecognized command `%s'", - argv[1]); - struct plugin_command *root; - root=plugin_depend_list(list,plugins); - - /*do*/ - xchdir(cwd); - int nbytes=10; - char *args=xmalloc(nbytes); - args[0]='\0'; - int i; - for (i=2; i - 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. -*/ - -#include -#include -#include -#include -#include -#include - -#include "rvs.h" - -void * -xmalloc (size_t size) -{ - void *value = malloc (size); - if (value == NULL) { - perror(program_invocation_name); - exit(EXIT_FAILURE); - } - return value; -} - -void * -xrealloc (void *ptr, size_t size) -{ - void *value = realloc (ptr, size); - if (value == NULL) { - perror(program_invocation_name); - exit(EXIT_FAILURE); - } - return value; -} - -void -xfree (void *ptr) -{ - if (ptr!=NULL) - free (ptr); -} - -void -xsystem (const char *command) -{ - int stat=system(command); - if (stat!=0) { - if (stat==-1) { - fprintf(stderr, - "%s: unable to launch run command", - program_invocation_name); - exit(EXIT_FAILURE); - } else - exit(EXIT_FAILURE); - } -} - -/* unistd.h */ -int -xchdir (const char *filename) -{ - int ret=chdir(filename); - if (ret != 0) - error(EXIT_FAILURE,errno,"%s/",filename); - return ret; -} - -/* stdio.h */ -FILE * -xfopen (const char *filename, const char *opentype) -{ - FILE *file = fopen(filename,opentype); - /* fopen gives NULL on failure */ - if ( file == NULL ) - error(EXIT_FAILURE,errno,"%s",filename); - return file; -} - -/* string funtions */ -void -stradds(size_t *size, char **dest, char *str) -{ - if (*size > ( strlen(*dest) + strlen(str) )) - strcat(*dest, str); - else { - *size = strlen(*dest) + strlen(str) + 1; - *dest = (char *) xrealloc (*dest, *size); - strcat(*dest, str); - } -} - -char * -stralloc (const char *string) -{ - char *copy = (char *)xmalloc(strlen(string)+1); - strcpy(copy,string); - return copy; -} - diff --git a/wrapper/rvs.h b/wrapper/rvs.h deleted file mode 100644 index bdd5c68..0000000 --- a/wrapper/rvs.h +++ /dev/null @@ -1,76 +0,0 @@ -/* wrapper/rvs.h -- general and machine specific functions for rvs. - system depends: - 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. -*/ -#ifndef FILE_rvs_h_SEEN -#define FILE_rvs_h_SEEN - -#include -#include -#include -#include -#include -#include - -/* glibc */ -extern char *program_invocation_name; -extern char *program_invocation_short_name; - -/* stdlib.h */ -/*extern int EXIT_SUCCESS;*/ -/*extern int EXIT_FAILURE;*/ - -extern -void * -xmalloc (size_t size); - -extern -void * -xrealloc (void *ptr, size_t size); - -extern -void -xfree (void *ptr); - -extern -void -xsystem (const char *command); - -/* unistd.h */ -extern -int -xchdir (const char *filename); - -/* stdio.h */ -extern -FILE * -xfopen (const char *filename, const char *opentype); - -/* string funtions */ -extern -void -stradds(size_t *size, char **dest, char *str); - -extern -char * -stralloc (const char *string); - -#endif - diff --git a/wrapper/rvs.sh b/wrapper/rvs.sh index 0001d66..85586ea 100644 --- a/wrapper/rvs.sh +++ b/wrapper/rvs.sh @@ -1,7 +1,7 @@ #!/bin/sh name='@name@' ver='0.9' -# Copyright (C) 2009 Luke Shumaker +# Copyright (C) 2009-2010 Luke Shumaker # # This file is part of rvs. # @@ -14,93 +14,143 @@ ver='0.9' # 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. +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see . -RVS="$0" #RVS="@rvs@" -libexecdir="@libexecdir@/$name" +export RVS="$0" #RVS="@rvs@" +export BINDIR="@BINDIR@" +export TMPDIR="@TMPDIR@" +export LIBDIR="@LIBDIR@" +export ETCDIR="@ETCDIR@" + +################################################################################ +# Internal use # +################################################################################ + +# General ############################################################ _error() { - echo "$RVS: $1" >> /dev/stderr + echo "$RVS: $@" >> /dev/stderr exit 1 } +# Repository ######################################################### + _repo() { repo=".$name" pwd=`pwd` - owd="$pwd" + owd="$pwd" # old working directory + # [----can ascend-----] && [-haven't found repo-] while [ "$pwd" != "`pwd`" ] && [ ! -e "`pwd`/$repo" ]; do pwd=`pwd` cd .. done if [ -e "`pwd`/$repo" ]; then + # we found a repository echo "`pwd`/$repo" else + # we didn't find a repository _error "no $name repository found" fi cd "$owd" } -_init() { - repo=`_repo 2> /dev/null` - if [ -z "$repo" ]; then - repo=".$name" - install -d "$repo" - install -m644 -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 +# Modules ############################################################ + +_runcom() { + command=${$1?"usage: rvs runcom COMMAND"}; shift + if [ ! -e "$BINDIR/$command" ]; then + _error "cannot find command \`$command" else - _error "repository already exists at \`$repo'" + if [ -f "$BINDIR/$command" ]; then + exec "$BINDIR/$command" $@ | tee "$TMPDIR/$command" + elif [ -d "$BINDIR/$command" ] + for file in "$BINDIR/$command"/*; do + id=$(echo $file | sed 's/^[0-9]*-//') + exec "$file" $@ | tee "TMPDIR/$command/$id" + done + else + _error "cannot run \`$command'" + fi 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" +_nextpriority() { + command=${1?"usage: rvs nextpriority COMMAND"} + for file in "$BINDIR/$command"/*; do + echo $file | sed 's/^\([0-9]*\)-.*/\1/' + done | sort -n | tail -n1 | xargs expr 1 + +} + +################################################################################ +# Builtin commands # +################################################################################ + +_init() { + REPO=`_repo 2> /dev/null` + if [ -z "$REPO" ]; then + export REPO="`pwd`.$name" + install -d "$REPO" + _runcom init else - echo "$id" >> "$libexecdir/plugins" + _error "repository already exists at \`$REPO'" fi - rm -rf "$libexecdir/$id" - cp -rpT "$dir" "$libexecdir/$id" } +################################################################################ +# Builtin commands -- installing modules # +################################################################################ + +_install() { + file= ${1?"usage: $RVS install FILE COMMAND ID [PRIORITY]"} + command= ${2?"usage: $RVS install FILE COMMAND ID [PRIORITY]"} + id= ${3?"usage: $RVS install FILE COMMAND ID [PRIORITY]"} + priority=${4-"`_nextpriority "$command"`"} + + install -d "$BINDIR/$command" + install "$file" "$BINDIR/$command/$priority-$id" +} + + _uninstall() { - id=$1 - sed -i "/^$id$/ d" "$libexecdir/plugins" - rm -rf "$libexecdir/$id" + command=${1?"usage: $RVS uninstall COMMAND [ID]"} + id=$2 + + if [ -z "$id" ]; then + # no ID specified + rm "$BINDIR/$command" + else + # ID specified + rm "$BINDIR/$command/*-$id" + if [ -z "$(ls "$BINDIR/$command")" ]; then + rmdir "$BINDIR/$command" + fi + fi } +################################################################################ +# Main # +################################################################################ + # START OPTION HANDLING # com=$1; # END OPTION HANDLING # case "$com" in '') _error 'no command specified';; - # 'repo') _repo; exit $?;; - 'init') _init; exit $?;; + 'init' ) shift; _init $@; exit $?;; 'install') shift; _install $@; exit $?;; 'uninstall') shift; _uninstall $@; exit $?;; - *) REPO=`_repo` + *) + REPO=`_repo` if [ "$?" = '0' ]; then - export RVS libexecdir REPO - "$libexecdir/runcom" $@ < $REPO/plugins + export REPO + _runcom $@ exit $? else - _error "cannot find an existing repository" + _error 'cannot find an existing repository' fi :;; esac -- cgit v1.2.3-2-g168b