get_lwopen_version() {
	BASEDIR=`dirname $0`/../..
	. $BASEDIR/samba/source/VERSION
	VERSION=${LIKEWISE_AUTH_MAJOR}.${LIKEWISE_AUTH_MINOR}.${LIKEWISE_AUTH_RELEASE}

	echo "${VERSION}"
}

create_rpmbuild_directory() {
	topdir=`rpm --eval %_topdir`
	mkdir -p ${topdir}/{SOURCES,SPECS,BUILD,RPMS,SRPMS}
}

build_dist() {
	BASEDIR=`dirname $0`/../..
	RELEASE=""

	. ${BASEDIR}/packaging/scripts/functions
	VERSION=$(get_lwopen_version)

	TARGET=likewise-open-$VERSION$RELEASE
	/bin/rm -rf $BASEDIR/../$TARGET || exit 1
	mkdir $BASEDIR/../$TARGET || exit 1
	for dir in centutils domainjoin winbindd; do
	        rsync -a --exclude=.git* --exclude=.svn --exclude=*~ --exclude=*bak \
	                $BASEDIR/$dir $BASEDIR/../$TARGET/ || exit 1
	done
	cd $BASEDIR/..
	tar cf - $TARGET | gzip -9 > likewise-open-$VERSION.tar.gz
}
