From: wanchao.xu Date: Wed, 4 Dec 2024 08:39:53 +0000 (+0800) Subject: Add '--max-retry-times' to support rebuild if build failed. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=57ec958d72b91c016de545091d84c7df7b272fc9;p=tools%2Fbuild.git Add '--max-retry-times' to support rebuild if build failed. * If build failed because of qemu crash, support to retry rebuild. Change-Id: I9591e659a464d4c599b1fc29c36cfde9de4219b5 Signed-off-by: wanchao.xu --- diff --git a/build b/build index ec07d23..ca14b79 100644 --- a/build +++ b/build @@ -103,6 +103,7 @@ USEHIGHERDEPS= PKG_CCACHE= CCACHE_SETUP_START_TIME= NOCUMULATE= +MAX_RETRY_TIMES=0 # This is for insserv export YAST_IS_RUNNING=instsys @@ -357,6 +358,8 @@ Known Parameters: Enable creation of a debuginfo package --nocumulate Enable build without cumulative build. + --max-retry-times N + Retry N times to rebuild if build failed. Remember to have fun! @@ -744,6 +747,21 @@ hide_passwords() # echo ${repos[@]} } +retry_build_or_not() +{ + if test -n "$LOGFILE"; then + build_log="$LOGFILE" + else + build_log="$BUILD_ROOT/.build.log"; + fi + if test -f "$build_log"; then + if grep -q "qemu: uncaught target signal" $build_log; then + return 0 + fi + fi + return 1 +} + #### main #### trap fail_exit EXIT @@ -1004,6 +1022,11 @@ while test -n "$1"; do -use-higher-deps) USEHIGHERDEPS="--use-higher-deps" ;; + -max-retry-times) + needarg + MAX_RETRY_TIMES="$ARG" + shift + ;; -*) if vm_parse_options "$@" ; then set -- "${nextargs[@]}" @@ -1470,6 +1493,17 @@ for RECIPEFILE in "${RECIPEFILES[@]}" ; do start_time=`date +%s` recipe_build + if test "$BUILD_SUCCEEDED" = false -a "$MAX_RETRY_TIMES" -gt 0; then + for ((num=0; num<$MAX_RETRY_TIMES; num++)) ; do + if retry_build_or_not ; then + echo ----- retrying to build $RECIPEFILE + recipe_build + else + break + fi + test "$BUILD_SUCCEEDED" = true && break + done + fi if test "$DO_STATISTICS" = 1; then mkdir -p $TOPDIR/OTHER echo "TIME_main_build: $(( `date +%s` - $start_time ))" >> $TOPDIR/OTHER/_statistics