summaryrefslogtreecommitdiff
path: root/modules/files
diff options
context:
space:
mode:
Diffstat (limited to 'modules/files')
l---------modules/files/Makefile1
-rw-r--r--modules/files/Makefile.inc.mk8
-rw-r--r--modules/files/Module.mk0
-rw-r--r--modules/files/_stdio.sh74
-rw-r--r--modules/files/blob-gethash.sh26
-rw-r--r--modules/files/blob-gettype.sh26
-rw-r--r--modules/files/commit.d.sh42
-rw-r--r--modules/files/commit.f.sh32
-rw-r--r--modules/files/commit.sh27
-rw-r--r--modules/files/file-gettype.sh39
-rw-r--r--modules/files/get.d.sh46
-rw-r--r--modules/files/get.f.sh29
-rw-r--r--modules/files/get.sh32
-rw-r--r--modules/files/ls.sh50
-rw-r--r--modules/files/print.sh39
-rw-r--r--modules/files/tree.sh40
16 files changed, 511 insertions, 0 deletions
diff --git a/modules/files/Makefile b/modules/files/Makefile
new file mode 120000
index 0000000..fa7273c
--- /dev/null
+++ b/modules/files/Makefile
@@ -0,0 +1 @@
+../module.mk \ No newline at end of file
diff --git a/modules/files/Makefile.inc.mk b/modules/files/Makefile.inc.mk
new file mode 100644
index 0000000..99c739e
--- /dev/null
+++ b/modules/files/Makefile.inc.mk
@@ -0,0 +1,8 @@
+src_files += blob-gethash.sh blob-gettype.sh commit.d.sh commit.f.sh commit.sh file-gettype.sh get.d.sh get.f.sh get.sh ls.sh print.sh tree.sh
+out_files += blob-gethash blob-gettype commit.d commit.f commit file-gettype get.d get.f get ls print tree
+
+src_files += _stdio.sh
+sys_files += $(pkglibexecdir)/modules/$(name)/_stdio.sh
+
+$(DESTDIR)$(pkglibexecdir)/modules/$(name)/_stdio.sh: $(srcdir)/_stdio.sh | $(DESTDIR)$(pkglibexecdir)/modules/$(name)
+ $(INSTALL_DATA) $< $@
diff --git a/modules/files/Module.mk b/modules/files/Module.mk
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/modules/files/Module.mk
diff --git a/modules/files/_stdio.sh b/modules/files/_stdio.sh
new file mode 100644
index 0000000..974e98e
--- /dev/null
+++ b/modules/files/_stdio.sh
@@ -0,0 +1,74 @@
+#!/bin/sh
+#name='stdio'
+#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 <http://www.gnu.org/licenses>.
+
+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: $RVS $name $usage
+
+Try \`$RVS help $name' for more options.
+__error__
+ exit 1
+}
+
+getvar() {
+ if [ -z "$1" ]; then
+ error
+ else
+ echo $1
+ fi
+}
+
+version() {
+ echo "$name $ver"
+ if [ "$volume" != '-q' ]; then
+ cat << __disclaimer__
+$name is copyright (C) 2009-2010 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/modules/files/blob-gethash.sh b/modules/files/blob-gethash.sh
new file mode 100644
index 0000000..74defbc
--- /dev/null
+++ b/modules/files/blob-gethash.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+name='blob-gethash'
+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 <http://www.gnu.org/licenses>.
+
+. "$LIBDIR/@ID@/stdio"
+
+usage="ID"
+id="`getvar "$1"`"
+
+echo $id | sed 's/.*://'
+
diff --git a/modules/files/blob-gettype.sh b/modules/files/blob-gettype.sh
new file mode 100644
index 0000000..da3ee2a
--- /dev/null
+++ b/modules/files/blob-gettype.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+name='blob-gettype'
+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 <http://www.gnu.org/licenses>.
+
+. "$LIBDIR/@ID@/stdio"
+
+usage="ID"
+id="`getvar "$1"`"
+
+echo $id | sed 's/:.*//'
+
diff --git a/modules/files/commit.d.sh b/modules/files/commit.d.sh
new file mode 100644
index 0000000..d7e48f9
--- /dev/null
+++ b/modules/files/commit.d.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+name='commit.d'
+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 <http://www.gnu.org/licenses>.
+
+. "$LIBDIR/@ID@/stdio"
+
+usage="DIRNAME"
+dir="`getvar "$1"`"
+
+tmp=`mktemp`
+t=' ';
+
+cd "$dir"
+for file in *; do
+ p="`stat "$file" -c'%a' `" # permissions
+ o="`stat "$file" -c'%u (%U)'`" # owner
+ g="`stat "$file" -c'%g (%G)'`" # group
+ i="`"$RVS" commit "$file"`" # ID
+ n="$file" # name
+
+ # %p %o %g %i %n
+ echo "$p$t$o$t$g$t$i$t$n" >> "$tmp"
+done
+
+"$RVS" commit.f "$tmp" d
+rm "$tmp"
+
diff --git a/modules/files/commit.f.sh b/modules/files/commit.f.sh
new file mode 100644
index 0000000..e0df1b2
--- /dev/null
+++ b/modules/files/commit.f.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+name='commit.f'
+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 <http://www.gnu.org/licenses>.
+
+. "$LIBDIR/@ID@/stdio"
+
+usage="FILENAME [TYPE]"
+file="`getvar "$1"`"
+prefix="${2-f}"
+
+hash=`sha1sum $file | sed "s/ .*$//"`
+if [ ! -f "$REPO/@ID@/$hash" ]; then
+ mkdir -p "$REPO/@ID@/"
+ install -m 644 -o $USER -g $USER -T "$file" "$REPO/@ID@/$hash"
+fi
+echo "$prefix:$hash"
+
diff --git a/modules/files/commit.sh b/modules/files/commit.sh
new file mode 100644
index 0000000..0bb8233
--- /dev/null
+++ b/modules/files/commit.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+name='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 <http://www.gnu.org/licenses>.
+
+. "$LIBDIR/@ID@/stdio"
+
+usage="[FILE]"
+file=${1-.} # take arg1 as the file, default to the current directory
+
+type=`"$RVS" file-gettype "$file"`
+"$RVS" "commit.$type" "$file"
+
diff --git a/modules/files/file-gettype.sh b/modules/files/file-gettype.sh
new file mode 100644
index 0000000..2a1e0ca
--- /dev/null
+++ b/modules/files/file-gettype.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+name='file-gettype'
+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 <http://www.gnu.org/licenses>.
+
+. "$LIBDIR/@ID@/stdio"
+
+usage="FILE"
+file="`getvar "$1"`"
+
+if [ ! -e "$file" ]; then
+ fatal "file \`$file' does not exist";
+else
+ type=''
+ for check in "$ETCDIR/@ID@/"*; do
+ type=`"$check" "$file"`
+ if [ -n "$type" ]; then break; fi
+ done
+ if [ -n "$type" ]; then
+ echo "$type"
+ else
+ fatal "cannot handle file type of \`$file'"
+ fi
+fi
+
diff --git a/modules/files/get.d.sh b/modules/files/get.d.sh
new file mode 100644
index 0000000..646e29d
--- /dev/null
+++ b/modules/files/get.d.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+name='get.d'
+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 <http://www.gnu.org/licenses>.
+
+. "$LIBDIR/@ID@/stdio"
+
+usage="DIRNAME ID"
+dir="`getvar "$1"`"
+ id="`getvar "$2"`"
+
+tmp=`mktemp`
+"$RVS" get.f "$tmp" "$id"
+
+#install -d "$dir"
+mkdir -p "$dir"
+
+cd "$dir"
+rm -rf ./*
+while read line; do
+ p="`echo "$line" | cut -f1`" # permissions
+ o="`echo "$line" | cut -f2`" # owner
+ g="`echo "$line" | cut -f3`" # group
+ i="`echo "$line" | cut -f4`" # ID
+ n="`echo "$line" | cut -f5-`" # name
+ "$RVS" get "$n" "$i"
+ chmod "$p" "$n"
+ #chown "$o:$g" "$n"
+done < "$tmp"
+
+rm "$tmp"
+
diff --git a/modules/files/get.f.sh b/modules/files/get.f.sh
new file mode 100644
index 0000000..e3d5edc
--- /dev/null
+++ b/modules/files/get.f.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+name='get.f'
+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 <http://www.gnu.org/licenses>.
+
+. "$LIBDIR/@ID@/stdio"
+
+usage="FILENAME ID"
+name="`getvar "$1"`"
+ id="`getvar "$2"`"
+
+hash="`"$RVS" blob-gethash "$id"`"
+
+install -T "$REPO/@ID@/$hash" "$name"
+
diff --git a/modules/files/get.sh b/modules/files/get.sh
new file mode 100644
index 0000000..639ac57
--- /dev/null
+++ b/modules/files/get.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+name='get'
+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 <http://www.gnu.org/licenses>.
+
+. "$LIBDIR/@ID@/stdio"
+
+usage="FILENAME ID"
+name="`getvar "$1"`"
+ id="`getvar "$2"`"
+
+file="$REPO/@ID@/$id"
+
+type="`"$RVS" blob-gettype "$id"`"
+#hash="`"$RVS" blob-gethash "$id"`"
+
+"$RVS" "get.$type" "$name" "$id"
+
diff --git a/modules/files/ls.sh b/modules/files/ls.sh
new file mode 100644
index 0000000..9e586eb
--- /dev/null
+++ b/modules/files/ls.sh
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+name='ls'
+ver=0.1
+# Copyright (C) 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 <http://www.gnu.org/licenses>.
+
+. "$LIBDIR/@ID@/stdio"
+
+usage="DIR_ID [FORMAT]"
+id="`getvar "$1"`"
+form="${2-%p\t%o\t%g\t%n\t%i}"
+
+# %p - permissions
+# %o - owner
+# %g - group
+# %i - blob id
+# %n - name
+# \t - a tab char
+
+tmp="`mktemp`"
+"$RVS" get.f "$tmp" "$id"
+
+while read line; do
+ p="`echo "$line" | cut -f1`"
+ o="`echo "$line" | cut -f2`"
+ g="`echo "$line" | cut -f3`"
+ i="`echo "$line" | cut -f4`"
+ n="`echo "$line" | cut -f5-`"
+ echo "$form" | sed \
+ -e 's:\\t:\t:g' \
+ -e "s:%p:${p/:/\\:}:g" \
+ -e "s:%o:${o/:/\\:}:g" \
+ -e "s:%g:${g/:/\\:}:g" \
+ -e "s:%i:${i/:/\\:}:g" \
+ -e "s:%n:${n/:/\\:}:g"
+done < "$tmp"
+
diff --git a/modules/files/print.sh b/modules/files/print.sh
new file mode 100644
index 0000000..3657d2f
--- /dev/null
+++ b/modules/files/print.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+name='print'
+ver=0.1
+# Copyright (C) 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 <http://www.gnu.org/licenses>.
+
+. "$LIBDIR/@ID@/stdio"
+
+usage='ID'
+id="`getvar "$1"`"
+
+hash="`"$RVS" blob-gethash "$id"`"
+file="$REPO/@ID@/$hash"
+
+if [ -e "$file" ]; then
+ t="`"$RVS" blob-gettype "$id"`"
+ type=''
+ case "$t" in
+ f) type='regular file';;
+ d) type='directory';;
+ esac
+ echo "File Type: $t ($type)"
+else
+ fatal "no object with ID \`$id'"
+fi
+
diff --git a/modules/files/tree.sh b/modules/files/tree.sh
new file mode 100644
index 0000000..6164d94
--- /dev/null
+++ b/modules/files/tree.sh
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+name='tree'
+ver=0.1
+# Copyright (C) 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 <http://www.gnu.org/licenses>.
+
+. "$LIBDIR/@ID@/stdio"
+
+usage="DIR_ID [NAME] [PREFIX] [LAST]"
+id="`getvar "$1"`"
+name="${2-.}"
+pref="$3"
+last="$4"
+
+echo "$pref $name $id"
+pref=' | '
+"$RVS" ls "$id" '%i\t%n' | while read line; do
+ i="`echo "$line" | cut -f1`"
+ n="`echo "$line" | cut -f2-`"
+ t="`"$RVS" blob-gettype "$i"`"
+ if [ "$t" = 'd' ]
+ "$RVS" tree "$i" "$n" "$pref"
+ else
+ echo "$pref $n $i"
+ fi
+done
+