diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2009-07-24 22:41:51 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-06-26 00:30:12 -0600 |
commit | dd78d7c7724e4da4b6f44f0483f0d28792c8f13c (patch) | |
tree | d842ab2fa09442b61684cf7e696c04beedd7db68 /src/core/plugins.d/repo | |
parent | 797494b91e13c6faf35affe5bbacb1a3d3aa13fe (diff) |
0.7.0 -- refactor to make core a pluggin (not done)
Diffstat (limited to 'src/core/plugins.d/repo')
-rw-r--r-- | src/core/plugins.d/repo/commit.d.sh | 23 | ||||
-rw-r--r-- | src/core/plugins.d/repo/commit.f.sh | 24 | ||||
-rw-r--r-- | src/core/plugins.d/repo/commit.sh | 51 | ||||
-rw-r--r-- | src/core/plugins.d/repo/get.d.sh | 30 | ||||
-rw-r--r-- | src/core/plugins.d/repo/get.f.sh | 20 | ||||
-rw-r--r-- | src/core/plugins.d/repo/get.sh | 32 | ||||
-rw-r--r-- | src/core/plugins.d/repo/lib/stdio.sh | 58 |
7 files changed, 238 insertions, 0 deletions
diff --git a/src/core/plugins.d/repo/commit.d.sh b/src/core/plugins.d/repo/commit.d.sh new file mode 100644 index 0000000..5b2d3fd --- /dev/null +++ b/src/core/plugins.d/repo/commit.d.sh @@ -0,0 +1,23 @@ +#!$$SHELL$$ +name='rvs commit.d' +ver='0.7.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 <lukeshu@sbcglobal.net>. + +# commit.d DIRNAME +dir="$1" + +tmp=`tempfile` +for file in $dir/*; do + hash=`rvs commit "$file"` + echo "$file:$hash" >> "$tmp" +done + +rvs commit.f "$tmp" +rm "$tmp" + diff --git a/src/core/plugins.d/repo/commit.f.sh b/src/core/plugins.d/repo/commit.f.sh new file mode 100644 index 0000000..915ba3c --- /dev/null +++ b/src/core/plugins.d/repo/commit.f.sh @@ -0,0 +1,24 @@ +#!$$SHELL$$ +name='rvs commit.f' +ver='0.7.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 <lukeshu@sbcglobal.net>. + +source "$RVSDIR/lib/stdio" +source "$RVSDIR/lib/rvsdb" + +# commit.f FILENAME +file="$1" + +#hash=`md5sum $file | sed "s/ .*$//"` +hash=`sha1sum $file | sed "s/ .*$//"` +if [ ! -f "`rvs repo`/files/$hash" ]; then + install -m 644 -o $USER -g $USER -T "$file" "`rvs repo`/files/$hash" +fi +echo "$hash" + diff --git a/src/core/plugins.d/repo/commit.sh b/src/core/plugins.d/repo/commit.sh new file mode 100644 index 0000000..0c8cfc5 --- /dev/null +++ b/src/core/plugins.d/repo/commit.sh @@ -0,0 +1,51 @@ +#!$$SHELL$$ +name='rvs commit' +ver='0.7.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 <lukeshu@sbcglobal.net>. + +source "$RVSDIR/lib/stdio" + +# commit FILE +if [ $# -gt 0 ]; then + file="$1" +else + file='.' +fi + +warn "$file" + +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 ]; 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` +cat << __EOF__ > "$tmp" +name:$file +hash:$ret +type:$type +author:$user +owner:$owner +license:$license +__EOF__ + +rvs commit.f "$tmp" +rm "$tmp" + diff --git a/src/core/plugins.d/repo/get.d.sh b/src/core/plugins.d/repo/get.d.sh new file mode 100644 index 0000000..2443850 --- /dev/null +++ b/src/core/plugins.d/repo/get.d.sh @@ -0,0 +1,30 @@ +#!$$SHELL$$ +name='rvs get.d' +ver='0.7.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 <lukeshu@sbcglobal.net>. + +#source "$RVSDIR/lib/stdio" +source "$RVSDIR/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/src/core/plugins.d/repo/get.f.sh b/src/core/plugins.d/repo/get.f.sh new file mode 100644 index 0000000..e631a1f --- /dev/null +++ b/src/core/plugins.d/repo/get.f.sh @@ -0,0 +1,20 @@ +#!$$SHELL$$ +name='rvs get.f' +ver='0.7.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 <lukeshu@sbcglobal.net>. + +source "$RVSDIR/lib/stdio" +source "$RVSDIR/lib/rvsdb" + +# get.f ID FILENAME +id="$1" +file="$2" + +cp "`rvs repo`/files/$id" "$file" + diff --git a/src/core/plugins.d/repo/get.sh b/src/core/plugins.d/repo/get.sh new file mode 100644 index 0000000..4317c40 --- /dev/null +++ b/src/core/plugins.d/repo/get.sh @@ -0,0 +1,32 @@ +#!$$SHELL$$ +name='rvs get' +ver='0.7.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 <lukeshu@sbcglobal.net>. + +source "$RVSDIR/lib/stdio" +source "$RVSDIR/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/src/core/plugins.d/repo/lib/stdio.sh b/src/core/plugins.d/repo/lib/stdio.sh new file mode 100644 index 0000000..e6ef31a --- /dev/null +++ b/src/core/plugins.d/repo/lib/stdio.sh @@ -0,0 +1,58 @@ +#!$$SHELL$$ +#name='rvs stdio' +#ver='0.7.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 <lukeshu@sbcglobal.net>. + +verbose() { + if [ "$volume" == '-v' ]; then + echo $@ + fi +} + +out() { + if [ "$volume" != '-q' ]; then + echo $@ + fi +} + +warn () { + echo "$name: $1" >> /dev/stderr +} + +error() { + warn "$1" + cat << __error__ >> /dev/stderr +Usage: $name $usage + +Try \`$name --help\' for more options. +__error__ + exit 1 +} + +fatal () { + warn "$1" + 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 +} + |