From: Trevor Woerner <[email protected]> Place into one location the logic to decide what to do with regards to the following build modes: LISTONLY, RESUME, NOQUIT, and BUILD_ONE.
Signed-off-by: Trevor Woerner <[email protected]> --- build.sh | 163 ++++++++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 116 insertions(+), 47 deletions(-) diff --git a/build.sh b/build.sh index 3a57561..2bfcebb 100755 --- a/build.sh +++ b/build.sh @@ -66,12 +66,8 @@ nonexistent_components="" clonefailed_components="" failed() { - if [ X"${NOQUIT}" != X ]; then - echo "***** $1 failed on $2/$3" - failed_components="$failed_components $2/$3" - else - exit 1 - fi + echo "***** $1 failed on $2/$3" + failed_components="$failed_components $2/$3" } # print a pretty title to separate the processing of each module @@ -147,12 +143,18 @@ checkfortars() { if [ X"$jj" = X"gz" ]; then TAROPTS=xzf fi - tar $TAROPTS $TARFILE -C $ii || failed tar $1 $2 + tar $TAROPTS $TARFILE -C $ii + if [ $? -ne 0 ]; then + failed tar $1 $2 + return 1 + fi fi - return + return 0 fi done done + + return 0 } clone() { @@ -190,21 +192,8 @@ clone() { return 0 } -build() { - if [ X"$LISTONLY" != X ]; then - echo "$1/$2" - return 0 - fi - - if [ X"$RESUME" != X ]; then - if [ X"$RESUME" = X"$1/$2" ]; then - unset RESUME - # Resume build at this module - else - echo "Skipping $1 module component $2..." - return 0 - fi - fi +process() { + local rtn module_title $1 $2 @@ -218,10 +207,7 @@ build() { if [ $? -ne 0 ]; then echo "Failed to clone $1 module component $2. Ignoring." clonefailed_components="$clonefailed_components $1/$2" - if [ X"$BUILD_ONE" != X ]; then - exit 1 - fi - return + return 1 fi SRCDIR="$1/$2" CONFCMD="autogen.sh" @@ -233,7 +219,7 @@ build() { if [ X"$SRCDIR" = X ]; then echo "$1 module component $2 does not exist, skipping." nonexistent_components="$nonexistent_components $1/$2" - return + return 0 fi if [ X"$BUILT_MODULES_FILE" != X ]; then @@ -241,38 +227,56 @@ build() { fi old_pwd=`pwd` - cd $SRCDIR || failed cd1 $1 $2 + cd $SRCDIR + if [ $? -ne 0 ]; then + failed cd1 $1 $2 + return 1 + fi if [ X"$GITCMD" != X ]; then $GITCMD - if [ $? -ne 0 ]; then - failed "$GITCMD $1 $2" - fi + rtn=$? cd $old_pwd - if [ X"$BUILD_ONE" != X ]; then - echo "Single-component git command complete" - exit 0 + if [ $rtn -ne 0 ]; then + failed "$GITCMD" $1 $2 + return 1 fi return 0 fi if [ X"$PULL" != X ]; then - git pull --rebase || failed "git pull" $1 $2 + git pull --rebase + if [ $? -ne 0 ]; then + failed "git pull" $1 $2 + cd $old_pwd + return 1 + fi fi # Build outside source directory if [ X"$DIR_ARCH" != X ] ; then - mkdir -p "$DIR_ARCH" || failed mkdir $1 $2 - if cd "$DIR_ARCH" ; then :; else + mkdir -p "$DIR_ARCH" + if [ $? -ne 0 ]; then + failed mkdir $1 $2 + cd $old_pwd + return 1 + fi + cd "$DIR_ARCH" + if [ $? -ne 0 ]; then failed cd2 $1 $2 cd ${old_pwd} - return + return 1 fi fi if [ X"$MAKECMD" != X ]; then - $MAKECMD || failed "$MAKECMD" $1 $2 + $MAKECMD + if [ $? -ne 0 ]; then + failed "$MAKECMD" $1 $2 + cd $old_pwd + return 1 + fi else # Special configure flags for certain modules MOD_SPECIFIC= @@ -290,27 +294,92 @@ build() { if [ X"$NOAUTOGEN" = X ]; then sh ${DIR_CONFIG}/${CONFCMD} --prefix=${PREFIX} ${LIB_FLAGS} \ ${MOD_SPECIFIC} ${QUIET:+--quiet} \ - ${CACHE:+--cache-file=}${CACHE} ${CONFFLAGS} "$CONFCFLAGS" || \ + ${CACHE:+--cache-file=}${CACHE} ${CONFFLAGS} "$CONFCFLAGS" + if [ $? -ne 0 ]; then failed ${CONFCMD} $1 $2 + cd $old_pwd + return 1 + fi fi - ${MAKE} $MAKEFLAGS || failed make $1 $2 + + ${MAKE} $MAKEFLAGS + if [ $? -ne 0 ]; then + failed make $1 $2 + cd $old_pwd + return 1 + fi + if [ X"$CHECK" != X ]; then - ${MAKE} $MAKEFLAGS check || failed check $1 $2 + ${MAKE} $MAKEFLAGS check + if [ $? -ne 0 ]; then + failed check $1 $2 + cd $old_pwd + return 1 + fi fi + if [ X"$CLEAN" != X ]; then - ${MAKE} $MAKEFLAGS clean || failed clean $1 $2 + ${MAKE} $MAKEFLAGS clean + if [ $? -ne 0 ]; then + failed clean $1 $2 + cd $old_pwd + return 1 + fi fi + if [ X"$DIST" != X ]; then - ${MAKE} $MAKEFLAGS dist || failed dist $1 $2 + ${MAKE} $MAKEFLAGS dist + if [ $? -ne 0 ]; then + failed dist $1 $2 + cd $old_pwd + return 1 + fi fi + if [ X"$DISTCHECK" != X ]; then - ${MAKE} $MAKEFLAGS distcheck || failed distcheck $1 $2 + ${MAKE} $MAKEFLAGS distcheck + if [ $? -ne 0 ]; then + failed distcheck $1 $2 + cd $old_pwd + return 1 + fi fi - $SUDO env LD_LIBRARY_PATH=$LD_LIBRARY_PATH ${MAKE} $MAKEFLAGS install || \ + + $SUDO env LD_LIBRARY_PATH=$LD_LIBRARY_PATH ${MAKE} $MAKEFLAGS install + if [ $? -ne 0 ]; then failed install $1 $2 + cd $old_pwd + return 1 + fi fi cd ${old_pwd} + return 0 +} + +build() { + if [ X"$LISTONLY" != X ]; then + echo "$1/$2" + return 0 + fi + + if [ X"$RESUME" != X ]; then + if [ X"$RESUME" = X"$1/$2" ]; then + unset RESUME + # Resume build at this module + else + echo "Skipping $1 module component $2..." + return 0 + fi + fi + + process $1 $2 + if [ $? -ne 0 ]; then + echo "error processing module/component: \"$1/$2\"" + if [ X"$NOQUIT" = X ]; then + exit 1 + fi + fi if [ X"$BUILD_ONE" != X ]; then echo "Single-component build complete" -- 1.7.3.1.45.g9855b _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
