[PATCH build 06/10] Automatic clone.

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


From: Trevor Woerner <twoerner at gmail.com>

If a module to be processed doesn't exist, assume it still needs to be cloned.

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

diff --git a/build.sh b/build.sh
index 82ca01e..f0d84fa 100755
--- a/build.sh
+++ b/build.sh
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+_DEFAULT_GITROOT="git://anongit.freedesktop.org/git"
+
 envoptions() {
 cat << EOF
 global environment variables you may set:
@@ -12,8 +14,8 @@ global environment variables you may set to replace default functionality:
   MAKE:     program to use instead of 'make' (default: make)
   FONTPATH: font path to use (defaults under: \$PREFIX/\$LIBDIR...)
   LIBDIR:   path under \$PREFIX for libraries (e.g., lib64) (default: lib)
-  GITROOT:  path to freedesktop.org git root, only needed for --clone
-            (default: git://anongit.freedesktop.org/git)
+  GITROOT:  path to freedesktop.org git root
+            (default: $_DEFAULT_GITROOT)
 
 global environment variables you may set to augment functionality:
   CONFFLAGS:  additional flags to pass to all configure scripts
@@ -178,7 +180,24 @@ checkfortars() {
     done
 }
 
+# the git clone command needs special processing in order to correctly
+# map the module name back to the source git repository
+# the arguments specify the module to clone
+# arguments:
+#   $1 - required
+#   $2 - optional
+# returns:
+#   0 - good
+#   1 - bad
 clone() {
+    local _rtn
+
+    # preconds
+    if [ -z "$1" ]; then
+	errout "internal error! required argument \$1 not provided"
+	return 1
+    fi
+
     case $1 in
         "pixman")
         BASEDIR=""
@@ -198,19 +217,21 @@ clone() {
     esac
 
     DIR="$1/$2"
-    GITROOT=${GITROOT:="git://anongit.freedesktop.org/git"}
+    GITROOT=${GITROOT:="$_DEFAULT_GITROOT"}
 
-    if [ ! -d "$DIR" ]; then
-        git clone "$GITROOT/$BASEDIR$DIR" "$DIR"
-        if [ $? -ne 0 ] && [ ! -d "$DIR" ]; then
-            return 1
-        fi
-    else
-        # git cannot clone into an existing directory
+    if [ -d "$DIR" ]; then
+	errout "git can not clone into an existing directory/repository"
 	return 1
     fi
 
-    return 0
+    git clone "$GITROOT/$BASEDIR$DIR" "$DIR"
+    _rtn=$?
+
+    if [ $_rtn -ne 0 ]; then
+	errout "failed to clone module \"$1/$2\""
+	clonefailed_components+="$1/$2"
+    fi
+    return $_rtn
 }
 
 # perform the steps to process one module
@@ -229,20 +250,19 @@ process() {
 
     echo "Processing module \"$1/$2\""
 
+    # do we need to clone?
+    if [ ! -d "$1/$2" ]; then
+	clone $1 $2
+	if [ $? -ne 0 ]; then
+	    return 1
+	fi
+    fi
+
     SRCDIR=""
     CONFCMD=""
     if [ -f $1/$2/autogen.sh ]; then
         SRCDIR="$1/$2"
         CONFCMD="autogen.sh"
-    elif [ -n "$CLONE" ]; then
-        clone $1 $2
-        if [ $? -ne 0 ]; then
-            errout "Failed to clone $1 module component $2. Ignoring."
-            clonefailed_components+="$1/$2 "
-            return 1
-        fi
-        SRCDIR="$1/$2"
-        CONFCMD="autogen.sh"
     else
         checkfortars $1 $2
         CONFCMD="configure"
@@ -817,7 +837,6 @@ usage() {
     echo "  -p : run git pull on each component"
     echo "  -r module/component : resume building with this component"
     echo "  -s sudo-command : sudo command to use"
-    echo "  --clone : clone non-existing repositories (uses \$GITROOT if set)"
     echo "  --autoresume file : autoresume from file"
     echo "  --check : run make check in addition to others"
     echo ""
@@ -833,7 +852,7 @@ DIR_CONFIG="."
 LIB_ONLY=0
 
 # Process command line args
-CMDLINE=`getopt -o abcdDf:ghklo:pr:s:L --long check,clone,help,autoresume:,keep-going -n $0 -- "$@"`
+CMDLINE=`getopt -o abcdDf:ghklo:pr:s:L --long check,help,autoresume:,keep-going -n $0 -- "$@"`
 if [ $? != 0 ]; then
     errout "getopt(1) invocation error"
     exit 1
@@ -854,9 +873,6 @@ while [ 1 ]; do
     --check)
 	CHECK=1
 	;;
-    --clone)
-	CLONE=1
-	;;
     -d)
 	DISTCHECK=1
 	;;
@@ -977,7 +993,7 @@ if [ -n "$failed_components" ]; then
     echo ""
 fi
 
-if [ -n "$CLONE" ] && [ -n "$clonefailed_components" ];  then
+if [ -n "$clonefailed_components" ];  then
     echo ""
     echo "***** Components failed to clone *****"
     for _cmp in `echo $clonefailed_components`; do
-- 
1.7.3.rc2



More information about the xorg-devel mailing list