#!/bin/bash

tempfile=`mktemp`
echo "Enter Changes" >&2
cat >"$tempfile"

SUBJECT="[ANNOUNCEMENT] Updated Cygwin/X packages"
PKGS=""
for file in "$@"; do
    filename=`basename "$file" .tar.bz2`
    case "$filename" in
      *-src)
      ;;
      *) PKGS="$PKGS $filename"
      ;;
    esac 
done
test -n "$PKGS" && SUBJECT="[ANNOUNCEMENT] Updated: $PKGS"

(
cat <<EOF
The following packages have been updated in the Cygwin distribution:

EOF
(
echo "filename	size	md5sum" 
for file in "$@"; do
    filename=`basename "$file" .tar.bz2`
    size=`ls -h --size "$file" | cut -b1-4`
    sum=`md5sum "$file" | cut -f1 -d\ `
    echo "$filename	$size	$sum"
done
) | expand -t 35,45

cat << EOF

Changes
=======

EOF
cat < "$tempfile"
rm "$tempfile"
cat << EOF

======= 

To update your installation, click on the "Install Cygwin now" link on
the http://cygwin.com/ web page.  This downloads setup.exe to your
system.  Once you've downloaded setup.exe, run it and select "X11"
and then click on the appropriate field until the above announced
version number appears if it is not displayed already.

If your mirror doesn't yet have the latest version of these package after
24 hours, you can either continue to wait for that site to be updated or
you can try to find another mirror.

If you're not sure what version do you have you can use the following
command:
$ cygcheck -c xorg-x11-xwin
EOF
cygcheck -c xorg-x11-xwin
cat <<EOF

For other packages than xorg-x11-xwin use the packagename as parameter.

Please send questions or comments to the Cygwin/X mailing list at:
cygwin-xfree@cygwin.com

If you want to subscribe to the mailinglist go to:
http://cygwin.com/lists.html

I would appreciate if you would use this mailing list rather than
emailing me directly.  This includes ideas and comments about the setup
utility or Cygwin/X in general.

If you want to make a point or ask a question the Cygwin/X mailing
list is the appropriate place.

    *** CYGWIN-XFREE-ANNOUNCE UNSUBSCRIBE INFO ***
 
If you want to unsubscribe from the cygwin-xfree-announce mailing list, 
look at the "List-Unsubscribe: " tag in the email header of this message.
Send email to the address specified there.  It will be in the format:

cygwin-xfree-announce-unsubscribe-you=yourdomain.com@cygwin.com

If you need more information on unsubscribing, start reading here:

http://sources.redhat.com/lists.html#unsubscribe-simple

Please read *all* of the information on unsubscribing that is available
starting at this URL.    
EOF
) | gpg --clearsign | \
        EMAIL="Alexander.Gottwald@s1999.tu-chemnitz.de" \
        REPLYTO="cygwin-xfree@cygwin.com" \
        mutt -s "$SUBJECT" \
        cygwin-xfree-announce@cygwin.com
