#!/bin/bash # Bail out if there are any errors set -e # There's probably a way to do this in the Makefile, but I couldn't figure # out how, so I'm doing it here. This script just tars up all the files, # excluding the demos that are not ready for release. # This script expects to be called with the TWHOME directory as its first # arg and the list of demo dirs as the rest. Both are defined in the # Makefile. TWHOME=$1 shift DEMO_DIRS=$@ # Returning 0 is true, and 1 is false, in the usual, paradoxical Unix way. function member () { arg=$1 shift; for elt in $@; do if [ $arg = $elt ]; then return 0 fi done return 1 } echo "demo dirs are ${DEMO_DIRS}" export TW_VERSION=tw-`cat VERSION` echo "TW_VERSION is ${TW_VERSION}" echo "TWHOME is ${TWHOME}" cd ${TWHOME} cd .. if [ -d ${TW_VERSION} ]; then echo "Directory ${TW_VERSION} already exists; assuming a re-release" rm -rf ${TW_VERSION} fi echo "Copying ${TWHOME} to ${TW_VERSION}" cp -ar ${TWHOME} ${TW_VERSION} cd ${TW_VERSION} make clean for dir in demos/*; do if ! member $dir $DEMO_DIRS ; then # echo "$dir is NOT a demo dir" rm -rf $dir fi done cd .. tarfile=${TW_VERSION}.tgz if [ -e $tarfile ]; then echo "removing old tarball $tarfile" rm $tarfile fi echo "Creating tarball $tarfile" tar --create -z --file=$tarfile ${TW_VERSION}