From 3e100e9de3cec5ec5e9a641e782ae47ca095233d Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 13 Sep 2009 15:20:14 -0400 Subject: bichun! fixed makefiles, moved around files The wrapper is now a hybrid shell-C program. A shell script does the integrated commands, but it calls the C program (`$(libexecdir)/rvs/runcom') to launch plugins Note that right now, it does EVERYTHING BUT launch plugins. --- wrapper/Makefile.in | 26 +++++++++++-- wrapper/TODO | 4 +- wrapper/runcom.c | 50 ++++++++++++++++++++++++ wrapper/rvs.c | 47 ---------------------- wrapper/rvs.sh | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 185 insertions(+), 52 deletions(-) create mode 100644 wrapper/runcom.c delete mode 100644 wrapper/rvs.c create mode 100644 wrapper/rvs.sh (limited to 'wrapper') diff --git a/wrapper/Makefile.in b/wrapper/Makefile.in index 85f56f7..a6eef15 100644 --- a/wrapper/Makefile.in +++ b/wrapper/Makefile.in @@ -31,6 +31,7 @@ dirs = $(srcdir) $(prefix) $(exec_prefix) $(bindir) $(sbindir) $(libexecdir)/ #export srcdir prefix exec_prefix bindir sbindir libexecdir # programs ######################################################### +CC = @CC@ RVS ?= @RVS@ SHELL ?= @SHELL@ RM ?= rm @@ -43,19 +44,36 @@ INSTALL_DATA ?= $(INSTALL) -m 644 TOUCH ?= touch # This file doesn't use touch #export RVS SHELL RM CP SED INSTALL MKDIR INSTALL_PROGRAM INSTALL_DATA TOUCH +CFLAGS = -DLIBEXECDIR=\"$(libexecdir)\" -DPLUGIN_CONF=\"plugin.conf\" + # phony targets #################################################### -all : rvs -.PHONY : install uninstall clean distclean dist +all : rvs runcom +.PHONY : install uninstall clean distclean dist install-runcom .SUFFIXES : .c .o VPATH = $(srcdir)/wrapper # most everything ################################################## -install : $(RVS) -$(RVS) : rvs $(bindir) +RUNCOM = $(libexecdir)/$(rvs)/runcom +install : $(RVS) $(RUNCOM) +$(RVS) : rvs $(dir $(RVS)) + $(INSTALL_PROGRAM) $< $@ + +$(RUNCOM): runcom $(dir $(RUNCOM)) + $(INSTALL_PROGRAM) $< $@ + +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' \ + $@ uninstall : $(RM) $(RVS) + $(RM) $(libexecdir)/$(rvs)/runcom clean : diff --git a/wrapper/TODO b/wrapper/TODO index 577c252..6d1bd2a 100644 --- a/wrapper/TODO +++ b/wrapper/TODO @@ -1,6 +1,8 @@ #! /bin/more -plugin-load.h: +* add propper option handling via GNU getopt +* actually launch the plugins +* plugin-load.h: The function `load_plugins' must loop through sub-directories in the directory `libexecdir'. They way it does this is an ugly kludge, and should be rewritten. diff --git a/wrapper/runcom.c b/wrapper/runcom.c new file mode 100644 index 0000000..f581a45 --- /dev/null +++ b/wrapper/runcom.c @@ -0,0 +1,50 @@ +const char *name="rvs"; +const char *ver="0.8c"; +/* 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" +#include "plugin-load.h" +#include "plugin-find.h" +#include "plugin-depend.h" + +const char *libexecdir=LIBEXECDIR; +const char *plugin_conf=PLUGIN_CONF; + +int +main ( int argc, char *argv[] ) +{ + struct plugin *plugins=load_plugins(libexecdir,plugin_conf); + if (argc > 1) { + struct plugin_command_list *list; + list=plugin_find_commands(plugins,argv[1]); + struct plugin_command *root; + root=plugin_depend_list(list,plugins); + plugin_free_list(list); + plugin_free_command(root); + } + plugin_free_plugin(plugins); + return 0; +} + +/* Copy/Paste Virus 1.3c Please copy and paste this text anywhere. Track *\ +\* its progress by searching for this MD5#f7eac285ebfe21c4587bfebb9582f90d */ + diff --git a/wrapper/rvs.c b/wrapper/rvs.c deleted file mode 100644 index 4f2fa1b..0000000 --- a/wrapper/rvs.c +++ /dev/null @@ -1,47 +0,0 @@ -const char *name="rvs"; -const char *ver="0.8c"; -/* 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" -#include "plugin-load.h" -#include "plugin-find.h" -#include "plugin-depend.h" - -const char *libexecdir="./plugins"; -const char *plugin_conf="plugin.conf"; - -int -main ( int argc, char *argv[] ) -{ - struct plugin *plugins=load_plugins(libexecdir,plugin_conf); - if (argc > 1) { - struct plugin_command_list *list; - list=plugin_find_commands(plugins,argv[1]); - struct plugin_command *root; - root=plugin_depend_list(list,plugins); - plugin_free_list(list); - plugin_free_command(root); - } - plugin_free_plugin(plugins); - return 0; -} - diff --git a/wrapper/rvs.sh b/wrapper/rvs.sh new file mode 100644 index 0000000..d7fc753 --- /dev/null +++ b/wrapper/rvs.sh @@ -0,0 +1,110 @@ +#!@SHELL@ +name='@name@' +ver='0.8c' +# 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. + +RVS="$0" #RVS="@rvs@" +libexecdir="@libexecdir@/$name" + +_error() { + echo "$name: $1" >> /dev/stderr + exit 1 +} + +_repo() { + repo=".$name" + pwd=`pwd` + owd="$pwd" + + while [ "$pwd" != "`pwd`" ] && [ ! -e "`pwd`/$repo" ]; do + pwd=`pwd` + cd .. + done + + if [ -e "`pwd`/$repo" ]; then + echo "`pwd`/$repo" + else + _error "no $name repository found" + fi + cd "$owd" +} + +_init() { + repo=`_repo 2> /dev/null` + if [ -z "$repo" ]; then + repo=".$name" + install -d "$repo" + install -T $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 + else + _error "repository already exists at \`$repo'" + 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" + else + echo "$id" >> "$libexecdir/plugins" + fi + rm -rf "$libexecdir/$id" + cp -rpT "$dir" "$libexecdir/$id" +} + +_uninstall() { + id=$1 + sed -i "/^$id$/ d" "$libexecdir/plugins" + rm -rf "$libexecdir/$id" +} + +# START OPTION HANDLING # +com=$1; +# END OPTION HANDLING # +case "$com" in + '') _error 'no command specified';; + # 'repo') _repo; exit $?;; + 'init') _init; exit $?;; + 'install') shift; _install $@; exit $?;; + 'uninstall') shift; _uninstall $@; exit $?;; + *) repo=`_repo` + if [ "$?" = '0' ]; then + shift + $libexecdir/runcom $@ + exit $? + else + _error "cannot find an existing repository" + fi + :;; +esac + +# Copy/Paste Virus 1.3c Please copy and paste this text anywhere. Track +# its progress by searching for this MD5#f7eac285ebfe21c4587bfebb9582f90d + -- cgit v1.2.3-54-g00ecf