[PATCH modular 11/13] build.sh: regroup script main line together

Gaetan Nadon memsize at videotron.ca
Wed Dec 29 07:44:46 PST 2010


Some lines are interspersed with functions which makes it harder
to understand the script main line code.

Add some comments along the line.
No functional changes.

Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
---
 build.sh |   93 ++++++++++++++++++++++++++++++++++---------------------------
 1 files changed, 52 insertions(+), 41 deletions(-)

diff --git a/build.sh b/build.sh
index 2095d20..1111e50 100755
--- a/build.sh
+++ b/build.sh
@@ -96,10 +96,6 @@ setup_buildenv() {
     $SUDO mkdir -p ${DESTDIR}${LOCALSTATEDIR}/log
 }
 
-failed_components=""
-nonexistent_components=""
-clonefailed_components=""
-
 # explain where a failure occurred
 # if you find this message in the build output it can help tell you where the failure occurred
 # arguments:
@@ -1002,10 +998,58 @@ check_full_path () {
     fi
 }
 
+# perform sanity checks on cmdline args which require arguments
+# arguments:
+#   $1 - the option being examined
+#   $2 - the argument to the option
+# returns:
+#   if it returns, everything is good
+#   otherwise it exit's
+required_arg() {
+    # preconds
+    if [ X"$1" = X ]; then
+	echo "internal required_arg() error, missing \$1 argument"
+	exit 1
+    fi
+
+    # check for an argument
+    if [ X"$2" = X ]; then
+	echo "the '$1' option is missing its required argument"
+	echo ""
+	usage
+	exit 1
+    fi
+
+    # does the argument look like an option?
+    echo $2 | grep "^-" > /dev/null
+    if [ $? -eq 0 ]; then
+	echo "the argument '$2' of option '$1' looks like an option itself"
+	echo ""
+	usage
+	exit 1
+    fi
+}
+
+#------------------------------------------------------------------------------
+#			Script main line
+#------------------------------------------------------------------------------
+
+# Initialize variables controlling end of run reports
+failed_components=""
+nonexistent_components=""
+clonefailed_components=""
+
+# Set variables supporting multiple binaries for a single source tree
 HAVE_ARCH="`uname -i`"
 DIR_ARCH=""
 DIR_CONFIG="."
 
+# Set variables for conditionally building some components
+HOST_OS=`uname -s`
+export HOST_OS
+HOST_CPU=`uname -m`
+export HOST_CPU
+
 # States if the user has exported EPREFIX
 if [ X"$EPREFIX" != X ]; then
     EPREFIX_SET=yes
@@ -1036,38 +1080,6 @@ if [ X"$LOCALSTATEDIR" != X ]; then
     LOCALSTATEDIR_SET=yes
 fi
 
-# perform sanity checks on cmdline args which require arguments
-# arguments:
-#   $1 - the option being examined
-#   $2 - the argument to the option
-# returns:
-#   if it returns, everything is good
-#   otherwise it exit's
-required_arg() {
-    # preconds
-    if [ X"$1" = X ]; then
-	echo "internal required_arg() error, missing \$1 argument"
-	exit 1
-    fi
-
-    # check for an argument
-    if [ X"$2" = X ]; then
-	echo "the '$1' option is missing its required argument"
-	echo ""
-	usage
-	exit 1
-    fi
-
-    # does the argument look like an option?
-    echo $2 | grep "^-" > /dev/null
-    if [ $? -eq 0 ]; then
-	echo "the argument '$2' of option '$1' looks like an option itself"
-	echo ""
-	usage
-	exit 1
-    fi
-}
-
 # Process command line args
 while [ $# != 0 ]
 do
@@ -1193,6 +1205,7 @@ do
     shift
 done
 
+# The PREFIX variable is mandatory
 if [ X"${PREFIX}" = X ] && [ X"$LISTONLY" = X ]; then
     echo "required argument 'prefix' appears to be missing"
     echo ""
@@ -1230,11 +1243,7 @@ if [ X"$LIBDIR_SET" = X ]; then
     LOCALSTATEDIR=$PREFIX/var
 fi
 
-HOST_OS=`uname -s`
-export HOST_OS
-HOST_CPU=`uname -m`
-export HOST_CPU
-
+# All user input has been obtained, set-up the user shell variables
 if [ X"$LISTONLY" = X ]; then
     setup_buildenv
     echo "Building to run $HOST_OS / $HOST_CPU ($HOST)"
@@ -1268,8 +1277,10 @@ if [ X"$LISTONLY" != X ]; then
     exit 0
 fi
 
+# Print the end date/time to compare with the start data/time
 date
 
+# Report about components that failed for one reason or another
 if [ X"$nonexistent_components" != X ]; then
     echo ""
     echo "***** Skipped components (not available) *****"
-- 
1.6.0.4



More information about the xorg-devel mailing list