#!/bin/ksh
# **********************************************************************
# *                                                                    *
# *  Make Special Source Distribution for Helsinki DPolApp Developers  *
# *                                                                    *
# **********************************************************************
# File: DPolAppSource
#
#                       COPYRIGHT (c) 2006 BY
#         SIGMET INCORPORATED, 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="dpolapp-source"

VERSION="`show_machine_code -version | tr -dc '.[0-9]'`"

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

PUBLICNAME="haze:/usr/sigmet/info/DeveloperResources/dpolapp-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

# We are providing the source code to the following programs:
#   iris/reingest
# And the following libraries
#   libs/share
#   dpolapp/src
#
${IRIS_INS}make_iris_tape -stdout 8 \
  -source iris/reingest     -source libs/share       -source dpolapp/src\
    > ${IRIS_REL}${BASENAME}

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

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