#!/bin/sh set -e set -u TYPE=`basename $0 | cut -f2 -d-` # # Script to generate distribution builds of LifeType # # (c) 27-08-2004, the LifeType Team # # array with the files that we are going to remove before # making the package... Wildcards, complete paths, whatever # can be used here # TOREMOVE="unported/ bin/" WORKFOLDER="/tmp/" #sourceforge wants all unique filenames. So # we code them with a version number. ugh. VERSION="1.2" # # helper functions to print things in different colors # NOCOLOR='\e[0m' message() { echo -e "\033[01;32m$*$NOCOLOR" } warning() { echo -e "\033[01;33m$*$NOCOLOR" } error() { echo -e "\033[01;31m$*$NOCOLOR" } # check parameters if [ $# -lt 1 ]; then echo "Makes a zip package of a given $TYPE" echo "" echo "Usage: $0 [noupload] <$TYPE name>" echo "" echo "Use 'all' in order to generate a package of all the ${TYPE}s" exit -1 fi # get the name of the object that we're trying to build if [ "${1:-}" == "noupload" ]; then message "Building, not uploading"; UPLOAD="" NAME=$2 else message "Building and uploading, please type your sourceforge username" read UPLOAD if [ "${UPLOAD:-}" == "" ]; then error "A sourceforge username is required to upload, or else use 'noupload'." exit fi NAME=$1 fi # a temporary working folder like any other... TMPFOLDER=${WORKFOLDER}`date | md5` CURFOLDER=`pwd` # export the current folder message "Exporting folder..." svn export . $TMPFOLDER # remove whatever we don't need message "Removing unnecessary files..."; for i in ${TOREMOVE} do message " -- removing $i" rm -rf ${TMPFOLDER}/$i done # build the correct template package, or all of them if that's what we were requested to do... cd $TMPFOLDER message "Creating ZIP package..." if [ $NAME == "all" ]; then NAME=all_${TYPE}s zip -qr ${CURFOLDER}/${VERSION}_${NAME}.zip . else zip -r ${CURFOLDER}/${VERSION}_${NAME}.zip $NAME fi if [ "$UPLOAD" != "" ]; then # upload the package. scp ${CURFOLDER}/${VERSION}_${NAME}.zip ${UPLOAD},lifetype@frs.sourceforge.net:/home/frs/project/l/li/lifetype/lifetype-${TYPE}s/lifetype-${VERSION}/${VERSION}_${NAME}.zip fi message "Done!" # cleanup rm -rf $TMPFOLDER