summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Davis <jrcd83@gmail.com>2012-02-24 01:05:29 +0100
committerJustin Davis <jrcd83@gmail.com>2012-02-24 01:05:29 +0100
commitbd9d357c9344f9c23919f5300ce780be2e2ddda0 (patch)
tree98786fc4b9ab4057846e17051bc13d0f194ba295
parentf4ee30a61b018afd61b67b8a7269a826e2a98281 (diff)
downloadgenpkg-bd9d357c9344f9c23919f5300ce780be2e2ddda0.tar.gz
genpkg-bd9d357c9344f9c23919f5300ce780be2e2ddda0.tar.xz
Start dir-based package trees. Adds catpkgtree.
-rw-r--r--bin/catpkgtree67
1 files changed, 67 insertions, 0 deletions
diff --git a/bin/catpkgtree b/bin/catpkgtree
new file mode 100644
index 0000000..846655c
--- /dev/null
+++ b/bin/catpkgtree
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+PROG=catpkgtree
+
+findnode()
+{
+ for f in *
+ do
+ [ "$f" = '*' ] && break
+ [ -f "$f" ] || continue
+ case f in
+ [0-9][0-9]-*)
+ n=`echo "$f" | sed 's/^...//'`
+ if [ "$n" = "$1" ]
+ then
+ echo "$f"
+ return 0
+ fi
+ esac
+ done
+ return 1
+}
+
+if [ $# -ne 1 ]
+then
+ echo "usage: $PROG [tree path] < [text to append]" 1>&2
+ exit 2
+fi
+
+if ! cd PKGTREE
+then
+ echo "$PROG: PKGTREE dir must be present in current dir" 1>&2
+ exit 100
+fi
+
+IFS=/ set -- "$1"
+if [ $# -lt 2 ]
+then
+ echo "$PROG: path to tree node must be separated by forward slashes" 1>&2
+ exit 101
+fi
+
+if ! cd "$1"
+then
+ echo "$PROG: $1 is not a valid package file" 1>&2
+ exit 102
+fi
+shift
+
+while [ $# -gt 1 ]
+do
+ f=`findnode $1`
+ if [ $? -ne 0 ] || ! cd "$f"
+ then
+ echo "$PROG: $1 is not a valid node name" >1&2
+ exit 102
+ fi
+ shift
+done
+
+f=`findnode $1`
+if [ $? -ne 0 ] || [ ! -f "$f" ]
+then
+ echo "$PROG: $f is not a valid final node" 1>&2
+ exit 102
+fi
+cat >> "$f"