#! /bin/bash

# usage:
#		tarball devel|release [<version>]
# example:
#		tarball release 1.40.3
# produces
#		snapshot/1.40.3/fxscintilla-1.40.3.tar.gz
# and
#		snapshot/1.40.3/fxscintilla-1.40.3.zip


if [ "$1" = "devel" ]; then
		devel=true
else
		devel=false
fi
	
version=$2

# Name
name="fxscintilla-"
if [ -z $version ]; then
		version="cvs"
fi
version_tag=`echo $version | sed 's/\./_/g'`
name="${name}${version}"
# Tag
if [ ! "$version" = "cvs" ]; then
		tag="FXSCINTILLA-${version_tag}"
else
		tag="HEAD"
fi


if [ ! -d snapshot ]; then
	mkdir snapshot
fi
cd snapshot
if [ ! -d ${version} ]; then
	mkdir ${version}
fi

rm -fr fxscintilla
cvs -z3 -w export -r "${tag}" fxscintilla

if [ "$devel" = "false" ]; then
		cd fxscintilla
		rm -fr scintilla/gtk scintilla/win32
		cd ..
fi

mv fxscintilla $name

binaries='*.png *.ico *.cur *.jpg *.bmp'

tar cvzf ${version}/${name}.tar.gz $name
zip -lr ${version}/${name}.zip ${name} -x ${binaries}
zip -ur ${version}/${name}.zip ${name} -i ${binaries}

mv $name fxscintilla

ls -l ${version}
cd ..
