365340 - Enhancement to check basic installation for running a build
diff --git a/releng.wtpbuilder/build.xml b/releng.wtpbuilder/build.xml
index 7d7f49d..044f5a5 100644
--- a/releng.wtpbuilder/build.xml
+++ b/releng.wtpbuilder/build.xml
@@ -7,7 +7,7 @@
     <!-- main -->
     <target
         name="build"
-        depends="init"
+        depends="init, preBuild"
         if="build_distro_target_exists">
         
         <!-- remove eclipse builder at start of every major build, so it will be reinstalled -->
@@ -190,4 +190,30 @@
             value="true"/>
 
     </target>
+    <!--
+        Steps to do before running a build.
+    -->
+    <target name="preBuild">        
+        <!-- Verify that cvs is installed before starting a build. -->
+        <ant antfile="${wtp.builder.home}/scripts/build/checkSystemPrereq.xml">
+            <property
+                name="commandName"
+                value="cvs"/>
+            <property
+                name="arguments"
+                value="--version"/>
+        </ant>
+
+        <!-- Verify that grep is installed. -->
+        <ant antfile="${wtp.builder.home}/scripts/build/checkSystemPrereq.xml">
+            <property
+                name="commandName"
+                value="grep"/>
+            <property
+                name="arguments"
+                value="--version"/>
+        </ant>
+
+       <echo message="All build system prereqs passed"/>
+    </target>
 </project>
\ No newline at end of file
diff --git a/releng.wtpbuilder/scripts/build/checkForFastFail.xml b/releng.wtpbuilder/scripts/build/checkForFastFail.xml
index 06942bc..9a5c728 100644
--- a/releng.wtpbuilder/scripts/build/checkForFastFail.xml
+++ b/releng.wtpbuilder/scripts/build/checkForFastFail.xml
@@ -68,7 +68,7 @@
             outputproperty="reasonFailed"
             resultproperty="returnCode"
             errorproperty="ignoredErrored"
-            error="/dev/null"
+            error="${env.LOG_DIR}/${projectname}/grepError.log"
             failonerror="false">
             <arg line="-s --max-count 1 --after-context 20 --before-context 10 --regexp='${stringToCheck}' ${resource}"/>
         </exec>
diff --git a/releng.wtpbuilder/scripts/build/checkSystemPrereq.xml b/releng.wtpbuilder/scripts/build/checkSystemPrereq.xml
new file mode 100644
index 0000000..6cab8db
--- /dev/null
+++ b/releng.wtpbuilder/scripts/build/checkSystemPrereq.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+    name="checkSystemPrereq"
+    default="checkSystemPrereq"
+    basedir=".">
+
+    <fail
+        unless="commandName"
+        message="Must provide the commandName to run"/>
+    <fail
+        unless="arguments"
+        message="Must provide the command arguments to run"/>
+
+    <target name="checkSystemPrereq">
+
+        <exec
+            executable="${commandName}"
+            resultproperty="returnCode"
+            errorproperty="errorCode"
+            outputproperty="output"
+        	failifexecutionfails="false" 
+            failonerror="false">
+            <arg line="${arguments}"/>
+        </exec>
+
+        <fail unless="returnCode" message="**** Build failled: cannot execute ${commandName} ****"/>
+    </target>
+</project>
\ No newline at end of file