#!/bin/sh
#
# Copyright (C) 2000-2002 The ViewCVS Group. All Rights Reserved.
#
# By using this file, you agree to the terms and conditions set forth in
# the LICENSE.html file which can be found at the top level of the ViewCVS
# distribution or at http://viewcvs.sourceforge.net/license-1.html.
#
# Contact information:
#   Greg Stein, PO Box 760, Palo Alto, CA, 94302
#   gstein@lyra.org, http://viewcvs.sourceforge.net/
#
# -----------------------------------------------------------------------
#
# make-release: internal tool for creating ViewCVS releases
#
# -----------------------------------------------------------------------
#

if test $# != 2; then
  echo "USAGE: $0 tagname target-directory"
  exit 1
fi

if test -e $2; then
  echo "ERROR: must remove $2 first."
  exit 1
fi

# grab a copy of the CVS repository
echo 'Checking out into:' $2
cvs -d :pserver:anonymous@cvs.viewcvs.sourceforge.net:/cvsroot/viewcvs export -r $1 -d $2 viewcvs

# various shifting, cleanup.
# documentation is now also distributed together with the release, 
# but we still copy the license file to its traditional place (it is small 
# and many files still contain comments refering to this location):
cp $2/website/license-1.html $2/LICENSE.html
# rm -r $2/website
# remove some tools only useful for ViewCVS developers:
rm $2/tools/make-release
rm -f $2/tools/bin2inline_py.py

# Make sure, permissions are reasonable:
find $2 -print | xargs chmod uoa+r
find $2 -type d -print | xargs chmod uoa+x

# cut the tarball:
tar cf - $2 | gzip -9 > $2.tar.gz
# create also a ZIP file for those poor souls :-) still using Windows: 
zip -qor9 $2.zip $2

echo 'Done.'
