summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2009-08-11 01:14:29 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-06-26 00:30:13 -0600
commit24e77f63ae243c33e1d38792080eaec1db43f8f7 (patch)
tree75af0795dc89bb383a814747f07e72a2a744781b
parent530c6ff02be9ce6604e16ac33ec24569a39f6b0c (diff)
I don't think this will run, but I think the next step is to turn `rvs.sh' into
`rvs.c', so I'm going to go ahead and commit this.
-rw-r--r--Makefile.in9
-rw-r--r--TODO8
-rw-r--r--plugins/repo/Makefile.in23
-rw-r--r--plugins/repo/lib/stdio.sh68
-rw-r--r--plugins/users/Makefile.in27
-rw-r--r--plugins/users/lib/stdio.sh68
-rw-r--r--rvs.sh75
7 files changed, 90 insertions, 188 deletions
diff --git a/Makefile.in b/Makefile.in
index 31b60fa..165d11b 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -20,14 +20,14 @@ ver = 0.7.3
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
export rvs = $(name)
-# pirectories ######################################################
+# directories ######################################################
srcdir = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
-dirs = $(srcdir) $(prefix) $(exec_prefix) $(bindir) $(sbindir) $(libexecdir)/$(rvs)
+dirs = $(srcdir) $(prefix) $(exec_prefix) $(bindir) $(sbindir) $(libexecdir)/
export srcdir prefix exec_prefix bindir sbindir libexecdir
# programs #########################################################
@@ -112,7 +112,8 @@ $(d) : distclean
# plugins ##########################################################
-install-p-% : plugins/% plugins/%/Makefile p-% libexec ; $(MAKE) -C $< install
+install-p-% : plugins/% plugins/%/Makefile p-% libexec $(RVS)
+ $(MAKE) -C $< install
p-% : plugins/% plugins/%/Makefile ; $(MAKE) -C $<
uninstall-p-% : plugins/% plugins/%/Makefile ; $(MAKE) -C $< uninstall
clean-p-% : plugins/% plugins/%/Makefile ; $(MAKE) -C $< clean
@@ -121,6 +122,6 @@ dist-p-% : plugins/% plugins/%/Makefile ; $(MAKE) -C $< dist
# implicit rules ###################################################
-$(dirs) :
+$(dirs) $(libexecdir)/$(rvs) :
$(MKDIR) $@
diff --git a/TODO b/TODO
deleted file mode 100644
index 1a2664f..0000000
--- a/TODO
+++ /dev/null
@@ -1,8 +0,0 @@
-X write `dist' into the makefiles
- X Makefile.in
- X plugins/repo/Makefile.in
- X plugins/repo/Makefile.in
-_ rewrite the plugin interface to allow depends
-_ implement tree
- _ merge diff-daemon into rvs
-
diff --git a/plugins/repo/Makefile.in b/plugins/repo/Makefile.in
index 6adec10..8409705 100644
--- a/plugins/repo/Makefile.in
+++ b/plugins/repo/Makefile.in
@@ -20,16 +20,17 @@ ver = 0.7beta
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
export rvs ?= @name@
-# Directories ######################################################
+# directories ######################################################
srcdir ?= @srcdir@
prefix ?= @prefix@
exec_prefix ?= @exec_prefix@
bindir ?= @bindir@
sbindir ?= @sbindir@
libexecdir ?= @libexecdir@
-#export srcdir prefix exec_prefix bindir sbindir libexecdir
+dirs = $(srcdir) $(prefix) $(exec_prefix) $(bindir) $(sbindir) $(libexecdir)/
+#export srcdir prefix exec_prefix bindir sbindir libexecdir
-# Programs #########################################################
+# programs #########################################################
RVS ?= @RVS@
SHELL ?= @SHELL@
RM ?= rm
@@ -56,7 +57,10 @@ srcFiles = $(filter-out %/Makefile.in,$(shell find $(mysrcdir)/ -type f))
shSrcFiles = $(filter %.sh,$(srcFiles))
shOutFiles = $(patsubst $(mysrcdir)/%,$(myoutdir)/%,$(basename $(shSrcFiles)))
-$(name) : $(shOutFiles)
+$(name) : $(myoutdir) $(shOutFiles) $(myoutdir)/plugin.conf
+
+$(myoutdir)/plugin.conf : $(mysrcdir)/plugin.conf
+ $(INSTALL_DATA) $< $@
# (un)install ######################################################
@@ -90,13 +94,10 @@ $(d) : distclean
b := @
# build shell scripts
-$(myoutdir)/% : $(mysrcdir)/%.sh
- $(MKDIR) $(dir $@)
- $(INSTALL_PROGRAM) $< $@
- $(SED) -i 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' $@
-# workaround... idk why it doesn't match `lib/'
-$(myoutdir)/lib/% : $(mysrcdir)/lib/%.sh
- $(MKDIR) $(dir $@)
+$(myoutdir)/% : $(mysrcdir)/%.sh $(myoutdir)
$(INSTALL_PROGRAM) $< $@
$(SED) -i 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' $@
+$(dirs) $(libexecdir)/$(rvs) $(myoutdir) :
+ $(MKDIR) $@
+
diff --git a/plugins/repo/lib/stdio.sh b/plugins/repo/lib/stdio.sh
deleted file mode 100644
index c1a1b6b..0000000
--- a/plugins/repo/lib/stdio.sh
+++ /dev/null
@@ -1,68 +0,0 @@
-#!@SHELL@
-#name='rvs repo stdio'
-#ver='0.7.3'
-# 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.
-
-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 <lukeshu@sbcglobal.net>.
-__disclaimer__
- fi
- exit 0
-}
-
diff --git a/plugins/users/Makefile.in b/plugins/users/Makefile.in
index b97720b..5de6cb3 100644
--- a/plugins/users/Makefile.in
+++ b/plugins/users/Makefile.in
@@ -20,16 +20,17 @@ ver = 0.7beta
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
export rvs ?= @name@
-# Directories ######################################################
+# directories ######################################################
srcdir ?= @srcdir@
prefix ?= @prefix@
exec_prefix ?= @exec_prefix@
bindir ?= @bindir@
sbindir ?= @sbindir@
libexecdir ?= @libexecdir@
-#export srcdir prefix exec_prefix bindir sbindir libexecdir
+dirs = $(srcdir) $(prefix) $(exec_prefix) $(bindir) $(sbindir) $(libexecdir)/
+#export srcdir prefix exec_prefix bindir sbindir libexecdir
-# Programs #########################################################
+# programs #########################################################
RVS ?= @RVS@
SHELL ?= @SHELL@
RM ?= rm
@@ -44,10 +45,10 @@ TOUCH ?= touch # This file doesn't use touch
# phony targets ####################################################
all : $(name)
-.PHONY : $(name) install uninstall clean distclean
+.PHONY : $(name) install uninstall clean distclean dist
.SUFFIXES :
-# main #############################################################
+# build ############################################################
mysrcdir = $(srcdir)/plugins/$(name)
myoutdir = out
@@ -56,7 +57,10 @@ srcFiles = $(filter-out %/Makefile.in,$(shell find $(mysrcdir)/ -type f))
shSrcFiles = $(filter %.sh,$(srcFiles))
shOutFiles = $(patsubst $(mysrcdir)/%,$(myoutdir)/%,$(basename $(shSrcFiles)))
-$(name) : $(shOutFiles)
+$(name) : $(myoutdir) $(shOutFiles) $(myoutdir)/plugin.conf
+
+$(myoutdir)/plugin.conf : $(mysrcdir)/plugin.conf
+ $(INSTALL_DATA) $< $@
# (un)install ######################################################
@@ -90,13 +94,10 @@ $(d) : distclean
b := @
# build shell scripts
-$(myoutdir)/% : $(mysrcdir)/%.sh
- $(MKDIR) $(dir $@)
- $(INSTALL_PROGRAM) $< $@
- $(SED) -i 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' $@
-# workaround... idk why it doesn't match `lib/'
-$(myoutdir)/lib/% : $(mysrcdir)/lib/%.sh
- $(MKDIR) $(dir $@)
+$(myoutdir)/% : $(mysrcdir)/%.sh $(myoutdir)
$(INSTALL_PROGRAM) $< $@
$(SED) -i 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' $@
+$(dirs) $(libexecdir)/$(rvs) $(myoutdir) :
+ $(MKDIR) $@
+
diff --git a/plugins/users/lib/stdio.sh b/plugins/users/lib/stdio.sh
deleted file mode 100644
index 1149284..0000000
--- a/plugins/users/lib/stdio.sh
+++ /dev/null
@@ -1,68 +0,0 @@
-#!@SHELL@
-#name='rvs users stdio'
-#ver='0.7.3'
-# 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.
-
-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 <lukeshu@sbcglobal.net>.
-__disclaimer__
- fi
- exit 0
-}
-
diff --git a/rvs.sh b/rvs.sh
index b9ff973..f54f553 100644
--- a/rvs.sh
+++ b/rvs.sh
@@ -85,33 +85,76 @@ _uninstall() {
rm -rf "$libexecdir/$id"
}
+_treebranch() {
+ branch="$1"
+ for com in "$branch"; do
+ var="r_$com"
+ if [ -z "\$$var" ]; then
+ exec r$var="`$libexecdir/$com $param`"
+ var="_$com"
+ _treebranch "\$$var"
+ else
+ _error "plugin dependancy loop detected"
+ fi
+ done
+}
+
+_runcom() {
+ com="$1"
+ tmp_mast="`tempfile`"
+ # bash optimized version
+ #grep -E "^$com(:.*)?$" "$libexecdir/*/plugin.conf" | sed \
+ # -e 's/\#.*//' \
+ # -e "s:^${libexecdir//':'/'\:'}/::" \
+ # -e 's@plugin.conf\:@@' > "$tmp_mast"
+ # POSIX version
+ grep -E "^$com(:.*)?$" $libexecdir/*/plugin.conf | sed \
+ -e 's/\#.*//' \
+ -e "s:^`echo "$libexecdir" |sed 's@:@\\:@g'`/::" \
+ -e 's@plugin.conf\:@@' > "$tmp_mast"
+
+ # start processing-------------------------------------------
+ if [ "`wc -c < "$tmp_mast"`" = '0' ]; then
+ _error "unrecognized command \`$com'"
+ else
+ # create tree
+ tmp_work="`tempfile`"
+ lev1="`sed \
+ -e "/\:/w '$tmp_work'" \
+ -e '/\:/d' "$tmp_mast"`"
+ while read line; do
+ com="`echo "$line" | sed 's/\:.*$/'`"
+ dep="_`echo "$line" | sed 's/.*\:$/'`"
+ # bash optimized version
+ # eval $dep=\"${!dep} $com\"
+ # POSIX version
+ eval $dep=\"\$$dep $com\"
+ done < "$tmp_work"
+ rm "$tmp_work"
+
+ # cycle through tree
+ _treebranch "$lev1"
+ fi
+ rm "$tmp_mast"
+}
+
# START OPTION HANDLING #
com=$1;
# END OPTION HANDLING #
case "$com" in
'') _error 'no command specified';;
- # 'repo') repo; exit $?;;
+ # 'repo') _repo; exit $?;;
'init') _init; exit $?;;
'install') shift; _install $@; exit $?;;
'uninstall') shift; _uninstall $@; exit $?;;
*) repo=`_repo`
if [ "$?" = '0' ]; then
- while read plugin; do
- if [ -f "$libexecdir/$plugin/$com" ]; then
- done='yes'
- export libexecdir=$libexecdir/$plugin
- export REPO=$repo/$plugin
- export RVS
- $libexecdir/$@
- exit $?
- break
- fi
- done < "$repo/plugins"
+ shift
+ param="$@"
+ _runcom
+ exit $?
else
- exit 1;
- fi
- if [ "$done" != 'yes' ]; then
- _error "unrecognized command \`$com'"
+ _error "cannot find an existing repository"
fi
:;;
esac