#! /bin/bash
#
# description: script to autocompress of last building OOo4Kids and generate the md5sum
# author: Ben Bois
# last update: 2009.10.04
#

if [ -z $1 ] || [ -z $2 ] || [ -z $3 ]
then
	echo ""
	echo "usage: $0 version CPUtype builderName"
	echo ""
	echo "example:"
	echo "        $0 0.6 Linux_intel_X86-64 benb"
	echo ""
	echo "Note: It needs to be execute in the target folder:"
	echo "        tree_root/instsetoo_native/unxlngx6.pro/OOo4Kids/installed/install/"
	echo ""
	exit 0
fi

ARRAY=(`ls -1AB`)
LEN=${#ARRAY[*]}

echo "creating tree for upload '$2/$1'..."
mkdir $2
mkdir $2/$1

i=0
while [ $i -lt $LEN ]; do
	LANG=${ARRAY[$i]}
	if [ -d $LANG ] && [ $LANG != 'log' ]
	then 
		echo "creating '$2/$1/$LANG'folder..."
		mkdir $2/$1/${LANG}
		echo "folder '$LANG' is compressing..."
		tar czf $2/$1/${LANG}/OOo4Kids_$1_$2_${LANG}_$3.tar.gz ${LANG}
		echo "folder '$LANG' is md5suming..."
		md5sum $2/$1/${LANG}/OOo4Kids_$1_$2_${LANG}_$3.tar.gz > $2/$1/${LANG}/OOo4Kids_$1_$2_${LANG}_$3.tar.gz.md5
	fi
	let i++
done

exit 0


