[PATCH build 05/10] Properly handle keep-going and one-shot semantics.

Trevor Woerner twoerner at gmail.com
Sat Sep 18 13:11:42 PDT 2010


From: Trevor Woerner <twoerner at gmail.com>

Update code to make sure it stops on an error or continues to
process as expeted.

Signed-off-by: Trevor Woerner <twoerner at gmail.com>
---
 build.sh |   90 +++++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 66 insertions(+), 24 deletions(-)

diff --git a/build.sh b/build.sh
index d7ea75e..82ca01e 100755
--- a/build.sh
+++ b/build.sh
@@ -213,23 +213,21 @@ clone() {
     return 0
 }
 
-build() {
-    if [ -n "$LISTONLY" ]; then
-	echo "$1/$2"
-	return 0
-    fi
-
-    if [ -n "$RESUME" ]; then
-	if [ "$RESUME" = "$1/$2" ]; then
-	    unset RESUME
-	    # Resume build at this module
-	else
-	    echo "Skipping $1 module component $2..."
-	    return 0
-	fi
+# perform the steps to process one module
+# arguments:
+#   $1 - required
+#   $2 - optional
+# returns:
+#   0 - good
+#   1 - bad
+process() {
+    # preconds
+    if [ -z "$1" ]; then
+	errout "internal error! required argument \$1 not provided"
+	return 1
     fi
 
-    module_title "$1/$2"
+    echo "Processing module \"$1/$2\""
 
     SRCDIR=""
     CONFCMD=""
@@ -241,10 +239,7 @@ build() {
         if [ $? -ne 0 ]; then
             errout "Failed to clone $1 module component $2. Ignoring."
             clonefailed_components+="$1/$2 "
-            if [ -n "$BUILD_ONE" ]; then
-                exit 1
-            fi
-            return
+            return 1
         fi
         SRCDIR="$1/$2"
         CONFCMD="autogen.sh"
@@ -256,11 +251,9 @@ build() {
     if [ -z "$SRCDIR" ]; then
         errout "$1 module component $2 does not exist, skipping."
         nonexistent_components+="$1/$2 "
-        return
+        return 1
     fi
 
-    echo "Building $1 module component $2..."
-
     if [ -n "$BUILT_MODULES_FILE" ]; then
         echo "$1/$2" >> $BUILT_MODULES_FILE
     fi
@@ -278,7 +271,7 @@ build() {
 	if cd "$DIR_ARCH" ; then :; else
 	    failed cd2 $1 $2
 	    cd ${old_pwd}
-	    return
+	    return 1
 	fi
     fi
 
@@ -319,8 +312,57 @@ build() {
 
     cd ${old_pwd}
 
+    return 0
+}
+
+# process all modules to retain the semantics of
+# list-only, keep-going, and one-shot
+# the arguments specify the module to process
+# arguments:
+#   $1 - required
+#   $2 - optional
+# returns:
+#   (not significant)
+build() {
+    local _rtn
+
+    # preconds
+    if [ -z "$1" ]; then
+	errout "internal error! missing required argument \$1"
+	return
+    fi
+
+    # just print list of modules to process
+    if [ -n "$LISTONLY" ]; then
+	echo "$1/$2"
+	return
+    fi
+
+    # if we're resuming a previously stopped build
+    # skip all modules up to the one from which to resume processing
+    if [ -n "$RESUME" ]; then
+	if [ "$RESUME" = "$1/$2" ]; then
+	    unset RESUME
+	    # Resume build at this module
+	else
+	    echo "Skipping $1 module component $2..."
+	    return
+	fi
+    fi
+
+    module_title "$1/$2"
+
+    process $1 $2
+    _rtn=$?
+    if [ $_rtn -ne 0 ]; then
+	errout "error processing module \"$1/$2\""
+	if [ -z "$KEEPGOING" ]; then
+	    exit 1
+	fi
+    fi
+
     if [ -n "$BUILD_ONE" ]; then
-	echo "Single-component build complete"
+	echo "Single component processing complete"
 	exit 0
     fi
 }
-- 
1.7.3.rc2



More information about the xorg-devel mailing list