#!/bin/sh
IFS="
"

MYDIR=$(dirname $0)
cd $MYDIR/..

die()
{
	echo "$@" >&2
	exit 1
}

verify()
{
	ERROR=$1
	shift
	"$@" || die "Can't repack: $ERROR"
}

verify "filesystem is not a symlink" [ -L filesystem ]
for d in bin lib tmp; do
	verify "$d is not a directory" [ -d $d ]
done
verify "versa-proc.sh is not executable" [ -x versa-proc.sh ]
for d in versa-pre.ini versa-post.ini; do
	verify "$d does not exist" [ -f $d ]
done

pax -wX bin lib tmp etc filesystem \
		versa-proc.sh proc.sh subproc.sh \
		versa-pre.ini versa-post.ini \
	| gzip -9 --rsyncable \
	>versabox.tar.gz
