[PATCH build 10/10] Perform arbitrary git and make commands.

Trevor Woerner twoerner at gmail.com
Sat Sep 18 13:12:40 PDT 2010


From: Trevor Woerner <twoerner at gmail.com>

The script can now accept and perform an arbitrary git or make command over
all the modules to build. If no such command is provided "make" followed by
"make install" is assumed.

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

diff --git a/build.sh b/build.sh
index 5a0501b..f199b8b 100755
--- a/build.sh
+++ b/build.sh
@@ -248,6 +248,7 @@ clone() {
 #   1 - bad
 process() {
     local _need_config=0
+    local _rtn
 
     # preconds
     if [ -z "$1" ]; then
@@ -297,13 +298,17 @@ process() {
 	return 1
     fi
 
-    if [ -n "$PULL" ]; then
-	git pull --rebase
-	if [ $? -ne 0 ]; then
-	    failed "git pull" $1 $2
-	    cd $old_pwd
+    # perform git command
+    if [ -n "$GITCMD" ]; then
+	echo "performing git command: '$GITCMD'"
+	$GITCMD
+	_rtn=$?
+	cd $old_pwd
+	if [ $_rtn -ne 0 ]; then
+	    failed "$GITCMD" $1 $2
 	    return 1
 	fi
+	return 0
     fi
 
     # Build outside source directory
@@ -345,62 +350,32 @@ process() {
 	fi
     fi
 
-    # make
-    ${MAKE} $MAKEFLAGS
-    if [ $? -ne 0 ]; then
-	failed "$MAKE $MAKEFLAGS" $1 $2
-	cd $old_pwd
-	return 1
-    fi
-
-    # make check
-    if [ -n "$CHECK" ]; then
-        ${MAKE} $MAKEFLAGS check
+    if [ -n "$MAKECMD" ]; then
+	echo "performing make command: '$MAKECMD $MAKEFLAGS'"
+	$MAKECMD $MAKEFLAGS
 	if [ $? -ne 0 ]; then
-	    failed "$MAKE $MAKEFLAGS check" $1 $2
+	    failed "$MAKECMD $MAKEFLAGS" $1 $2
 	    cd $old_pwd
 	    return 1
 	fi
-    fi
-
-    # make clean
-    if [ -n "$CLEAN" ]; then
-	${MAKE} $MAKEFLAGS clean
-	if [ $? -ne 0 ]; then
-	    failed "$MAKE $MAKEFLAGS clean" $1 $2
-	    cd $old_pwd
-	    return 1
-	fi
-    fi
-
-    # make dist
-    if [ -n "$DIST" ]; then
-	${MAKE} $MAKEFLAGS dist
+    else
+	# make
+	${MAKE} $MAKEFLAGS
 	if [ $? -ne 0 ]; then
-	    failed "$MAKE $MAKEFLAGS dist" $1 $2
+	    failed "$MAKE $MAKEFLAGS" $1 $2
 	    cd $old_pwd
 	    return 1
 	fi
-    fi
 
-    # make distcheck
-    if [ -n "$DISTCHECK" ]; then
-	${MAKE} $MAKEFLAGS distcheck
+	# make install
+	$SUDO env LD_LIBRARY_PATH=$LD_LIBRARY_PATH ${MAKE} $MAKEFLAGS install
 	if [ $? -ne 0 ]; then
-	    failed "$MAKE $MAKEFLAGS distcheck" $1 $2
+	    failed "$SUDO env LD_LIBRARY_PATH=$LD_LIBRARY_PATH ${MAKE} $MAKEFLAGS install" $1 $2
 	    cd $old_pwd
 	    return 1
 	fi
     fi
 
-    # make install
-    $SUDO env LD_LIBRARY_PATH=$LD_LIBRARY_PATH ${MAKE} $MAKEFLAGS install
-    if [ $? -ne 0 ]; then
-	failed "$SUDO env LD_LIBRARY_PATH=$LD_LIBRARY_PATH ${MAKE} $MAKEFLAGS install" $1 $2
-	cd $old_pwd
-	return 1
-    fi
-
     cd ${old_pwd}
     return 0
 }
@@ -894,9 +869,6 @@ usage() {
     echo "  where options are:"
     echo "  -a : do NOT run auto config tools (autogen.sh, configure)"
     echo "  -b : use .build.$HAVE_ARCH build directory"
-    echo "  -c : run make clean in addition to others"
-    echo "  -d : run make distcheck in addition to others"
-    echo "  -D : run make dist in addition to others"
     echo "  -f file: append module being built to file. The last line of this"
     echo "           file can be used for resuming with -r."
     echo "  -g : build with debug information"
@@ -904,12 +876,12 @@ usage() {
     echo "  -k | --keep-going : do not stop after an error"
     echo "  -l : build libraries only (i.e. no drivers, no docs, etc.)"
     echo "  -o module/component : build just this component"
-    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 "  --autoresume file : autoresume from file"
-    echo "  --check : run make check in addition to others"
     echo "  --reconfigure : run configure scripts again"
+    echo "  --cmd cmd : specify a git or make command to run"
+    echo "              by default \"make\" and \"make install\" will be performed"
     echo ""
     echo "Usage: $0 -L"
     echo "  -L : just list modules to build"
@@ -923,7 +895,7 @@ DIR_CONFIG="."
 LIB_ONLY=0
 
 # Process command line args
-CMDLINE=`getopt -o bcdDf:ghklo:pr:s:L --long check,help,autoresume:,keep-going,reconfigure -n $0 -- "$@"`
+CMDLINE=`getopt -o bf:ghklo:r:s:L --long cmd:,help,autoresume:,keep-going,reconfigure -n $0 -- "$@"`
 if [ $? != 0 ]; then
     errout "getopt(1) invocation error"
     exit 1
@@ -935,18 +907,6 @@ while [ 1 ]; do
 	DIR_ARCH=".build.$HAVE_ARCH"
 	DIR_CONFIG=".."
 	;;
-    -c)
-	CLEAN=1
-	;;
-    --check)
-	CHECK=1
-	;;
-    -d)
-	DISTCHECK=1
-	;;
-    -D)
-	DIST=1
-	;;
     -f)
         shift
         BUILT_MODULES_FILE=$1
@@ -971,9 +931,6 @@ while [ 1 ]; do
 	RESUME=$1
 	BUILD_ONE=1
 	;;
-    -p)
-	PULL=1
-	;;
     -r)
 	shift
 	RESUME=$1
@@ -993,6 +950,24 @@ while [ 1 ]; do
     --reconfigure)
 	RECONFIG=1
 	;;
+    --cmd)
+	shift
+	_first=`echo $1 | cut -d' ' -f1`
+	if [ "$_first" = "git" ]; then
+	    _second=`echo $1 | cut -d' ' -f2`
+	    if [ "$_second" = "clone" ]; then
+		echo "git cloning happens automatically, ignoring --cmd"
+	    else
+		GITCMD=$1
+	    fi
+	elif [ "$_first" = "make" ]; then
+	    MAKECMD=$1
+	else
+	    errout "script can only handle \"git\" and \"make\" commands"
+	    errout "don't know how to handle \"$_first\" commands"
+	    exit 1
+	fi
+	;;
     --)
 	shift
 	break
-- 
1.7.3.rc2



More information about the xorg-devel mailing list