#!/bin/sh

OSNAME=$(uname)
VER=`cat Version`

if [ "$OSNAME" = "AIX" ]
then
        source=/opt/freeware/src/packages
        echo '.svn' > /tmp/xcat-excludes
        tar -X /tmp/xcat-excludes -cf $source/SOURCES/xCAT-test-$VER.tar xCAT-test
        gzip -f $source/SOURCES/xCAT-test-$VER.tar
        rm -f $source/SRPMS/xCAT-test*rpm $source/RPMS/ppc/xCAT-test*rpm
        rpm -ba xCAT-test/xCAT-test.spec
        #rpm -ta $source/SOURCES/xCAT-test-$VER.tar.gz
else
	if [ -f /etc/redhat-release ]
	then
   		pkg="redhat"
	else
   		pkg="packages"
	fi

	set -x
	tar --exclude=.svn -czhf /usr/src/$pkg/SOURCES/xCAT-test-$VER.tar.gz xCAT-test
	rm -f /usr/src/$pkg/SRPMS/xCAT-test-$VER*rpm /usr/src/$pkg/RPMS/noarch/xCAT-test-$VER*rpm
	rpmbuild -ta /usr/src/$pkg/SOURCES/xCAT-test-$VER.tar.gz
fi
