copy v2.1 version of promote.sh sitting in build.eclipse.org:/shared/webtools/releng.control/ to this repo because srsly who doesn't back up their code, right?

Signed-off-by: nickboldt <nboldt@redhat.com>
diff --git a/releng.control/promote.sh b/releng.control/promote.sh
index c6ff0c6..92766c9 100755
--- a/releng.control/promote.sh
+++ b/releng.control/promote.sh
@@ -1,17 +1,20 @@
 #!/usr/bin/env bash
 #
+# V2.1
 # Script to promote the latest build in the specified committers area
-#
-
+# Change control
+# [425061] A static URL to latest integration build  :: New function added to synchronize the I-latest directory with the repository and repositoryunittests from the build when required  ==> [-r] option
+# 
 function usage() 
 {
-    printf "\n\tUsage: %s [-v] [-d] [-s] [-c] [-z] [-a] [-p] projectname " $(basename $0) >&2
+    printf "\n\tUsage: %s [-v] [-d] [-s] [-c] [-r] [-z] [-a] [-p] projectname " $(basename $0) >&2
     printf "\n\t\t%s\t%s" "-p <projectname>," "where projectname is a cc project, such as wtp-R3.2.3-M, wtp-R3.3.0-I, etc. from which to get latest build." >&2	
     printf "\n\t\t%s\t%s" "-v" "verbose" >&2
     printf "\n\t\t%s\t%s" "-d" "delete old builds" >&2
     printf "\n\t\t%s\t%s" "-s" "send notification mail" >&2
     printf "\n\t\t%s\t%s" "-c" "copy the build from committers to downloads" >&2
-    printf "\n\t\t%s\t%s" "-z" "process artifacts (create pack200 gz jars, etc.) Remember, is long running" >&2 
+    printf "\n\t\t%s\t%s" "-r" "refresh I-latest with current build" >&2
+    printf "\n\t\t%s\t%s" "-z" "process artifacts (create pack200 gz jars, etc.) Remember, is long running. NOTE: This is not required for builds >=3.6.1" >&2 
     printf "\n\t\t%s\t%s" "-a" "add properties" >&2    
     printf "\n\t\t%s\t%s\n" "-h" "this help message" >&2
 }
@@ -64,6 +67,13 @@
     echo "   addProperties NOT requested"
 fi
 
+if [ $syncLatest ]
+  then
+	echo "   refresh I-latest repositories requested"
+  else
+	echo "   refresh I-latest repositories NOT requested"
+fi 
+
 }
 
 # see https://bugs.eclipse.org/bugs/show_bug.cgi?id=348028
@@ -81,7 +91,8 @@
 projectname=
 processArtifacts=
 addProperties=
-while getopts 'hvdcszap:' OPTION
+syncLatest=
+while getopts 'hvdcrszap:' OPTION
 do
     case $OPTION in
         h)    usage
@@ -98,6 +109,8 @@
         z)    processArtifacts=1
         ;;
         a)    addProperties=1        
+        ;;
+        r)    syncLatest=1        
         ;;        
         # we strip off ".ser", if present, just to make it easier to use with tab completion, etc., from 
         # releng.control directory, were the project files are named, for example, "wtp-R3.3.0-I.ser"
@@ -333,10 +346,32 @@
     then
         dropDirectory=${TODIR}${dropDirName}
         ./runAntRunner.sh "${PWD}/updateReferenceComposite.xml" "-DreferenceCompositeDir=$referenceCompositeDir" "-DdropDirectory=$dropDirectory"
-    fi 
+    fi
 else
     printf  "\n\t%s\n\n"   "Nothing copied: specify -c to actually do the copy"
-fi 
+fi
+
+if [ $syncLatest ]
+then
+    if [ "patches" != $distribution ]
+    then
+    	iLatest=${TODIR}I-latest
+
+    	mkdir -p iLatest/repository
+    	mkdir -p iLatest/repositoryunittests
+
+   	repoDir=${FROMDIR}/repository
+    	repoTestDir=${FROMDIR}/repositoryunittests
+   		
+	echo "Refreshing I-latest from [ ${FROMDIR} ]"
+    	rsync-retry $repoDir $iLatest $verboseFlag
+   	rsync-retry $repoTestDir $iLatest $verboseFlag
+       else
+       	 echo "Refresh I-latest operation is not allowed for Patches" 
+    fi
+else
+     echo "I-latest not updated. Specify -r if desired"
+fi
 
 if [ $sendmail ]
 then