#
#
# Does a build in the XServe

. scripts/build_package_prepare_upload_unpack

logpath=log
if test "$outdir" != ""; then
        logpath="$outdir/log"
fi

source_dir=`basename $source_tar .tar.gz`

echo "Building"
if test "$autobuild" == 1; then
scripts/runcmd  -m=".* BUILDING" -l=$logpath.$caller.`whoami` $sshcmd $target_host \"cd $target_build_dir/$source_dir \; cp -f res/include/wb_config_$edition.h wb_config.h \; xcodebuild -configuration Release -sdk macosx10.5 clean build\"
else
scripts/runcmd  -n=$caller -m=".* BUILDING" -l=$logpath.$caller.`whoami` $sshcmd $target_host \"cd $target_build_dir/$source_dir\; cp -f res/include/wb_config_$edition.h wb_config.h \; xcodebuild -configuration Release -sdk macosx10.5 clean build\"
fi
if [ $? -ne 0 ]; then
	echo "$0 failed"
	exit 1
fi

outgoing=$outdir
if test "$outgoing" = ""; then
        outgoing="outgoing"
fi

echo "Creating dmg"
$sshcmd $target_host "cd $target_build_dir/$source_dir ; ~/guibuild/make_dmg.sh $edition $version build/Release/MySQLWorkbench.app"

echo "Downloading dmg"
$scpcmd $target_host:$target_build_dir/$source_dir/mysql-workbench-$edition-$version*.dmg $outgoing/

echo "Done"

