#! /bin/sh

case "$#" in
1 )	;;
* )	echo "Usage: $0 version" >&2 ;exit 1 ;;
esac
version=$1

PREP=${TMP:-/tmp}/eugridpma.$$
DIST=webegp@www.eugridpma.org:/project/srv/www/site/eugridpma/html/distribution/
RSYNC="rsync -rav -e ssh"

mkdir $PREP
mkdir $PREP/$version
mkdir $PREP/$version/worthless
mkdir $PREP/$version/others
mkdir $PREP/$version/accredited
PREP=$PREP/$version

echo "This is version $1" > $PREP/version.txt

cat <<EOF > $PREP/worthless/README.txt

Version $1 WORTHLESS root certificates

This area contains explicitly "worthless" root certificates. Do
not rely on these certificates in a real environment - you install
them entirely at your own risk!

Examples of worthless CAs include the "tutorial" on-line exercise
CA, and the Globus Certificate Service.
Especially the Globus Certificate Service is governed by this
disclaimer from the Globus web site:

"
The Globus Certificate Service is a service that issues low-quality
certificates to users who require certificates to use the Globus
Toolkit(C) and do not have other means of acquiring certificates.  The
Globus Certificate Service is not a true CA (for example, it does not
revoke or reissue certificates) and certificates from the Globus
Certificate Service are intended solely for experimentation and
testing.  Care should be taken when using certificates issued by it,
particularly on production resources.

We strongly encourage users to use more secure alternatives to the
Globus Certificate Service
"

EOF


cat <<EOF > $PREP/others/README.txt

Version $1 other root certificates

This area contains non-accredited root certificates -- you install 
them entirely at your own risk! But they could be quite good as well,
but just not fitting the current set of guidelines.

Examples of "other" CAs include the Fermilab KerberosCA root.

EOF

( cd .. ; tar zcvf $PREP/eugridpma-carep-$1.tar.gz \
	--exclude "carep/accredited" \
	--exclude "carep/others" \
	--exclude "carep/worthless" \
	--exclude "CVS" \
	carep
)

rpmtop=`awk '/^%_topdir/ { t=$NF } END {print t}' $HOME/.rpmmacros`
rpmbuild -ba eugridpma.spec

cp -p $rpmtop/SRPMS/ca_policy_eugridpma-$1*.src.rpm $PREP/
cp -p $rpmtop/RPMS/noarch/ca_policy_eugridpma-$1*.noarch.rpm $PREP/

( cd $PREP ; yum-arch . )

cp -pr accredited worthless others CHANGES $PREP/

( cd $PREP ; $RSYNC $PREP $DIST )
