#!/bin/sh

MKDIR=`which mkdir` 
STRIP=`which strip`
SYSTEM=`uname -s`

TAR=`which tar`
GZIP=`which gzip`

RM=`which rm`
CP=`which cp`
CHMOD=`which chmod`

VERSION="2.0.0"

DIR_NAME="osiris-${VERSION}"
PACKAGE_NAME="${DIR_NAME}-${SYSTEM}.tar"

echo "-------------------------------------------------------------------------"
echo "building release tarball: ${TARBALL}"

# make a temporary directory.

${MKDIR} ./${DIR_NAME}
cd ./${DIR_NAME}

# copy in the binaries, then strip them.

${CP} ../../cli/osiris .
${STRIP} ./osiris

${CP} ../../osirisd/osirisd .
${STRIP} ./osirisd

# copy the LICENSE file.

${CP} ../../../LICENSE .

# copy in the installer script.

${CP} ../install.sh .
${CHMOD} ug+x ./install.sh

# copy in platform specific crap.

case ${SYSTEM} in
Linux)
    ${CP} -rf ../linux .
    ;;
Darwin)
    ${CP} -rf ../darwin .
    ;;
FreeBSD)
    ${CP} -rf ../freebsd .
    ;;
*)
    ;;
esac


echo "installer package contents:"

ls -lA
cd ..

${TAR} cf ${PACKAGE_NAME} ${DIR_NAME}
${GZIP} ${PACKAGE_NAME}

# remove temporary directory.

${RM} -rf ${DIR_NAME}

echo "-------------------------------------------------------------------------"
echo "installer package created."
echo ""

