#!/bin/sh
# ***********************************************
# *                                             *
# *  Make Special Source Distribution for RSIS  *
# *                                             *
# ***********************************************
# File: RsisSource
#
#                COPYRIGHT (c) 2003, 2007, 2010 BY
#           VAISALA INC., WESTFORD MASSACHUSETTS, U.S.A.
# 
# THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND  COPIED
# ONLY  IN  ACCORDANCE WITH  THE  TERMS  OF  SUCH  LICENSE  AND WITH THE
# INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE  OR  ANY OTHER
# COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
# OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE  IS  HEREBY
# TRANSFERED.

BASENAME="rsis-source"

VERSION="`show_machine_code --version | sed 's/ *$//' | sed 's/.* //'`"

IRIS_REL=${IRIS_ROOT}"/rda-${VERSION}/"
IRIS_INS=${IRIS_ROOT}"/install/"

PUBLICNAME="wes-hazy:/usr/sigmet_info/DeveloperResources/RSIS-Files/${BASENAME}-${VERSION}.tgz"

# The original release directory had better be there, but not the file
# we're about to create.
#
if [ ! -d ${IRIS_REL} ] ; then
  echo "Sorry, '${IRIS_REL}' does not yet exist.  You must build"
  echo "  a standard IRIS release first before adding these special source"
  echo "  files to it."
  exit 1
fi
if [ -r "${IRIS_REL}${BASENAME}.tgz" ] ; then
  echo "Sorry, ${IRIS_REL}${BASENAME}.tgz already exists.  Please manually"
  echo "  delete the existing file if you really intend to recreate it."
  exit 1
fi

echo "Making ${IRIS_REL}${BASENAME}.tgz..."

rm -f ${IRIS_REL}${BASENAME} ${IRIS_REL}${BASENAME}.tgz

${IRIS_INS}make_iris_tape -stdout 8 -rda \
  -source utils/antennax    -source utils/ascopex    -source utils/dspx \
  -source utils/zauto7      -source utils/sigbru     -source utils/bitex2 \
  -source utils/rtdisp      -source utils/antenna    -source utils/zcal \
  -source utils/colorsetup  -source utils/misc       -source utils/manuals \
  -source utils/dsp         -source utils/custom \
    > ${IRIS_REL}${BASENAME}

gzip -S .tgz --best ${IRIS_REL}${BASENAME}

echo ""
echo "Make this file available as:"
read -p "${PUBLICNAME} ? [no]" REPLY
if [ "${REPLY}" = "yes" ] ; then
  echo "Installing public file..."
  rcp ${IRIS_REL}${BASENAME}.tgz ${PUBLICNAME}
fi
