#! /bin/sh
# $OpenLDAP: pkg/ldap/build/mkrelease,v 1.23.2.6 2010/04/13 20:22:21 kurt Exp $
## This work is part of OpenLDAP Software <http://www.openldap.org/>.
##
## Copyright 1998-2010 The OpenLDAP Foundation.
## All rights reserved.
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted only as authorized by the OpenLDAP
## Public License.
##
## A copy of this license is available in the file LICENSE in the
## top-level directory of the distribution or, alternatively, at
## <http://www.OpenLDAP.org/license.html>.
#
# Make a release
#	mkrelease RELNAME CVSTAG CVSMODULES
# where CVSTAG is the tag to export from the current CVSROOT
#

#
# This script MUST NOT add files to the export nor modify
# any file in the export.
#

set -e 		# exit immediately if any errors occur

if test $# != 3 ; then
	echo 'usage: mkrelease RELNAME CVSTAG CVSMODULES ...'
	exit 1
fi

RELNAME=openldap-$1
shift
CVSTAG=$1
shift

if test -e $RELNAME ; then
	echo "error: $RELNAME exists"
	exit 1
fi

echo Release: $RELNAME
echo CVS Tag: $CVSTAG
echo Modules: $*

cvs -q export -kkv -r $CVSTAG -d $RELNAME $*

if test ! -d $RELNAME ; then
	echo "error: $RELNAME doesn't exists"
	exit 1
fi

if test -e $RELNAME/doc/guide/admin/guide.sdf ; then
	echo "build guide..."
	( cd $RELNAME/doc/guide/admin ; make guide.html )
else
	echo "No guide"
fi

if test -e $RELNAME/libraries/liblunicode/ucdata/uctable.h ; then
	echo "touching uctable.h..."
	touch $RELNAME/libraries/liblunicode/ucdata/uctable.h
fi

if test ! -e $RELNAME/build/version.sh ; then
	echo "No build version"
	OL_STRING="something"
else
	eval `$RELNAME/build/version.sh`
fi

echo "Rolling up $OL_STRING ..."


tar cf $RELNAME.tar $RELNAME
gzip -9 -c $RELNAME.tar > $RELNAME.tgz
md5 $RELNAME.tgz > $RELNAME.md5
sha1 $RELNAME.tgz > $RELNAME.sha1
rm -f $RELNAME.tar

ls -l $RELNAME.*

echo "Made $OL_STRING as $RELNAME.tgz"
