#!/bin/sh
#
# This is a simple backup script for archiving source trees quickly.
#

# For some reason, GNU tar 1.12 requires the tfp_comp entry whereas GNU tar
# */1.13 correctly uses the tfp_comp entry. Go figure.  Include both so we
# don't have to worry about which version of tar we are using.
EXCLUDES="*.o *~ set_rtlimits"

# Obtain the name of the directory we are in.  This will also be used to
# form the name of the archive.  Use the non-builtin version to be sure
# of having a fully qualified name (ie, no symlinks).
PWD=`/bin/pwd`
CURR_DIR=`basename $PWD`

# No globbing for the next bit to avoid pathname expansion of $EXCLUDES
# in the for command
set -f

# Form the exclusion list into something TAR understands
EXCL=
for i in $EXCLUDES ; do
  EXCL="${EXCL} --exclude=${i}"
done
set +f

cd ..
tar cfz ${CURR_DIR}.tgz $EXCL $CURR_DIR/
cd $CURR_DIR
