#!/bin/sh
# bootcdmkbackupwiz
#
# Create a tar package with all files needed to backup 
# a debian or alien linux distribution.
# Alternatively you can download a prebuild tar package with:
# wget ftp://bootcd.alioth.debian.org/pub/bootcd/bootcdbackupwizard.tar.gz
#
# Please see README.Debian for more info

set -e

VERSION=5.04
D="bootcdbackwiztar"

usage()
{
  echo "Usage: bootcdmkbackwiztar [-f]" >&2
}

err()
{
  echo "$*" >&2
  exit 1
}

FORCE=""
while [ $# -ge 1 ]; do
  if [ "$1" = "-f" ]; then
    FORCE="1"
    shift
  else
    usage "Unknown argument <$1>"
    exit 1
  fi
done
  
[ -e "$D" -a ! "$FORCE" ] && err "$D already exists. Please move it away and run again"

rm -rf $D
mkdir $D
(
  cd $D
  apt-get source bootcd
  (

    [ ! -d bootcd-${VERSION} ] && err "apt-get source bootcd did not install the VERSION ${VERSION}, please change /etc/apt/sources.list"

    cd bootcd-${VERSION}
    debuild binary
    make bootcdbackwiz
  )
)
cp $D/bootcd-${VERSION}/bootcdbackupwizard_${VERSION}.tar.gz .
rm -r $D

echo "created bootcdbackupwizard_${VERSION}.tar.gz"
