summaryrefslogtreecommitdiffstats
path: root/bin/initpkgtree
diff options
context:
space:
mode:
Diffstat (limited to 'bin/initpkgtree')
-rwxr-xr-xbin/initpkgtree40
1 files changed, 40 insertions, 0 deletions
diff --git a/bin/initpkgtree b/bin/initpkgtree
new file mode 100755
index 0000000..77d8e47
--- /dev/null
+++ b/bin/initpkgtree
@@ -0,0 +1,40 @@
+#!/bin/sh
+# Initializes files and their sections in a package tree directory structure.
+# Assumes we are already inside of a package tree's root directory.
+
+prog=initpkgtree
+
+if [ $# -eq 0 ]
+then
+ echo "usage: $prog [filename] [section 1] [section 2] [...]" 1>&2
+ exit 2
+fi
+
+if [ -d "$1" ]
+then
+ echo "$prog: a file named $1 already exists in the package tree" 1>&2
+ exit 101
+fi
+
+dups=`for sect; do echo "$sect"; done | awk '
+{ dups[$1]++ } END { for(d in dups) if(dups[d] > 1) printf d " " }'
+`
+if [ "$dups" ]
+then
+ echo "$prog: duplicate sections not permitted: $dups" 1>&2
+ exit 102
+fi
+
+mkdir "$1"
+cd "$1"
+shift
+
+for sect
+do
+ d="$sect"
+ mkdir "$d"
+ for f in beg body end
+ do
+ touch "$d/$f"
+ done
+done