Index: /issm/trunk-jpl/jenkins/jenkins.sh
===================================================================
--- /issm/trunk-jpl/jenkins/jenkins.sh	(revision 24271)
+++ /issm/trunk-jpl/jenkins/jenkins.sh	(revision 24272)
@@ -1,5 +1,16 @@
 #!/bin/bash
-#This bash script calls the nightlyrun.m matlab file to run our nightly test decks.
-#It then processes the results and sends an email to the Ice developpers.
+################################################################################
+# This bash script manages installation of ISSM on a given Jenkins node using a
+# configuration file passed as the only argument. This file also contains
+# details about which nightly run tests should be executed after the build has
+# been completed. Finally, results of the build and tests are emailed to the
+# members of the ISSM development team.
+#
+# TODO:
+# - Rename TEMP to something more descriptive
+# - Ensure first that other parts of the build system do not rely on this
+#	name
+# - Investigate refactoring parsing of list of changed files
+################################################################################
 
 echo "Cleaning up execution directory"
@@ -53,16 +64,20 @@
 	echo "Current  revision number: $SVN_CURRENT"
 
-	#Get changes from jenkins itself (svn requires credentials)
+	# Get list of changed files
+	#
+
 	#svn --non-interactive --no-auth-cache --trust-server-cert diff -r $SVN_PREVIOUS:$SVN_CURRENT --summarize $ISSM_DIR | awk '{print $NF}' > $ISSM_DIR/TEMP
+
+	# Get list of changes from Jenkins itself as svn requires credentials
 	rm -rf changes
 	wget $SERVER/job/$JOB_NAME/$BUILD_NUMBER/changes > /dev/null 2>&1
 
-	#Process html page and get the list of files that has changed (tricky...)
+	# Process html page and get the list of files that has changed (tricky...)
 	#cat changes | grep '="The file was modified"' | sed -e 's/.*<\/td><td><a>\(.*\)<\/a><\/td><td>.*/\1/' > $ISSM_DIR/TEMP
 	#cat changes | grep 'document_edit' |sed -e 's/document_edit.png/document_edit.png\
 		#/g' | sed -e 's/.*<\/a><\/td><td>\(.*\)<\/td><\/tr>.*/\1/' | grep -v 'document_edit.png' > $ISSM_DIR/TEMP
-	cat changes  | tr " " "\n" | grep trunk |  sed -e 's/.*<a>\(.*\)<\/a>.*/\1/' > $ISSM_DIR/TEMP
-
-	#Print list of files
+	cat changes  | tr " " "\n" | grep trunk | sed -e 's/.*<a>\(.*\)<\/a>.*/\1/' > $ISSM_DIR/TEMP
+
+	# Print list of changed files
 	echo "   "
 	echo "List of updated files"
@@ -70,6 +85,11 @@
 	echo "   "
 
-	#Do we need to reinstall externalpackages?
+	###################################
+	### Determine installation type ###
+	###################################
 	echo "Determining installation type"
+
+	# If the contents of the externalpackages directory were modified in any
+	# way, check for changed external packages
 	if [ ! -z "$(cat $ISSM_DIR/TEMP | grep externalpackages)" ] ; then
 		echo "  -- checking for changed externalpackages... yes";
@@ -80,7 +100,8 @@
 	fi
 
-	#Do we need to reconfigure
+	# If the Makefile or m4 diirectory were changed in any way or if certain
+	# binary files from a previous compilation do not exist, reconfigure
 	if [ ! -z "$(cat $ISSM_DIR/TEMP | grep -e "Makefile.am" -e "m4" )" ] ||
-		[ ! -f "$ISSM_DIR/bin/issm.exe" ] ||
+		[ ! -f "$ISSM_DIR/bin/issm.exe" ] && [ ! -f "$ISSM_DIR/bin/issm-bin.js" ] ||
 		[ "$ISSM_EXTERNALPACKAGES" == "yes" ] ;
 	then
@@ -92,5 +113,5 @@
 	fi
 
-	#Do we need to recompile
+	# If source files were changed in any way, recompile
 	if [ ! -z "$(cat $ISSM_DIR/TEMP | grep -e "\.cpp" -e "\.h" )" ] ||
 		[ "$ISSM_RECONFIGURE" == "yes" ] ;
@@ -102,8 +123,8 @@
 		ISSM_COMPILATION="no"
 	fi
-	#ISSM_COMPILATION="yes"
+
+	# Cleanup
 	rm changes
 	rm $ISSM_DIR/TEMP
-
 else
 	echo "Previous revision not found, this must be a fresh install"
@@ -115,4 +136,5 @@
 	ISSM_COMPILATION="yes"
 fi
+
 echo " "
 echo "Recording current svn version: $SVN_REVISION_1"
