From 15b67942e56de4e0068f0870f257e852cd8b7c00 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 27 Feb 2016 17:47:52 -0500 Subject: wip; files were sitting here --- modules/blobs/.#get.f.sh | 1 + modules/blobs/Makefile | 1 + modules/blobs/Makefile.inc.mk | 8 +++++ modules/blobs/Module.mk | 0 modules/blobs/_stdio.sh | 74 +++++++++++++++++++++++++++++++++++++++++++ modules/blobs/commit.d.sh | 34 ++++++++++++++++++++ modules/blobs/commit.f.sh | 37 ++++++++++++++++++++++ modules/blobs/commit.sh | 39 +++++++++++++++++++++++ modules/blobs/get.d.sh | 37 ++++++++++++++++++++++ modules/blobs/get.f.sh | 31 ++++++++++++++++++ modules/blobs/get.sh | 28 ++++++++++++++++ modules/blobs/ls.sh | 50 +++++++++++++++++++++++++++++ modules/blobs/print.sh | 41 ++++++++++++++++++++++++ modules/blobs/tree.sh | 40 +++++++++++++++++++++++ 14 files changed, 421 insertions(+) create mode 120000 modules/blobs/.#get.f.sh create mode 120000 modules/blobs/Makefile create mode 100644 modules/blobs/Makefile.inc.mk create mode 100644 modules/blobs/Module.mk create mode 100644 modules/blobs/_stdio.sh create mode 100644 modules/blobs/commit.d.sh create mode 100644 modules/blobs/commit.f.sh create mode 100644 modules/blobs/commit.sh create mode 100644 modules/blobs/get.d.sh create mode 100644 modules/blobs/get.f.sh create mode 100644 modules/blobs/get.sh create mode 100644 modules/blobs/ls.sh create mode 100644 modules/blobs/print.sh create mode 100644 modules/blobs/tree.sh (limited to 'modules/blobs') diff --git a/modules/blobs/.#get.f.sh b/modules/blobs/.#get.f.sh new file mode 120000 index 0000000..c2c97da --- /dev/null +++ b/modules/blobs/.#get.f.sh @@ -0,0 +1 @@ +luke@build64-par.lan.670:1436421582 \ No newline at end of file diff --git a/modules/blobs/Makefile b/modules/blobs/Makefile new file mode 120000 index 0000000..fa7273c --- /dev/null +++ b/modules/blobs/Makefile @@ -0,0 +1 @@ +../module.mk \ No newline at end of file diff --git a/modules/blobs/Makefile.inc.mk b/modules/blobs/Makefile.inc.mk new file mode 100644 index 0000000..8fd2d6f --- /dev/null +++ b/modules/blobs/Makefile.inc.mk @@ -0,0 +1,8 @@ +src_files += commit.d.sh commit.f.sh commit.sh get.d.sh get.f.sh get.sh ls.sh print.sh tree.sh +out_files += commit.d commit.f commit 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/blobs/Module.mk b/modules/blobs/Module.mk new file mode 100644 index 0000000..e69de29 diff --git a/modules/blobs/_stdio.sh b/modules/blobs/_stdio.sh new file mode 100644 index 0000000..0da03f0 --- /dev/null +++ b/modules/blobs/_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 . + +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 . +__disclaimer__ + fi + exit 0 +} + diff --git a/modules/blobs/commit.d.sh b/modules/blobs/commit.d.sh new file mode 100644 index 0000000..620a88f --- /dev/null +++ b/modules/blobs/commit.d.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# rvs blobs/commit.d - add a directory to the repository +# Copyright (C) 2009-2010, 2015 Luke Shumaker +# +# This file is part of rvs. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +. "${0%/*}/_stdio.sh" + +usage='DIRECTORY' +[[ $# -eq 1 ]] || errusage +dir="$1" + +shopt -s dotglob +cd "$dir" +tmpfile="$(mktemp -t "${0##*/}.XXXXXXXXXX")" +for file in *; do + id="$("$RVS" commit "$file")" + stat -c $'%a\t%u (%U)\t%g (%G)\t' -- "$file" + printf $'%s\t%s\n' "$id" "$file" +done > "$tmpfile" +"$RVS" commit.f "$tmpfile" d diff --git a/modules/blobs/commit.f.sh b/modules/blobs/commit.f.sh new file mode 100644 index 0000000..8a97c2a --- /dev/null +++ b/modules/blobs/commit.f.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# rvs blobs/commit.f - add a plain file to the repository +# Copyright (C) 2009-2010, 2015 Luke Shumaker +# +# This file is part of rvs. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +. "${0%/*}/_stdio.sh" + +usage='FILENAME [TYPE]' +case $# in + 0) errusage;; + 1) infile=$1; type=f;; + 2) infile=$1; type=$2;; + *) errusage;; +esac + +hash="$(<"$file" sha1sum | cut -d ' ' -f1)" +outfile="$RVS_REPO/blobs/$hash" +if [ ! -f "$outfile" ]; then + mkdir -p -- "${outfile%/*}" + < "$infile" gzip -9 > "$outfile" +fi +printf '%s:%s\n' "$type" "$hash" + diff --git a/modules/blobs/commit.sh b/modules/blobs/commit.sh new file mode 100644 index 0000000..e23af27 --- /dev/null +++ b/modules/blobs/commit.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# rvs blobs/commit - add a file to the repository +# Copyright (C) 2009-2010, 2015 Luke Shumaker +# +# This file is part of rvs. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +. "${0%/*}/_stdio.sh" + +usage='[FILES...]' +if [[ $# -lt 1 ]]; then + set -- . +fi + +for file in "$@"; do + local type + if test -L "$file"; then + type=l + elif test -f "$file"; then + type=f + elif test -d "$file"; then + type=d + else + error 'Unsupported file type: %s' "$file" + fi + "$RVS" "commit.$type" "$file" +done diff --git a/modules/blobs/get.d.sh b/modules/blobs/get.d.sh new file mode 100644 index 0000000..989dbe8 --- /dev/null +++ b/modules/blobs/get.d.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# rvs blobs/get.d - get a directory from the repository +# Copyright (C) 2009-2010, 2015 Luke Shumaker +# +# This file is part of rvs. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +. "${0%/*}/_stdio.sh" + +usage="DIRNAME ID" +[[ $# -eq 2 ]] || errusage +name=$1 +id=$2 + +tmpfile="$(mktemp -t "${0##*/}.XXXXXXXXXX")" +"$RVS" get.f "$tmpfile" "$id" + +mkdir -p -- "$name" +cd "$name" + +IFS=$'\t' +while read -r perm user group id name; do + "$RVS" get "$name" "$id" + chmod "$perm" "$name" +done < "$tmpfile" diff --git a/modules/blobs/get.f.sh b/modules/blobs/get.f.sh new file mode 100644 index 0000000..02185a6 --- /dev/null +++ b/modules/blobs/get.f.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# rvs blobs/get.f - get a plain file from the repository +# Copyright (C) 2009-2010, 2015 Luke Shumaker +# +# This file is part of rvs. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +. "${0%/*}/_stdio.sh" + +. "$LIBDIR/@ID@/stdio" + +usage="FILENAME ID" +[[ $# -eq 2 ]] || errusage +name=$1 +id=$2 + +mkdir -p -- "${name%/*}" +< "$REPO/blobs/${id#*:}" gunzip > "$name" + diff --git a/modules/blobs/get.sh b/modules/blobs/get.sh new file mode 100644 index 0000000..4be2732 --- /dev/null +++ b/modules/blobs/get.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# rvs blobs/get - get a file from the repository +# Copyright (C) 2009-2010, 2015 Luke Shumaker +# +# This file is part of rvs. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +. "${0%/*}/_stdio.sh" + +usage="FILENAME ID" +[[ $# -eq 2 ]] || errusage +name=$1 +id=$2 + +"$RVS" "get.${id%%:*}" "$name" "$id" + diff --git a/modules/blobs/ls.sh b/modules/blobs/ls.sh new file mode 100644 index 0000000..1c4d620 --- /dev/null +++ b/modules/blobs/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 . + +. "$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/blobs/print.sh b/modules/blobs/print.sh new file mode 100644 index 0000000..0e23adc --- /dev/null +++ b/modules/blobs/print.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# rvs files/print - ??? +# Copyright (C) 2010, 2015 Luke Shumaker +# +# This file is part of rvs. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +. "${0%/*}/_stdio.sh" + +usage='ID' +[[ $# -eq 1 ]] || errusage +id=$1 + +hash="${id#*:}" +file="$REPO/blobs/$hash" + +if [ -e "$file" ]; then + t="${id%%:*}" + type='' + case "$t" in + f) type='regular file';; + d) type='directory';; + l) type='link';; + esac + printf 'File Type: %s (%s)\n' "$t" "$type" +else + fatal 'no object with ID `%s'\' "$id" +fi + diff --git a/modules/blobs/tree.sh b/modules/blobs/tree.sh new file mode 100644 index 0000000..80202ea --- /dev/null +++ b/modules/blobs/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 . + +. "${0%/*}/_stdio.sh" + +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 + -- cgit v1.2.3-54-g00ecf