summaryrefslogtreecommitdiffstats
path: root/bin/putpkgtree
diff options
context:
space:
mode:
authorJustin Davis <jrcd83@gmail.com>2012-03-05 23:29:51 +0100
committerJustin Davis <jrcd83@gmail.com>2012-03-05 23:29:51 +0100
commit0873b3e326586ff2b7b3b0e6cbdd85e1a31ec4ad (patch)
treeec4aaaa82dd8a1b4ebc496737adcc0ab7e5668dd /bin/putpkgtree
parent75bddd0e24674d76a2518dcbdced5a015b550775 (diff)
downloadgenpkg-0873b3e326586ff2b7b3b0e6cbdd85e1a31ec4ad.tar.gz
genpkg-0873b3e326586ff2b7b3b0e6cbdd85e1a31ec4ad.tar.xz
Make pkgtree scripts simpler still.
Diffstat (limited to 'bin/putpkgtree')
-rwxr-xr-xbin/putpkgtree28
1 files changed, 15 insertions, 13 deletions
diff --git a/bin/putpkgtree b/bin/putpkgtree
index f415108..2606460 100755
--- a/bin/putpkgtree
+++ b/bin/putpkgtree
@@ -2,25 +2,27 @@
prog=putpkgtree
-err()
-{
- code="$1"
- shift
- echo $@ 1>&2
- exit "$code"
-}
-
if [ "$#" -ne 3 ]
then
echo "usage: $prog [file] [section] ['beg'/'body'/'end'] < [text to append]" 1>&2
exit 2
fi
-[ -d "$1" ] || err 101 "$prog: package file does not exist: $1"
-cd "$1"
+case "$3" in
+beg|body|end) ;;
+*) echo "$prog: third parameter must be 'beg', 'body', or 'end'" 1>&2
+ exit 2
+esac
-[ -d "$2" ] || err 102 "$prog: section does not exist: $2" 1>&2
-cd "$2"
+if ! [ -d PKGTREE ]
+then
+ echo "$prog: PKGTREE directory does not exist" 1>&2
+ exit 100
+fi
+cd PKGTREE
-[ -f "$3" ] || err 103 "$prog: subsection does not exist: $3"
+[ -d "$1" ] || mkdir "$1"
+cd "$1"
+[ -d "$2" ] || mkdir "$2"
+cd "$2"
cat >> "$3"