#!/bin/bash

set -x

find . -type f -a \( -iname '*.so' -o -iname '*.a' -o -iname '*.jar' -o -iname '*.exe' -o -iname Thumbs.db \) -print0 | xargs -r0 rm
find SpreadsheetTester -type f -iname MSPCCS_SpreadsheetTester -print0 | xargs -r0 rm
rm -f CCS/docs/html/jquery.js
find . -type f -perm /111 -print0 | xargs -r0 chmod -x
find . ! -perm /200 -print0 | xargs -r0 chmod -c u+w
chmod +x $0 debian/rules

name=`basename $PWD | sed -e 's/geotran[sz][-]*\([0-9.]\+\)$/geotranz_\1/'`
tar -C .. --exclude $name/debian -cpf ../$name.orig.tar $name && bzip2 -9 ../$name.orig.tar
