# Build preparation
# - copy tar.gz to the vm
# - unpack



source_tar=$1
version=$2
edition=$3
target_host=mysqldev@$4
caller=`basename $5`
target_build_dir="\\Documents and Settings\\mysqldev\\build"
mounted_build_dir="/guibuilds/winshare"

sshcmd="ssh -i /guibuilds/scripts/ssh_identity_for_vms"
scpcmd="scp -i /guibuilds/scripts/ssh_identity_for_vms"

upload_srcs=1


if test "$source_tar" = ""; then
	echo "ERROR: You must pass source tar file and target host as argument!"
	exit 1
fi

if test "$version" = ""; then
	echo "ERROR: You must specify the version"
	exit 1
fi

if test "$target_host" = ""; then
	echo "ERROR: You must give a target host (eg 10.1.2.3)"
	exit 1
fi


echo "Remove old stuff in $target_build_dir (through $mounted_build_dir)"
sudo rm -fr $mounted_build_dir/mysql-workbench-*


if [ $upload_srcs -eq 1 ]; then
	echo "Uploading Sources"
	echo "$source_tar --> $mounted_build_dir"
	sudo cp $source_tar $mounted_build_dir
else
	echo "Skip upload srcs"	
fi


echo  "Unpacking sources"
pushd $mounted_build_dir
sudo tar xzf `basename $source_tar`
popd


