From 3cdfa2a24cd8279ab5d5204d598f319b175940f2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 13 Jul 2009 13:23:09 -0400 Subject: rvs 0.6.0 -- major restructuring to: * use a proper build directory, rather than just extracting into / * declare functions in a POSIX/SUS3 compliant way * support systems with out GNU bash, or GNU bash in a place other than /bin/bash --- Makefile.bak | 42 ++++++++++++ Makefile.orig | 55 ++++++++++++++++ Variables | 5 ++ configure | 59 +++++++++++++++++ docs/README.xhtml | 116 ++++++++++++++++++++++++++++++++++ etc/abomination/modules/rvs/commit | 57 ----------------- etc/abomination/modules/rvs/commit.d | 29 --------- etc/abomination/modules/rvs/commit.f | 25 -------- etc/abomination/modules/rvs/get | 34 ---------- etc/abomination/modules/rvs/get.d | 32 ---------- etc/abomination/modules/rvs/get.f | 22 ------- etc/abomination/modules/rvs/init | 18 ------ etc/abomination/modules/rvs/lib/rvsdb | 83 ------------------------ etc/abomination/modules/rvs/lib/stdio | 57 ----------------- source/rvs | 50 +++++++++++++++ source/rvs-core/commit | 51 +++++++++++++++ source/rvs-core/commit.d | 29 +++++++++ source/rvs-core/commit.f | 25 ++++++++ source/rvs-core/get | 34 ++++++++++ source/rvs-core/get.d | 32 ++++++++++ source/rvs-core/get.f | 22 +++++++ source/rvs-core/init | 18 ++++++ source/rvs-core/lib/rvsdb | 83 ++++++++++++++++++++++++ source/rvs-core/lib/stdio | 57 +++++++++++++++++ usr/bin/rvs | 50 --------------- 25 files changed, 678 insertions(+), 407 deletions(-) create mode 100644 Makefile.bak create mode 100644 Makefile.orig create mode 100644 Variables create mode 100755 configure create mode 100644 docs/README.xhtml delete mode 100755 etc/abomination/modules/rvs/commit delete mode 100755 etc/abomination/modules/rvs/commit.d delete mode 100755 etc/abomination/modules/rvs/commit.f delete mode 100755 etc/abomination/modules/rvs/get delete mode 100755 etc/abomination/modules/rvs/get.d delete mode 100755 etc/abomination/modules/rvs/get.f delete mode 100755 etc/abomination/modules/rvs/init delete mode 100755 etc/abomination/modules/rvs/lib/rvsdb delete mode 100755 etc/abomination/modules/rvs/lib/stdio create mode 100755 source/rvs create mode 100755 source/rvs-core/commit create mode 100755 source/rvs-core/commit.d create mode 100755 source/rvs-core/commit.f create mode 100755 source/rvs-core/get create mode 100644 source/rvs-core/get.d create mode 100755 source/rvs-core/get.f create mode 100755 source/rvs-core/init create mode 100755 source/rvs-core/lib/rvsdb create mode 100755 source/rvs-core/lib/stdio delete mode 100755 usr/bin/rvs diff --git a/Makefile.bak b/Makefile.bak new file mode 100644 index 0000000..979af8a --- /dev/null +++ b/Makefile.bak @@ -0,0 +1,42 @@ +# rvs Makefile +# +# 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 . + +# Make Dependencies ################################################# +RM = rm -f +WWW = links2 -width 70 -dump +INSTALL = install + +# Variables ######################################################## +SHELL = $$SHELL$$ +prefix = $$prefix$$ +bindir = $$bindir$$ +libdir = $$libdir$$ + +# Targets ########################################################## +files +build: +# $(WWW) README.xhtml > README.txt + +.SUFFIXES: + +install : wrapper core + $(INSTALL) -m 755 -T out/rvs $(prefix)/$(bindir)/rvs + $(INSTALL) -m 755 -d out/rvs-core $(libdir)/core + +out/% : source/% var.sed + ./var.sed <$< > $@ + +var.sed: makesed Variables + ./makesed var.sed + chmod 755 var.sed + +clean: + $(RM) var.sed + $(RM) -r out diff --git a/Makefile.orig b/Makefile.orig new file mode 100644 index 0000000..3ea425e --- /dev/null +++ b/Makefile.orig @@ -0,0 +1,55 @@ +# rvs Makefile +# +# 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 . + + +# Make Dependencies ################################################# +RM = rm -f +WWW = links2 -width 70 -dump +INSTALL = install + +# Variables ######################################################## +SHELL = $$SHELL$$ +prefix = $$prefix$$ +bindir = $$bindir$$ +libdir = $$libdir$$ + +# Targets ########################################################## +rvs : wrapper core + +.SUFFIXES : + +#install : wrapper core +# $(INSTALL) -m 755 -T out/rvs $(prefix)/$(bindir)/rvs +# $(INSTALL) -m 755 -d out/rvs-core $(libdir)/core + +wrapper : lib out/rvs + +#core : l b c d p f s +core : lib out/rvs-core/commit out/rvs-core/get d f + +#l: lib out/rvs-core/commit.l out/rvs-core/get.l +#b: lib out/rvs-core/commit.b out/rvs-core/get.b +#c: lib out/rvs-core/commit.c out/rvs-core/get.c +d : lib out/rvs-core/commit.d out/rvs-core/get.d +#p: lib out/rvs-core/commit.p out/rvs-core/get.p +f : lib out/rvs-core/commit.f out/rvs-core/get.f +#s: lib out/rvs-core/commit.s out/rvs-core/get.s +#D: lib out/rvs-core/commit.D out/rvs-core/get.D + +lib: out/rvs-core/lib/stdio out/rvs-core/lib/rvsdb + +out/% : source/% tmp/var.sed + tmp/var.sed <$< > $@ + +clean : + $(RM) -r tmp + $(RM) -r out + $(RM) Makefile + diff --git a/Variables b/Variables new file mode 100644 index 0000000..dacb7a9 --- /dev/null +++ b/Variables @@ -0,0 +1,5 @@ +VER '0.6.0' +SHELL '/usr/bin/env bash' +prefix "$HOME" +bindir 'bin' +libdir '/etc/rvs/' diff --git a/configure b/configure new file mode 100755 index 0000000..35c7b76 --- /dev/null +++ b/configure @@ -0,0 +1,59 @@ +#!/bin/sh +# rvs configureation script +# +# 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 . + +while [ $# -gt 0 ]; do case "$1" in + --*) + var0=`echo "$1" | sed -e 's/^--//' -e 's/=.*$//'` + match='false' + while read line; do + var1=`echo "$line" | cut -f 1 ` + if [ "$var0" == "$var1" ]; then + match='true' + break; + fi + done < Variables + if [ "$match" == 'false' ]; then + echo "configure: option \`$1' not recognized" + exit 255; + else + val=`echo "$1" | sed -e "s/^--$var0=//"` + eval _$var0=$val + fi + :;; + *) echo "configure: option \`$1' not recognized"; exit 255;; + esac + shift +done + +mkdir -p {out/rvs-core/lib,tmp} + +echo '#!/bin/sed -f' > tmp/var.sed +while read line; do + var=`echo "$line" | cut -f 1 ` + val=$(eval echo `echo "$line" | cut -f 2-`) # load from Variables file + val=$(eval echo '${'`echo _$var`-$val'}') # check for option overide + + # evaluate the values, so that we may use env variables as values + # escape slashes, as they cause problems for sed + var=`echo "$var" | sed 's:/:\\\\/:g'` + val=`echo "$val" | sed 's:/:\\\\/:g'` + + echo 's/$$'"${var}"'$\$/'"${val}"'/' >> tmp/var.sed + #sed -i.bak 's/$$'"${var}"'$\$/'"${val}"'/' "$files" + unset var val +done < Variables + +chmod +x tmp/var.sed +tmp/var.sed < Makefile.orig > Makefile + +n0='# DO NOT edit this file, it has been generated by configure, and will be' +n1='# overwritten. Instead, edit the file `Makefile.orig'\' +sed -i -e "10 a$n0" -e "10 a$n1" Makefile diff --git a/docs/README.xhtml b/docs/README.xhtml new file mode 100644 index 0000000..3d6c612 --- /dev/null +++ b/docs/README.xhtml @@ -0,0 +1,116 @@ + + + + + rvs $$VER$$ + + + +

rvs $$VER$$

+

rvs is a basic versioning system I've been writing. If you don't know what that means, it isn't for you (at least not at this stage in development).

+ +

installation

+

After you have obtained the source code, cd into the directory and run: +
./configure +
make install +

+

instead of using options to ./configure like ./configure --prefix=/usr/bin, all configuration options (that effect the installation, not the build process), are stored in the file Variables. Many of the source files use variables in the form $$VARNAME$$. The ./configure script replaces each instance of this with the value defined in Variables. Variables contains a variable name, tab character, then value on each line.

+ +
    +
  • /etc/abomination/modules/rvs/commit
  • +
  • /etc/abomination/modules/rvs/commit.d
  • +
  • /etc/abomination/modules/rvs/commit.f
  • +
  • /etc/abomination/modules/rvs/get
  • +
  • /etc/abomination/modules/rvs/get.d
  • +
  • /etc/abomination/modules/rvs/get.f
  • +
  • /etc/abomination/modules/rvs/init
  • +
  • /etc/abomination/modules/rvs/lib/rvsdb
  • +
  • /etc/abomination/modules/rvs/lib/stdio
  • +
  • /usr/bin/rvs
  • +
+ +

system requirements

+

Pretty much any *nix system should be able to run rvs, provided it has bash, and bash is installed at /bin/bash (e.g.: FreeBSD has it at /usr/bin/bash, so you should set up a symlink). rvs is not designed for Windows, but should be able to run in bash if you have some *nix pack installed.

+

To my knowledge, this is the absolute requirements (all need to be in your PATH):

+ + +

usage

+
+
create repository in the current directory
+
rvs init
+
check in the current directory
+
rvs commit This will return a commit id. You need this to check the revision back out.
+
check out to the current directory
+
rvs get ID This checks out commit ID
+
+

The system will bork if you have filenames with spaces or newlines. Why? Because you haven't written a patch to fix it yet.

+

Feel free to push to the launchpad repository.

+ +

hacking

+

Again, here is a list of all files in rvs-0.5.10.tar.gz:

+
    +
  • /etc/abomination/modules/rvs/commit
  • +
  • /etc/abomination/modules/rvs/commit.d
  • +
  • /etc/abomination/modules/rvs/commit.f
  • +
  • /etc/abomination/modules/rvs/get
  • +
  • /etc/abomination/modules/rvs/get.d
  • +
  • /etc/abomination/modules/rvs/get.f
  • +
  • /etc/abomination/modules/rvs/init
  • +
  • /etc/abomination/modules/rvs/lib/rvsdb
  • +
  • /etc/abomination/modules/rvs/lib/stdio
  • +
  • /usr/bin/rvs
  • +
+

These are all shell scripts and may be modified directly. I have designed this system to be extremely modular. As you may have figured out, each bit on functionality is in it's own script, and /usr/bin/rvs is just a wrapper for them. If you wish to move the directory with the sub-modules, all you have to do is update the variablle RVSDIR towards the beginning of /usr/bin/rvs.

+

commit actually does take a parameter. It can commit any file or directory. It works as it does because if no file is given, it defaults to ./. If it is given a directory (as it is by default), it loops through each file in the directory and commits them (by calling itself). In order to actually commit a file or directory it calls rvs commit.type where type is the standard unix file-type code:

+ + + + + + + + + + +
block       (buffered) special
b
character (unbuffered) special
c
directory                     
d
named pipe (FIFO)             
p
regular file                  
f
symbolic link                 
l
docket                        
s
door (Solaris only)           
D
+

As you probably noticed, only directories and regular files have been implemented in this release. get works in much the same way. If you implement any other file types, save the commit and get functions accordingly, and uncomment the line in /etc/abomination/modules/rvs/commit. Any commit function takes a filename as an argument and outputs the according commit id to stdout. Any get function takes the commit id as an argument and uses stdout only if verbose, or to report errors. So the modules communicate via pipes, which is generally considered bad-design, and libraries should be used. I deliberatly broke this because this way:

+
    +
  1. incompatible licences can be used for different modules
  2. +
  3. modules can be added/removed on the fly
  4. +
  5. one can use any lanugage to write new modules, without having to worry about bindings
  6. +
+ +

TODO

+
    +
  • implment other unix file types (see above)
  • +
  • add real option handling (code from another project is provided in /usr/bin/rvs)
  • +
  • write real documentation
  • +
  • implment a parent/child tree
      +
    • implement branch ids (NOTE: wch should be used to refer to the latest commit in a branch)
    • +
  • +
  • implement tags
  • +
  • owner/filepermissions/timestamps
  • +
  • usernames/author
  • +
+ +

I have set up bazaar repository at Launchpad. Only until rvs becomes self-hosting.

+

If anyone needs any help, let me know. +
~ Luke Shumaker <LukeShu@sbcglobal.net> +
Happy Hacking!

+ + + diff --git a/etc/abomination/modules/rvs/commit b/etc/abomination/modules/rvs/commit deleted file mode 100755 index 6ff39a0..0000000 --- a/etc/abomination/modules/rvs/commit +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# abomination module:rvs:commit -name='rvs commit' -ver='0.5.10' -usage='[OPTIONS] [FILE]' -# Copyright (C) 2009 Luke Shumaker -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# Originally written by Luke Shumaker . - -source "`rvs -d`/lib/stdio" -source "`rvs -d`/lib/rvsdb" - -# commit FILE -if [ $# -gt 0 ]; then - file="$1" -else - file='.' -fi - -if [ ! -e $file]; then error "file \`$file' does not exist"; -# START file type list -#elif [ -b $file ]; type='b'; # block (buffered) special -#elif [ -c $file ]; type='c'; # character (unbuffered) special -elif [ -d $file ]; type='d'; # directory -#elif [ -p $file ]; type='p'; # named pipe (FIFO) -elif [ -f $file ]; type='f'; # regular file -#elif [ -l $file ]; type='l'; # symbolic link -#elif [ -s $file ]; type='s'; # socket -#elif [ -D $file ]; type='D'; # door (Solaris only) -# END file type list -fi - -ret=`rvs "commit.$type" "$file"` - -tmp=`tempfile` -loginit "$tmp" -logwrite "$tmp" 'name' "$file" -logwrite "$tmp" 'hash' "$ret" -logwrite "$tmp" 'type' "$type" -logwrite "$tmp" 'author' "$user" -logwrite "$tmp" 'owner' "$owner" -logwrite "$tmp" 'owner' "$license" -#parents=`logfind "$repo/co" "$file"` the checkout log is getting an overhaul -#logwrite "$tmp" 'parents' "$parents" -#case "$type" in -# f) -# #logwrite "$tmp" 'f.type' "$" -# :;; -#esac - -rvs commit.f "$tmp" -rm "$tmp" - diff --git a/etc/abomination/modules/rvs/commit.d b/etc/abomination/modules/rvs/commit.d deleted file mode 100755 index 91a75c4..0000000 --- a/etc/abomination/modules/rvs/commit.d +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -# abomination module:rvs:commit:d -name='rvs commit.d' -ver='0.5.10' -usage='[OPTIONS] DIRECTORY' -# Copyright (C) 2009 Luke Shumaker -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# Originally written by Luke Shumaker . - -source "`rvs -d`/lib/stdio" -source "`rvs -d`/lib/rvsdb" - -# commit.d DIRNAME -dir="$1" - -tmp=`tempfile` -loginit "$tmp" -for file in $dir; do - hash=`commit "$dir/$file"` - echo "$file:$hash" >> "$tmp" -done - -rvs commit.f "$tmp" -rm "$tmp" - diff --git a/etc/abomination/modules/rvs/commit.f b/etc/abomination/modules/rvs/commit.f deleted file mode 100755 index 78c5d59..0000000 --- a/etc/abomination/modules/rvs/commit.f +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -# abomination module:rvs:commit:f -name='rvs commit.f' -ver='0.5.10' -usage='[OPTIONS] FILE' -# Copyright (C) 2009 Luke Shumaker -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# Originally written by Luke Shumaker . - -source "`rvs -d`/lib/stdio" -source "`rvs -d`/lib/rvsdb" - -# commit.f FILENAME -file="$1" - -hash=`getid $file` -if [ ! -f "$repo/files/$hash" ]; then - cp "$file" "$repo/files/$hash" -fi -echo "$hash" - diff --git a/etc/abomination/modules/rvs/get b/etc/abomination/modules/rvs/get deleted file mode 100755 index dce3ac7..0000000 --- a/etc/abomination/modules/rvs/get +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# abomination module:rvs:get -name='rvs commit' -ver='0.5.10' -usage='[OPTIONS] ID [FILENAME]' -# Copyright (C) 2009 Luke Shumaker -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# Originally written by Luke Shumaker . - -source "`rvs -d`/lib/stdio" -source "`rvs -d`/lib/rvsdb" - -# get ID [FILE] -id="$1" - -if [ $# -gt 1 ]; then - file="$2" -fi - -tmp=`tempfile` -rvs get.f "$id" "$tmp" -type=`logread "$tmp" 'type'` -if [ $# -gt 1 ]; then - file="$2" -else - file=`logread "$tmp" 'name'` -fi - -rvs "get.$type" "$id" "$file" - diff --git a/etc/abomination/modules/rvs/get.d b/etc/abomination/modules/rvs/get.d deleted file mode 100755 index 68d6aaa..0000000 --- a/etc/abomination/modules/rvs/get.d +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# abomination module:rvs:get:d -name='rvs get.d' -ver='0.5.10' -usage='[OPTIONS] ID FILENAME' -# Copyright (C) 2009 Luke Shumaker -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# Originally written by Luke Shumaker . - -source "`rvs -d`/lib/stdio" -source "`rvs -d`/lib/rvsdb" - -# get.d ID DIRNAME -id="$1" -dir="$2" - -tmp=`tempfile` -rvs get.f `logread "$db" 'hash'` "$tmp" - -mkdir "$dir" -for file in `cat "$tmp"`; do - hash=`echo "$file" | sed 's/^.*://'` - name=`echo "$file" | sed "s/:$hash$//"` - rvs get "$dir/$file" -done - -rm "$tmp" - diff --git a/etc/abomination/modules/rvs/get.f b/etc/abomination/modules/rvs/get.f deleted file mode 100755 index a0db378..0000000 --- a/etc/abomination/modules/rvs/get.f +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# abomination module:rvs:get:f -name='rvs get.f' -ver='0.5.10' -usage='[OPTIONS] ID FILENAME' -# Copyright (C) 2009 Luke Shumaker -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# Originally written by Luke Shumaker . - -source "`rvs -d`/lib/stdio" -source "`rvs -d`/lib/rvsdb" - -# get.f ID FILENAME -id="$1" -file="$2" - -cp "$repo/files/$id" "$file" - diff --git a/etc/abomination/modules/rvs/init b/etc/abomination/modules/rvs/init deleted file mode 100755 index ae778af..0000000 --- a/etc/abomination/modules/rvs/init +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# abomination rvs init -name='rvs init' -ver='0.5.10' -usage='[OPTIONS]' -# Copyright (C) 2009 Luke Shumaker -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# Originally written by Luke Shumaker . - -source "`rvs -d`/lib/stdio" -source "`rvs -d`/lib/rvsdb" - -mkdir -p "$repo/{files/tmp}" - diff --git a/etc/abomination/modules/rvs/lib/rvsdb b/etc/abomination/modules/rvs/lib/rvsdb deleted file mode 100755 index 9763042..0000000 --- a/etc/abomination/modules/rvs/lib/rvsdb +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/bash -# abomination module:rvs:lib:rvsdb -#name='rvs db' -#ver='0.5.10' -logver='0.5.0' -# Copyright (C) 2009 Luke Shumaker -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# Originally written by Luke Shumaker . - -source "`rvs -d`/lib/stdio" -#source "`rvs -d`/lib/rvsdb" - -repo='.rvs' - -# getid file -function getid { - #md5sum $file | sed "s/ .*$//" - sha1sum $file | sed "s/ .*$//" -} - -# loginit LOG -function loginit { - log="$1" - echo "#!rvsdb $logver" > "$log"; -} - -# lograw LOG -function lograw { - log="$1" - sed '1s/#!rvsdb .*//' "$log" -} - -# _find LOG FIELD VAL -function _find { - log="$1" - field="$2" - val="$3" - lograw $log | \ - cut -d : -f field | \ - sed -n "/^$val$/=" | \ - tr "\n" , | \ - sed 's/,$//' -} - -# logread LOG VAR -function logread { - log="$1" - var="$2" - lograw "$log" | sed -n "s/^$var://p" - #lograw "$log" | sed -n `_find "$log" '1' "$var"`p | cut -d : -f 2- -} - -# logwrite LOG VAR VAL -function logwrite { - log="$1" - var="$2" - val="$3" - - #lines=`_find "$log" '1' "$var"` - #if [ "$lines" = '' ]; then - if [ `lograw "$log" | grep "^$var:"` = '' ]; then - # no exiswhereting occurances - echo "$var:$val" >> "$log" - else - # found others - sed -i "^s/$var:.*/$var:$val/" "$log" - #lograw "$log" | ?????? - fi -} - -# logfind LOG VAL -function logfind { - log="$1" - val="$2" - # make a comma-delimeted list of the lines with our values - lines=`_find "$log" '2-' "$val"` - lograw "$log" | sed -n ${lines}p | cut -d : -f 1 -} - diff --git a/etc/abomination/modules/rvs/lib/stdio b/etc/abomination/modules/rvs/lib/stdio deleted file mode 100755 index 8e11b72..0000000 --- a/etc/abomination/modules/rvs/lib/stdio +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# abomination module:rvs:lib:stdio -#name='rvs stdio' -#ver='0.5.9' -#usage='' -# Copyright (C) 2009 Luke Shumaker -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# Originally written by Luke Shumaker . - -#source "$RVSDIR/lib/stdio" -#source "$RVSDIR/lib/rvsdb" - -sopt='VhH?vq' -lopt='version,verbose,quiet,help' - -function verbose { - if [ "$volume" == '-v' ]; then - echo $@ - fi -} - -function out { - if [ "$volume" != '-q' ]; then - echo $@ - fi -} - -function 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 -} - -function error { - cat << __error__ -$name: $1 -Usage: $name $usage - -Try $name \`--help' for more options. -__error__ - exit 1 -} - diff --git a/source/rvs b/source/rvs new file mode 100755 index 0000000..6a6102a --- /dev/null +++ b/source/rvs @@ -0,0 +1,50 @@ +#!$$SHELL$$ +# abomination module:rvs +name='rvs' +ver='0.5.10' +usage='COMMAND [OPTIONS]' +# Copyright (C) 2009 Luke Shumaker +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# Originally written by Luke Shumaker . + +RVSDIR='$$libdir$$' +source "$RVSDIR/lib/stdio" +source "$RVSDIR/lib/rvsdb" + +com=$1; +case "$com" in + -d) echo "$RVSDIR";; + '') error 'please specify a command';; + *) + if [ -f "$RVSDIR/$com" ]; then + export TMPDIR="$repo/tmp" + $RVSDIR/$@ + else + error "unrecognized command \`$com'" + fi + :;; +esac + +#args=`getopt -n "$name" -o "${sopt}" -l "${lopt}" -- "$@"` +#if [ $? == 0 ]; then +# set -- $args +# while [ $# -gt 0 ]; do +# case "$1" in +# -V | --version) mode='version';; +# -h | -H | -\? | --help) mode='help';; +# +# -v | --verbose) volume='-v';; +# -q | --quiet) volume='-q';; +# +# --) shift; break;; +# esac +# shift; +# done +#else +# error +#fi + diff --git a/source/rvs-core/commit b/source/rvs-core/commit new file mode 100755 index 0000000..2f120e0 --- /dev/null +++ b/source/rvs-core/commit @@ -0,0 +1,51 @@ +#!$$SHELL$$ +# abomination module:rvs:commit +name='rvs commit' +ver='0.6.0' +usage='[OPTIONS] [FILE]' +# Copyright (C) 2009 Luke Shumaker +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# Originally written by Luke Shumaker . + +source "`rvs -d`/lib/stdio" +source "`rvs -d`/lib/rvsdb" + +# commit FILE +if [ $# -gt 0 ]; then + file="$1" +else + file='.' +fi + +if [ ! -e $file]; then error "file \`$file' does not exist"; +# START file type list +elif [ -l $file ]; type='l'; # symbolic link +elif [ -b $file ]; type='b'; # block (buffered) special +elif [ -c $file ]; type='c'; # character (unbuffered) special +elif [ -d $file ]; type='d'; # directory +elif [ -p $file ]; type='p'; # named pipe (FIFO) +elif [ -f $file ]; type='f'; # regular file +elif [ -s $file ]; type='s'; # socket +#elif [ -D $file ]; type='D'; # door (Solaris only) +# END file type list +else error "could not identify file type of \`$file'" +fi + +ret=`rvs "commit.$type" "$file"` + +tmp=`tempfile` +loginit "$tmp" +logwrite "$tmp" 'name' "$file" +logwrite "$tmp" 'hash' "$ret" +logwrite "$tmp" 'type' "$type" +logwrite "$tmp" 'author' "$user" +logwrite "$tmp" 'owner' "$owner" +logwrite "$tmp" 'owner' "$license" + +rvs commit.f "$tmp" +rm "$tmp" + diff --git a/source/rvs-core/commit.d b/source/rvs-core/commit.d new file mode 100755 index 0000000..5a47614 --- /dev/null +++ b/source/rvs-core/commit.d @@ -0,0 +1,29 @@ +#!$$SHELL$$ +# abomination module:rvs:commit:d +name='rvs commit.d' +ver='0.6.0' +usage='[OPTIONS] DIRECTORY' +# Copyright (C) 2009 Luke Shumaker +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# Originally written by Luke Shumaker . + +source "`rvs -d`/lib/stdio" +source "`rvs -d`/lib/rvsdb" + +# commit.d DIRNAME +dir="$1" + +tmp=`tempfile` +loginit "$tmp" +for file in $dir; do + hash=`commit "$dir/$file"` + echo "$file:$hash" >> "$tmp" +done + +rvs commit.f "$tmp" +rm "$tmp" + diff --git a/source/rvs-core/commit.f b/source/rvs-core/commit.f new file mode 100755 index 0000000..cd8070b --- /dev/null +++ b/source/rvs-core/commit.f @@ -0,0 +1,25 @@ +#!$$SHELL$$ +# abomination module:rvs:commit:f +name='rvs commit.f' +ver='0.6.0' +usage='[OPTIONS] FILE' +# Copyright (C) 2009 Luke Shumaker +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# Originally written by Luke Shumaker . + +source "`rvs -d`/lib/stdio" +source "`rvs -d`/lib/rvsdb" + +# commit.f FILENAME +file="$1" + +hash=`getid $file` +if [ ! -f "$repo/files/$hash" ]; then + cp "$file" "$repo/files/$hash" +fi +echo "$hash" + diff --git a/source/rvs-core/get b/source/rvs-core/get new file mode 100755 index 0000000..c1a2469 --- /dev/null +++ b/source/rvs-core/get @@ -0,0 +1,34 @@ +#!$$SHELL$$ +# abomination module:rvs:get +name='rvs commit' +ver='0.6.0' +usage='[OPTIONS] ID [FILENAME]' +# Copyright (C) 2009 Luke Shumaker +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# Originally written by Luke Shumaker . + +source "`rvs -d`/lib/stdio" +source "`rvs -d`/lib/rvsdb" + +# get ID [FILE] +id="$1" + +if [ $# -gt 1 ]; then + file="$2" +fi + +tmp=`tempfile` +rvs get.f "$id" "$tmp" +type=`logread "$tmp" 'type'` +if [ $# -gt 1 ]; then + file="$2" +else + file=`logread "$tmp" 'name'` +fi + +rvs "get.$type" "$id" "$file" + diff --git a/source/rvs-core/get.d b/source/rvs-core/get.d new file mode 100644 index 0000000..dcd78e8 --- /dev/null +++ b/source/rvs-core/get.d @@ -0,0 +1,32 @@ +#!$$SHELL$$ +# abomination module:rvs:get:d +name='rvs get.d' +ver='0.6.0' +usage='[OPTIONS] ID FILENAME' +# Copyright (C) 2009 Luke Shumaker +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# Originally written by Luke Shumaker . + +source "`rvs -d`/lib/stdio" +source "`rvs -d`/lib/rvsdb" + +# get.d ID DIRNAME +id="$1" +dir="$2" + +tmp=`tempfile` +rvs get.f `logread "$db" 'hash'` "$tmp" + +mkdir "$dir" +while read line; do + hash=`echo "$line" | sed 's/^.*://'` + name=`echo "$line" | sed "s/:$hash$//"` + rvs get "$dir/$file" +done < "$tmp" + +rm "$tmp" + diff --git a/source/rvs-core/get.f b/source/rvs-core/get.f new file mode 100755 index 0000000..9e4cec7 --- /dev/null +++ b/source/rvs-core/get.f @@ -0,0 +1,22 @@ +#!$$SHELL$$ +# abomination module:rvs:get:f +name='rvs get.f' +ver='0.6.0' +usage='[OPTIONS] ID FILENAME' +# Copyright (C) 2009 Luke Shumaker +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# Originally written by Luke Shumaker . + +source "`rvs -d`/lib/stdio" +source "`rvs -d`/lib/rvsdb" + +# get.f ID FILENAME +id="$1" +file="$2" + +cp "$repo/files/$id" "$file" + diff --git a/source/rvs-core/init b/source/rvs-core/init new file mode 100755 index 0000000..c0b5980 --- /dev/null +++ b/source/rvs-core/init @@ -0,0 +1,18 @@ +#!$$SHELL$$ +# abomination rvs init +name='rvs init' +ver='0.6.0' +usage='[OPTIONS]' +# Copyright (C) 2009 Luke Shumaker +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# Originally written by Luke Shumaker . + +source "`rvs -d`/lib/stdio" +source "`rvs -d`/lib/rvsdb" + +mkdir -p "$repo/{files/tmp}" + diff --git a/source/rvs-core/lib/rvsdb b/source/rvs-core/lib/rvsdb new file mode 100755 index 0000000..8cd4316 --- /dev/null +++ b/source/rvs-core/lib/rvsdb @@ -0,0 +1,83 @@ +#!$$SHELL$$ +# abomination module:rvs:lib:rvsdb +#name='rvs db' +#ver='0.6.0' +logver='0.5.0' +# Copyright (C) 2009 Luke Shumaker +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# Originally written by Luke Shumaker . + +source "`rvs -d`/lib/stdio" +#source "`rvs -d`/lib/rvsdb" + +repo='.rvs' + +# getid file +getid() { + #md5sum $file | sed "s/ .*$//" + sha1sum $file | sed "s/ .*$//" +} + +# loginit LOG +loginit() { + log="$1" + echo "#!rvsdb $logver" > "$log"; +} + +# lograw LOG +lograw() { + log="$1" + sed '1s/#!rvsdb .*//' "$log" +} + +# _find LOG FIELD VAL +_find() { + log="$1" + field="$2" + val="$3" + lograw $log | \ + cut -d : -f field | \ + sed -n "/^$val$/=" | \ + tr "\n" , | \ + sed 's/,$//' +} + +# logread LOG VAR +logread() { + log="$1" + var="$2" + lograw "$log" | sed -n "s/^$var://p" + #lograw "$log" | sed -n `_find "$log" '1' "$var"`p | cut -d : -f 2- +} + +# logwrite LOG VAR VAL +logwrite() { + log="$1" + var="$2" + val="$3" + + #lines=`_find "$log" '1' "$var"` + #if [ "$lines" = '' ]; then + if [ `lograw "$log" | grep "^$var:"` = '' ]; then + # no exiswhereting occurances + echo "$var:$val" >> "$log" + else + # found others + sed -i "^s/$var:.*/$var:$val/" "$log" + #lograw "$log" | ?????? + fi +} + +# logfind LOG VAL +logfind() { + log="$1" + val="$2" + # make a comma-delimeted list of the lines with our values + lines=`_find "$log" '2-' "$val"` + lograw "$log" | sed -n ${lines}p | cut -d : -f 1 +} + diff --git a/source/rvs-core/lib/stdio b/source/rvs-core/lib/stdio new file mode 100755 index 0000000..9398a52 --- /dev/null +++ b/source/rvs-core/lib/stdio @@ -0,0 +1,57 @@ +#!$$SHELL$$ +# abomination module:rvs:lib:stdio +#name='rvs stdio' +#ver='0.6.0' +#usage='' +# Copyright (C) 2009 Luke Shumaker +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# Originally written by Luke Shumaker . + +#source "$RVSDIR/lib/stdio" +#source "$RVSDIR/lib/rvsdb" + +sopt='VhH?vq' +lopt='version,verbose,quiet,help' + +verbose() { + if [ "$volume" == '-v' ]; then + echo $@ + fi +} + +out() { + if [ "$volume" != '-q' ]; then + echo $@ + fi +} + +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 +} + +error() { + cat << __error__ +$name: $1 +Usage: $name $usage + +Try $name \`--help' for more options. +__error__ + exit 1 +} + diff --git a/usr/bin/rvs b/usr/bin/rvs deleted file mode 100755 index f8f31c6..0000000 --- a/usr/bin/rvs +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# abomination module:rvs -name='rvs' -ver='0.5.10' -usage='COMMAND [OPTIONS]' -# Copyright (C) 2009 Luke Shumaker -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# Originally written by Luke Shumaker . - -RVSDIR='/etc/abomination/modules/rvs' -source "$RVSDIR/lib/stdio" -source "$RVSDIR/lib/rvsdb" - -com=$1; -case "$com" in - -d) echo "$RVSDIR";; - '') error 'please specify a command';; - *) - if [ -f "$RVSDIR/$com" ]; then - export TMPDIR="$repo/tmp" - $RVSDIR/$@ - else - error "unrecognized command \`$com'" - fi - :;; -esac - -#args=`getopt -n "$name" -o "${sopt}" -l "${lopt}" -- "$@"` -#if [ $? == 0 ]; then -# set -- $args -# while [ $# -gt 0 ]; do -# case "$1" in -# -V | --version) mode='version';; -# -h | -H | -\? | --help) mode='help';; -# -# -v | --verbose) volume='-v';; -# -q | --quiet) volume='-q';; -# -# --) shift; break;; -# esac -# shift; -# done -#else -# error -#fi - -- cgit v1.2.3-2-g168b