#!/bin/sh

# sample settings
# host=storm.suse.cz
# distro=x86_64
# status_file="--status-file=../build.4.stat"
# rebuild="--rebuild"
# min=--min
# common_flags="--force"

usage()
{
    echo "This script builds OOo-devel and OOo-i18n using abuild in one call"
    
    echo "Usage: ooo-build-all --host=<host> --distro=<distro> [--min] ..."
    echo 
    echo "FIXME: Try ooo-build-package --help to get list of all options ;-)"
    
}

if test "z$1" = "z--help" ; then
    usage
    exit 1;
fi

# typical common 
common_options="$@"

devel_options="$common_options
    --keep-remote-tempdir
    --no-final-message"

devel_status_file=`ooo-build-package $devel_options --get-status-file OpenOffice_org.spec | tail -n 1`

if test -z "$devel_status_file" ; then
    echo "Error: Was not able to get status file for devel build"
    exit 1;
fi

other_options="$common_options
    --keep-remote-tempdir
    --prefer-rpms-from-build=$devel_status_file
    --re-use-remote-sources-from-build=$devel_status_file
    --do-not-update-remote-sources"

ooo-build-package $devel_options OpenOffice_org.spec || exit 1;

for other in icon-themes i18n i18n-group1 i18n-group2 ; do
    if test -f OpenOffice_org-$other.spec ; then
	ooo-build-package $other_options OpenOffice_org-$other.spec || exit 1;
    fi
done


remove_options="$common_options
    --remove-remote-tempdir=$devel_status_file"

ooo-build-package $remove_options || exit 1;
