[PATCH build] Perform arbitrary git or make commands.

Trevor Woerner twoerner at gmail.com
Tue Sep 21 19:52:16 PDT 2010


From: Trevor Woerner <twoerner at gmail.com>

The build.sh script can now accept any arbitrary git or make commands from
the user via the "--cmd" command-line argument. If no such argument is
provided "make" followed by "make install" is assumed.

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

diff --git a/build.sh b/build.sh
index d4f250a..07a46a1 100755
--- a/build.sh
+++ b/build.sh
@@ -218,7 +218,7 @@ build() {
         return
     fi
 
-    echo "Building $1 module component $2..."
+    echo "Processing module/component \"$1/$2\""
 
     if [ X"$BUILT_MODULES_FILE" != X ]; then
         echo "$1/$2" >> $BUILT_MODULES_FILE
@@ -227,8 +227,18 @@ build() {
     old_pwd=`pwd`
     cd $SRCDIR || failed cd1 $1 $2
 
-    if [ X"$PULL" != X ]; then
-	git pull --rebase || failed "git pull" $1 $2
+    if [ X"$GITCMD" != X ]; then
+	$GITCMD
+	if [ $? -ne 0 ]; then
+	    failed "$GITCMD" $1 $2
+	fi
+	cd $old_pwd
+
+	if [ X"$BUILD_ONE" != X ]; then
+	    echo "Single-component git command complete"
+	    exit 0
+	fi
+	return 0
     fi
 
     # Build outside source directory
@@ -260,21 +270,13 @@ build() {
 	    ${CACHE:+--cache-file=}${CACHE} ${CONFFLAGS} "$CONFCFLAGS" || \
 	    failed ${CONFCMD} $1 $2
     fi
-    ${MAKE} $MAKEFLAGS || failed make $1 $2
-    if [ X"$CHECK" != X ]; then
-        ${MAKE} $MAKEFLAGS check || failed check $1 $2
-    fi
-    if [ X"$CLEAN" != X ]; then
-	${MAKE} $MAKEFLAGS clean || failed clean $1 $2
-    fi
-    if [ X"$DIST" != X ]; then
-	${MAKE} $MAKEFLAGS dist || failed dist $1 $2
-    fi
-    if [ X"$DISTCHECK" != X ]; then
-	${MAKE} $MAKEFLAGS distcheck || failed distcheck $1 $2
+    if [ X"$MAKECMD" = X ]; then
+	${MAKE} $MAKEFLAGS || failed make $1 $2
+	$SUDO env LD_LIBRARY_PATH=$LD_LIBRARY_PATH ${MAKE} $MAKEFLAGS install || \
+	    failed install $1 $2
+    else
+	$MAKECMD || failed "$MAKECMD" $1 $2
     fi
-    $SUDO env LD_LIBRARY_PATH=$LD_LIBRARY_PATH ${MAKE} $MAKEFLAGS install || \
-	failed install $1 $2
 
     cd ${old_pwd}
 
@@ -721,9 +723,8 @@ 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 "  --cmd <cmd> : run an arbitrary 'git' or 'make' command"
+    echo "                (default: \"make; make install\")"
     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"
@@ -731,12 +732,10 @@ usage() {
     echo "  -l : build libraries only (i.e. no drivers, no docs, etc.)"
     echo "  -n : do not quit after error; just print error message"
     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 "  --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 ""
     echo "Usage: $0 -L"
     echo "  -L : just list modules to build"
@@ -750,7 +749,7 @@ DIR_CONFIG="."
 LIB_ONLY=0
 
 # Process command line args
-CMDLINE=`getopt -o abcdDf:ghlno:pr:s:L --long check,clone,help,autoresume: -n $0 -- "$@"`
+CMDLINE=`getopt -o abf:ghlno:r:s:L --long clone,help,autoresume:,cmd: -n $0 -- "$@"`
 if [ $? != 0 ]; then
     echo "getopt(1) invocation error"
     exit 1
@@ -765,20 +764,31 @@ while [ 1 ]; do
 	DIR_ARCH=".build.$HAVE_ARCH"
 	DIR_CONFIG=".."
 	;;
-    -c)
-	CLEAN=1
-	;;
-    --check)
-	CHECK=1
-	;;
     --clone)
 	CLONE=1
 	;;
-    -d)
-	DISTCHECK=1
-	;;
-    -D)
-	DIST=1
+    --cmd)
+	shift
+	cmd1=`echo $1 | cut -d' ' -f1`
+	cmd2=`echo $1 | cut -d' ' -f2`
+	if [ X"$cmd1" = X"git" ]; then
+	    if [ X"$cmd2" = X"clone" ]; then
+		echo "The \"git clone\" command is handled with the --clone cmdline arg"
+		echo ""
+		usage
+		exit 1
+	    else
+		GITCMD=$1
+	    fi
+	elif [ X"$cmd1" = X"make" ]; then
+	    MAKECMD=$1
+	else
+	    echo "The script can only process 'make' or 'git' commands"
+	    echo "It can't process '$cmd1' commands"
+	    echo ""
+	    usage
+	    exit 1
+	fi
 	;;
     -f)
         shift
@@ -804,9 +814,6 @@ while [ 1 ]; do
 	RESUME=$1
 	BUILD_ONE=1
 	;;
-    -p)
-	PULL=1
-	;;
     -r)
 	shift
 	RESUME=$1
-- 
1.7.3.rc2



More information about the xorg-devel mailing list