#! /bin/sh
# ------------------------------------------------------------------------
# release-dos
#
# Makes a DOS release of the dbf2info package.
# This is a very prelimary DOS release.  It just copies the precompiled
# executables from the "dos" subdirectory and a couple other things out
# to a zip file.
#
# Eventually, I'll make a real NT release that will run from the NT machine's
# commmand prompt.
#
# ------------------------------------------------------------------------
#
#
# Set a temporary place to put the released files.
# If the tmp directory exists, it will be renamed as -old.
# If the -old tmp exists, it will be deleted.
#
tmp=/usr132/rbd/xxdbftemp
#
#
# Set a place to put the zip file(s).
#
release_path=/usr132/rbd/releases
#
#
# Set whether or not to create the release zip files.
#
make_zip=1
#
#
# Set whether or not to delete the tmp directory after ziping.
# This is only done if set to 1 AND one of the make_*_zip options are also 1.
#
rm_tmp_after_zip=1
#
# Set up.
#
dbfhome=`pwd`
dbf_rev=57            # can't have a dot in it!
tempfile=xxdbfrel.tmp
#
#
# --------------------------------------------------
# You should not have to change anything below here.
# --------------------------------------------------
#
# Retain old release directory if it exists.
#
if [ -d $tmp ] ;then
  if [ -d $tmp'-old' ] ;then
    rm -r $tmp'-old'
  fi
  mv $tmp $tmp'-old'
fi
#
#
# Copy the files to the temporary directory.
#
cd $dbfhome
cp -rp dos $tmp
cp README.NT $tmp/README.TXT
cd $tmp
u2d -m README.TXT
cd $dbfhome
#
#
# Make zip?
#
if [ $make_zip -eq 1 ] ;then
  cd $tmp
  #
  # Set full name of the zip file.
  #
  zipfile=$release_path'/dbf-'$dbf_rev'.zip'
  #
  # Delete existing zip.
  #
  if [ -f $zipfile ] ;then
    rm -f $zipfile
    if [ -f $zipfile ] ;then
      echo Could not delete existing $zipfile.
      exit
    fi
  fi
  #
  # Make the zip.
  #
  cd $tmp
  zip -r $zipfile .
  if [ ! -f $zipfile ] ;then
    echo Zip failed to create $zipfile.
    exit
  fi
  #
  # Copy out the README file.
  #
  cd $dbfhome
  docfile=$release_path'/dbf-'$dbf_rev'.txt'
  cp README.NT $docfile
  #u2d -m $docfile  (makes it double spaced in the browser)
  #
  # Remove the temporary directory
  #
  cd $dbfhome
  if [ $rm_tmp_after_zip -eq 1 ] ;then
    rm -rf $tmp
  fi
fi
#
#
# Done.
#
cd $dbfhome
exit
