[PATCH modular] build.sh: add support for git submodules

Gaetan Nadon memsize at videotron.ca
Tue Mar 8 06:35:25 PST 2011


Currently xcb/util is the first package to use a git submodule.
When cloning, the script will init and update the submodule.
Older versions of git do not have --recursive option for git clone.

When using -p (pull rebase), the script will update the submodule.

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

diff --git a/build.sh b/build.sh
index 0a20a4d..b2d124b 100755
--- a/build.sh
+++ b/build.sh
@@ -309,6 +309,27 @@ clone() {
             clonefailed_components="$clonefailed_components $module/$component"
             return 1
         fi
+	old_pwd=`pwd`
+	cd $DIR
+	if [ $? -ne 0 ]; then
+            echo "Failed to cd to $module module component $component. Ignoring."
+            clonefailed_components="$clonefailed_components $module/$component"
+            return 1
+	return 1
+	fi
+	git submodule init
+        if [ $? -ne 0 ]; then
+            echo "Failed to initialize $module module component $component submodule. Ignoring."
+            clonefailed_components="$clonefailed_components $module/$component"
+            return 1
+        fi
+	git submodule update
+        if [ $? -ne 0 ]; then
+            echo "Failed to update $module module component $component submodule. Ignoring."
+            clonefailed_components="$clonefailed_components $module/$component"
+            return 1
+        fi
+	cd ${old_pwd}
     else
         echo "git cannot clone into an existing directory $module/$component"
 	return 1
@@ -390,6 +411,12 @@ process() {
 	    cd $old_pwd
 	    return 1
 	fi
+	# The parent module knows which commit the submodule should be at
+	git submodule update
+        if [ $? -ne 0 ]; then
+	    failed "git submodule update" $module $component
+            return 1
+        fi
     fi
 
     # Build outside source directory
-- 
1.6.0.4



More information about the xorg-devel mailing list