From 4e4949d7bcc89d319abfb866fb0ce0dc5d9fe058 Mon Sep 17 00:00:00 2001
From: david_williams <david_williams>
Date: Sat, 13 Dec 2008 18:17:17 +0000
Subject: [PATCH] automate sending of "declared" mail

---
 releng.control/promote.sh         | 16 ++++++++--
 releng.control/sendPromoteMail.sh | 49 +++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 2 deletions(-)
 create mode 100644 releng.control/sendPromoteMail.sh

diff --git a/releng.control/promote.sh b/releng.control/promote.sh
index d77298ab0..8ac70340e 100755
--- a/releng.control/promote.sh
+++ b/releng.control/promote.sh
@@ -14,7 +14,7 @@ verboseFlag=
 deleteOld=
 doCopy=
 projectname=
-while getopts 'hvdcp:' OPTION
+while getopts 'hvdcsp:' OPTION
 do
     case $OPTION in
         h)    usage
@@ -26,7 +26,9 @@ do
         ;;
         c)    doCopy=1
         ;;
-        p)    projectname=$OPTARG
+        s)    sendmail=1
+        ;;
+         p)    projectname=$OPTARG
         ;;
         ?)    usage
         exit 2
@@ -179,10 +181,20 @@ then
     # remember TODIR already has a slash
     ${REMOTE_SSH_COMMAND} perl -w -pi -e ${replaceCommand} ${TODIR}${dropDirName}/*.php
 
+    # send notification mail only if copying? 
+
 else
     printf  "\n\t%s\n\n"   "Nothing copied: specify -c to actually do the copy"
 fi 
 
+if [ $sendmail ]
+then
+    ./sendPromoteMail.sh "$projectname" "$TODIR" "$dropDirName"
+    echo "mail sent"
+else
+    echo "no mail sent. Specify -s if desired"
+fi 
+
 
 if [ $deleteOld ] 
 then 
diff --git a/releng.control/sendPromoteMail.sh b/releng.control/sendPromoteMail.sh
new file mode 100644
index 000000000..ecb8a9466
--- /dev/null
+++ b/releng.control/sendPromoteMail.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+PROJECT=$1
+if [ -z $PROJECT ]
+then
+    echo "must provide project name as first argumnet"
+    exit 9;
+fi
+TODIR=$2
+if [ -z $TODIR ]
+then
+    echo "must provide TODIR name as first argumnet"
+    exit 8;
+fi
+DROPDIR=$3
+if [ -z $DROPDIR ]
+then
+    echo "must provide DROPDIR name as first argumnet"
+    exit 7;
+fi
+
+# ideally, the user executing this mail will have this special file in their home direcotry,
+# that can specify a custom 'from' variable, but still use your "real" ID that is subscribed
+# to the mailing lists
+#   set from="\"Your Friendly WTP Builder\" <david_williams@us.ibm.com>"
+# correction ... seems the subscription system set's the "from" name, so doesn't work when 
+# sent to mail list (just other email addresses)
+export MAILRC=~/.buildermailrc
+
+SUBJECT="Declaring Build for $PROJECT: $DROPDIR"
+
+# wtp-dev for promotes, wtp-releng for smoketest requests
+TO="wtp-dev@eclipse.org"
+
+#make sure reply to goes back to the list
+REPLYTO="wtp-dev@eclipse.org"
+#we need to "fix up" TODIR since it's in file form, not URL
+URLTODIR=${TODIR##*${DOWNLOAD_ROOT}}
+mail -s "$SUBJECT" -R "$REPLYTO" "$TO"  <<EOF 
+ 
+
+Download Page: 
+http://download.eclipse.org$URLTODIR$DROPDIR
+
+General Smoketest results page:
+http://wiki.eclipse.org/WTP_Smoke_Test_Results
+
+EOF
+
-- 
GitLab