#!/bin/sh

setvar CWD = $(pwd)
echo ${CWD##*/} # prevent running from elsewhere

# see support for these vars
test -f support/fw.conf && setvar fw = "support/fw.conf" || setvar fw = ''
test -f support/rootfs-packages.conf && setvar rfsp = "support/rootfs-packages.conf" || setvar rfsp = ''
test -f support/mkwall.conf && setvar mkw = "support/mkwall.conf" || setvar mkw = ''

proc _help {
	xmessage -c \
	"This is a handy utility to store your woof-CE configuration.

Please setup the var 'XTRA_FLG' in '_00build.conf'
A tarball of your config files is made in the current dir.
Be careful when restoring backups as files may have changed!

PLEASE RUN THIS FROM THE COMMAND LINE!

see..
_00build.conf
DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
$fw  $rfsp  $mkw

To restore a backup just extract the generated tarball in place."
	exit 0
}

echo ${CWD##*/} | grep -q '^woof-out' || _help

source ./DISTRO_SPECS 2>/dev/null
source ./_00build.conf

case (1) {
	*h* {_help}
}
test -z $XTRA_FLG && _help # make sure the clickers are ok

echo "Press Enter.."
read || _help
echo "Backing up ...
"
tar cvf z${XTRA_FLG}.tar _00build.conf \
		DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} \
		$fw $rfsp $mkw