[Libreoffice-commits] buildbot.git: 3 commits - tb/tb tb/tb_internals.sh tb/tb_phases.sh

Norbert Thiebaud nthiebaud at gmail.com
Sun May 19 18:37:34 PDT 2013


 tb/tb              |  238 ++--------
 tb/tb_internals.sh | 1251 ++++++++++++++++++++---------------------------------
 tb/tb_phases.sh    |   49 +-
 3 files changed, 558 insertions(+), 980 deletions(-)

New commits:
commit dc03764d4da48c2d4e8b47f69c098405998ebe68
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date:   Sun May 19 20:36:30 2013 -0500

    tb: support -z again

diff --git a/tb/tb_internals.sh b/tb/tb_internals.sh
index daf08d1..242df2a 100644
--- a/tb/tb_internals.sh
+++ b/tb/tb_internals.sh
@@ -301,13 +301,13 @@ interupted_build()
     log_msgs "Interrupted by Signal"
     if [ "$TB_MODE" = "gerrit" ] ; then
         if [ -n "${GERRIT_TASK_TICKET}" ] ;then
-            # repport a cancellation if we already acquired the ticket
+            # report a cancellation if we already acquired the ticket
             R=2
             report_gerrit
         fi
     elif [ "$TB_MODE" = "tb" ] ; then
         if [ -n "${tb_LAST_CHECKOUT_DATE?}" ] ; then
-            # repport a cancellation if we already notified a start
+            # report a cancellation if we already notified a start
             report_to_tinderbox "${tb_LAST_CHECKOUT_DATE?}" "fold" "no"
         fi
     fi
@@ -464,7 +464,9 @@ profile_tb_defaults()
     if [ -z "${TB_REMOTE_REFSPEC}" ] ; then
         TB_REMOTE_REFSPEC="origin/${TB_LOCAL_REFSPEC}"
     fi
-
+    if [ -n "${TB_SEND_MAIL}" ] ; then
+        tb_SEND_MAIL="${TB_SEND_MAIL}"
+    fi
 }
 
 push_bibisect()
@@ -860,6 +862,27 @@ run_next_task()
     fi
 }
 
+run_primer()
+{
+    P=
+    R=0
+    for P in ${tb_ACTIVE_PROFILES} ; do
+        (
+        local triggered=0
+        R=0
+        trap 'interupted_build' SIGINT SIGQUIT
+        load_profile "${P?}"
+
+        # we do not want to send any email on 'primer/one-shot' build
+        tb_SEND_MAIL="none"
+        pushd "${TB_GIT_DIR?}" > /dev/null || die "Cannot cd to git repo ${TB_GIT_DIR?} for profile ${P?}"
+        run_tb_task
+        )
+        R=$?
+    done
+
+}
+
 run_tb_task()
 {
     local phase_list
@@ -953,7 +976,7 @@ select_next_gerrit_task()
     GERRIT_TASK_BRANCH=""
     GERRIT_TASK_REF=""
     GERRIT_TASK_FEATURE=""
-    result=$(ssh ${TB_GERRIT_HOST?} buildbot get -p core -a ${tb_GERRIT_PLATFORM?} --format BASH ${TB_GERRIT_BRANCH?} ${tb_GERRIT_TEST})
+    result=$(ssh ${TB_GERRIT_HOST?} buildbot get -p core -a ${TB_GERRIT_PLATFORM?} --format BASH ${TB_GERRIT_BRANCH?} ${tb_GERRIT_TEST})
     [ $V ] && echo "Get task result:${result}"
 
     has_task=$(echo "$result" | grep "^GERRIT_TASK_")
commit a5d537a402dfdd3b598c060ddfc5da40f51545a6
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date:   Wed May 15 03:40:48 2013 -0500

    tb: problem with make interferring with bash traps

diff --git a/tb/tb_phases.sh b/tb/tb_phases.sh
index aeb4181..00b9fd0 100644
--- a/tb/tb_phases.sh
+++ b/tb/tb_phases.sh
@@ -88,7 +88,9 @@ local extra_buildid=""
     fi
     if [ "${R}" = "0" ] ; then
         export EXTRA_BUILDID="$extra_buildid"
-        if ! ${TB_NICE} ${TB_WATCHDOG} ${MAKE?} -sr > "tb_${P?}_build.log" 2>&1 ; then
+        # we for MAKE_RESTARTS=1 because 1/ we know thta Makefile is up to date
+        # and 2/ the 'restart' mechanism in make is messed-up by the fact that we trap SIGINT
+        if ! ${TB_NICE} ${TB_WATCHDOG} ${MAKE?} MAKE_RESTARTS=1  -sr > "tb_${P?}_build.log" 2>&1 ; then
             tb_REPORT_LOG="tb_${P?}_build.log"
             tb_REPORT_MSGS="build failed - error is:"
             [ $V ] && echo "make failed :"
@@ -97,7 +99,7 @@ local extra_buildid=""
         else
             # if we want to populate bibisect we need to 'install'
             if [ "${TB_TYPE?}" = "tb" -a ${TB_BIBISECT} != "0" ] ; then
-                if ! ${TB_NICE} ${TB_WATCHDOG} ${MAKE?} -sr install-tb >>"tb_${P?}_build.log" 2>&1 ; then
+                if ! ${TB_NICE} ${TB_WATCHDOG}  ${MAKE?} MAKE_RESTARTS=1 -sr install-tb >>"tb_${P?}_build.log" 2>&1 ; then
                     tb_REPORT_LOG="tb_${P}_build.log"
                     tb_REPORT_MSGS="build failed - error is:"
                     R=1
@@ -144,7 +146,7 @@ canonical_do_test()
 {
     if [ "${R}" = "0" ] ; then
         if [ "${TB_DO_TESTS}" = "1" ] ; then
-            if ! ${TB_NICE} ${TB_WATCHDOG} ${MAKE?} -sr check > "tb_${P?}_tests.log" 2>&1 ; then
+            if ! ${TB_NICE} ${TB_WATCHDOG}  ${MAKE?} MAKE_RESTARTS=1 -sr check > "tb_${P?}_tests.log" 2>&1 ; then
                 tb_REPORT_LOG="tb_${P?}_tests.log"
                 tb_REPORT_MSGS="check failed - error is:"
                 R=1
commit 8a53478152d3edb190b650db75fd8a248ce20249
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date:   Sat Apr 20 09:49:46 2013 -0500

    tb: major rework to simplify things
    
    We drop the notin of 'branches'
    expand the role of profile... particularely most
    variables are now profiles levels and we can have an
    instance of tb that monitor multiple profiles

diff --git a/tb/tb b/tb/tb
index 84e0d32..fe65762 100755
--- a/tb/tb
+++ b/tb/tb
@@ -56,10 +56,7 @@ The gerrit-tb mode, in which tb does primarily gerrit build unless there is no
 ssuch build to do, in which case it does tb build until a new gerrit build is
 needed.
 
-tb configuration is organized in 'profile' which contains configuration for
-one or more 'branches' to monitor.
-tb can only run one profile at the time, but monitor and can therefore build
-any of the branches configured under that profile.
+tb can only run any number of profile at the time.
 
 The configuration is organized as:
 
@@ -67,60 +64,31 @@ The configuration is organized as:
        /meta/
        /phases.sh
        /profiles/<profile_name>/autogen.lastrun
-       /profiles/<profile_name>/autogen.lastrun_gerrit
-       /profiles/<profile_name>/autogen.lastrun_tb
-       /profiles/<profile_name>/branches/<branch_name>/autogen.lastrun
-       /profiles/<profile_name>/branches/<branch_name>/autogen.lastrun_gerrit
-       /profiles/<profile_name>/branches/<branch_name>/autogen.lastrun_tb
-       /profiles/<profile_name>/branches/<branch_name>/config
-       /profiles/<profile_name>/branches/<branch_name>/config_gerrit
-       /profiles/<profile_name>/branches/<branch_name>/config_tb
-       /profiles/<profile_name>/branches/<branch_name>/false_negatives
        /profiles/<profile_name>/config
        /profiles/<profile_name>/false_negatives
        /profiles/<profile_name>/phases.sh
 
-The configuration is obtained for a given branche by sourcing, in this order,
+The configuration is obtained for a given profile by sourcing, in this order,
 
 ~/tb/config
     /profiles/<profile_name>/config
-    /profiles/<profile_name>/branches/<branch_name>/config
-and
-    /profiles/<profile_name>/branches/<branch_name>/config_tb
-for tb-build, or
-    /profiles/<profile_name>/branches/<branch_name>/config_gerrit
-for gerrit-build.
 
 Each build need a autogen configuration for the building of libreoffice.
-for a branch the autogen configuration to is is the _first_ found of
 
-for tb-build :
-    /profiles/<profile_name>/branches/<branch_name>/autogen.lastrun_tb
-    /profiles/<profile_name>/branches/<branch_name>/autogen.lastrun
-    /profiles/<profile_name>/autogen.lastrun_tb
     /profiles/<profile_name>/autogen.lastrun
 
-for gerrit-build:
-    /profiles/<profile_name>/branches/<branch_name>/autogen.lastrun_gerrit
-    /profiles/<profile_name>/branches/<branch_name>/autogen.lastrun
-    /profiles/<profile_name>/autogen.lastrun_gerrit
-    /profiles/<profile_name>/autogen.lastrun
-
-Note: Contrary to config for tb itself, autogen config do not aggregate.
-The first file found according to the rules above is then the entire
-configuration that will be use as autogen.lastrun for the build.
-
 Some tb configuration parameters can be specified at the global level 'G',
-some at the profile level 'P' and some at the branch level 'B'.
-Unless otherwise specified a parameter can be specificed at any level.
+some at the profile level 'P'
 If a parameter is specified at multiple level then the lowest level prevail.
-In other words: B prevail over P, which prevail over G.
+In other words:  P prevail over G.
 
 The following variables can be specified in tb's configuration files.
 
-CCACHE_DIR=<path> This is to override the normal ccache environment variable.
-                  This allow to have a per profile, or even better, a per branche
-                  cache.
+TB_ACTIVE_PROFILES=<profile_name> [<profile_name> ...]
+                                  List of active profile.
+                                  This is a G level only parameter
+                                  This provide a default value in case -p <profle> is not
+                                  present on the command line, but is required.
 TB_BIBISECT_DIR=<path> Location of a git bibisect repository
                        This is a tb-mode only paramter. This is ingored in gerrit mode
                        This is a tb-mode only paramter. This is ingored in gerrit mode
@@ -135,39 +103,33 @@ TB_BIBISECT_PUSH=[0|1] Indicate if a git push should be issued after each bibise
 TB_BIBISECT=[0|1] Indicate if a bibisect version should be saved.
                   Default is 0.
                   This is a tb-mode only paramter. This is ingored in gerrit mode
-TB_BRANCHES=<nane> [<name>...] Space separated list of branch names configured, to monitor.
-                               This is G or P-level parameter only
-                               Default:"master"
-TB_BRANCH_LOCAL_REFSPEC=<ref> Name of the branche in the local repo
-                              Default to the name of the branch in the configuration
-                              This is a B-level only paramter
-                              This is a tb-mode only paramter. This is ingored in gerrit mode
-TB_BRANCH_MODE=(gerrit|tb|both) Restrict the branch to gerrit build or tb build or both (default)
-                                This is a B-level only parameter
-TB_BRANCH_REMOTE_REFSPEC=<ref> Name of the branch on the remote repo.
-                               Default to the name of the branch in the configuration
-                               This is a B-level only paramter
-                               This is a tb-mode only paramter. This is ingored in gerrit mode
+TB_BRANCH=<nane>  name of the branch that profile monitor, used to query gerrit or to repport to tindbuild
+                  Default:"master"
 TB_BUILD_DIR=<path> Directory to use a a build directory. If specified, it must exist.
                     Default to TB_GIT_DIR.
-TB_CCACHE_SIZE=<size> When CCACHE is specified at a profile or branche level
-                      if TB_CCACHE_SIZE as a value it is used to run
-                      ccache -M <size> to insure that the cache has the appropriate size
-TB_DEFAULT_MODE=[gerrit|gerrit-tb|tb-gerrit|tb] Default mode of operation.
-                                                This is a G or P level parameter
-                                                The command line --mode= override both level.
-                                                Default is "tb".
-TB_DEFAULT_PROFILE=<profile_name> Default profile name.
-                                  This is a G level only parameter
-                                  This provide a default value in case -p <prifle> is not
-                                  present on the command line, but is required.
+TB_LOCAL_REFSPEC=<ref> Name of the branche in the local repo
+                       Default to the name of the branch in the configuration
+                       This is a P-level only paramter
+                       This is a tb-mode only paramter. This is ingored in gerrit mode
+TB_MODE=(fair|fix)  Indicate the scheduling fairness to use
+                    This is a G only parameter
+                    in 'fair' mode active profiles are rotated such that
+                    when a profile get build it goes at the end of the queue
+                    for the next iteration... fix mean that profiles are attempted
+                    in the order they are specified, always.
+TB_REMOTE_REFSPEC=<ref> Name of the branch on the remote repo.
+                        Default to the name of the branch in the configuration
+                        This is a P-level only paramter
+                        This is a tb-mode only paramter. This is ingored in gerrit mode
+TB_TYPE=(gerrit|tb) Indicate if the profile describe a gerrit or tb build
+                    This is a mandatory P-level only parameter
 TB_GERRIT_HOST=<host> Gerrit host to contact in gerrit mode.
                      This parameter is mandatory to use a gerrit mode.
-                     This is G or P-level parameter only
+TB_GERRIT_TEST=(1|0) Indicate that this gerrit profile is for test only.
+                     The get request to the gerrit buildbot plugin will be made
+                     as 'test'. and therefore will not be consumed as real request.
 TB_GIT_DIR=<path> Location of the libreoffice core git repo to use for a build.
                   This parameter is mandatory.
-TB_ID=<integer> Id of the tinderbox. see http://wiki/documentfoundation.org/Development/Tinderbox
-                for information on how to acquire such an ID.
 TB_INCREMENTAL=[0|1] Indicate that one want to do incremental build, iow skip the clean phase
                      This apply only to tb build, as tb build are normally progressive
                      in time, whereas gerrit build can be all over the place...
@@ -200,6 +162,7 @@ TB_OWNER=<email> Email of the owner/operator of the tinderbox
                  This paramter is mandatory.
 TB_POLL_DELAY=<num_of_seconds> Delay in second between two attempt to pool the states of branches.
 TB_POST_BUILD_DELAY=<num_of_seconds> Pause in second after a build.
+                                     G Level parameter
 TB_SMTP_HOST=<smtp_hostname> Hostname of the smtp server to use to send email.
                              This paramter is mandatory in tb mode
 
@@ -225,10 +188,10 @@ TB_TRIGGER_FILE=<absolute_filename> This is the location of a 'trigger' file.
 
 In general, when a command line argument influence on of the paramter listed
 above, it can only override a G-level specification. P-level take, for the most
-part precedence of the command-line, and B-level always take precedence.
+part precedence of the command-line.
 
 The rational is that tb is meant to be a un-attended long running job, Ideally
-taking no argument what-so-ever except -p <profile_name> and possibly --mode=
+taking no argument what-so-ever.
 
 
 Note for tinbuild2 user: tb does _not_ require a primer build. but it will not
@@ -259,9 +222,7 @@ set_factory_default
 
 load_config
 
-if [ "${TB_DEFAULT_PROFILE}" ] ; then
-    P="${TB_DEFAULT_PROFILE}"
-fi
+set_global_defaults
 
 while [ "${1}" != "" ]; do
     parm=${1%%=*}
@@ -274,44 +235,6 @@ while [ "${1}" != "" ]; do
     fi
 
     case "${parm}" in
-        -0)  # avoid calling *_clean functions (incremental build)
-            DO_NOT_CLEAN=1
-            ;;
-        -a)  # email to the branch's author for out-of-tinderbox branch buildbot
-            if [ -z "${has_arg}" ] ; then
-                shift;
-                arg="$1"
-            fi
-            if [ -z "${arg}" ] ; then
-                die "Missing argument for option $parm"
-            else
-                tb_BRANCH_AUTHOR="$arg"
-            fi
-            ;;
-        -b|--branch|--brandhes)  # to list the branches to build
-            if [ -z "${has_arg}" ] ; then
-                shift;
-                arg="$1"
-            fi
-            if [ -z "${arg}" ] ; then
-                echo "Missing argument for option $parm" 1>&2
-                exit -1
-            else
-                tb_BRANCHES="$arg"
-            fi
-            ;;
-        -d)  # wrap make in a watchdog
-            if [ -z "${has_arg}" ] ; then
-                shift;
-                arg="$1"
-            fi
-            if [ -z "${arg}" ] ; then
-                echo "Missing argument for option $parm" 1>&2
-                exit -1
-            else
-                TB_WATCHDOG="makewatchdog $arg -- "
-            fi
-            ;;
         -h|--help)  # display help
             do_help
             exit
@@ -319,55 +242,6 @@ while [ "${1}" != "" ]; do
         -k)  # do not override the local autogen.lastrun if present
             tb_KEEP_AUTOGEN="1"
             ;;
-        -m)  # which email to wend and to whom
-            if [ -z "${has_arg}" ] ; then
-                shift;
-                arg="$1"
-            fi
-            if [ -z "${arg}" ] ; then
-                echo "Missing argument for option $parm" 1>&2
-                exit -1
-            else
-                tb_SEND_MAIL="${arg}"
-            fi
-            ;;
-        --mode)
-            # operating mode of the tinbuild
-            if [ -z "${has_arg}" ] ; then
-                shift;
-                arg="$1"
-            fi
-            if [ -z "${arg}" ] ; then
-                die "Missing argument for option $parm"
-            fi
-            case "$arg" in
-                fair)
-                    tb_MODE="dual"
-                    tb_DUAL_PRIORITY="fair"
-                    ;;
-                gerrit)
-                    tb_MODE="gerrit"
-                    ;;
-                gerrit-tb)
-                    tb_MODE="dual"
-                    tb_DUAL_PRIORITY="gerrit"
-                    ;;
-                prime)
-                    tb_MODE="tb"
-                    tb_ONE_SHOT="1"
-                    ;;
-                tb)
-                    tb_MODE="tb"
-                    ;;
-                tb-gerrit)
-                    tb_MODE="dual"
-                    tb_DUAL_PRIORITY="tb"
-                    ;;
-                *)
-                    die "Unsupported mode of operation : $arg"
-                    ;;
-            esac
-            ;;
         -p)  # profile to use to deterine extra parameter (email mostly) and autogen arguments
             if [ -z "${has_arg}" ] ; then
                 shift;
@@ -376,19 +250,23 @@ while [ "${1}" != "" ]; do
             if [ -z "${arg}" ] ; then
                 die "Missing argument for option $parm"
             else
-                P="${arg}"
+                if [ -z "${tb_ACTIVE_PROFILES}" ] ; then
+                    tb_ACTIVE_PROFILES="${arg}"
+                else
+                    tb_ACTIVE_PROFILES="${tb_ACTIVE_PROFILES?} ${arg}"
+                fi
             fi
             ;;
+        -t )
+            # test mode
+            TB_TEST=1
+            ;;
         -v)  # print more messages
             V=1
             ;;
-        -x|--bibisect)  # Push builds to bibisect repo (per buildbot and major version)
-            TB_BIBISECT=1
-            ;;
         -z)
             # to run an initial build (without sending any email) to establish a 'baseline'
-            # synonym of --mode=prime
-            tb_MODE="tb"
+            # only the first profile is considered
             tb_ONE_SHOT="1"
             ;;
         -*)
@@ -401,29 +279,15 @@ while [ "${1}" != "" ]; do
     shift
 done
 
-
-load_profile "${P}"
-
-setup_profile_defaults
-
-verify_command
+validate_active_profiles
 
 # remove lingering stop semaphore file
 rm -f ~/.tb/stop
 
-case "${tb_MODE?}" in
-    dual)
-        run_loop
-        ;;
-    gerrit)
-        run_loop
-        ;;
-    tb)
-        if [ "${tb_ONE_SHOT}" = "1" ] ; then
-            run_primer
-        else
-            run_loop
-        fi
-        ;;
-esac
+if [ "${tb_ONE_SHOT}" = "1" ] ; then
+    run_primer
+else
+    run_loop
+fi
+
 
diff --git a/tb/tb_internals.sh b/tb/tb_internals.sh
index 7f2b2c4..daf08d1 100644
--- a/tb/tb_internals.sh
+++ b/tb/tb_internals.sh
@@ -15,22 +15,19 @@
 #
 # in general use readable variable name, use _ to separate the part of the variables name
 #
-# Exception: P : project name
-#            B : current branch name. gerrit_* are reserved branch names for gerrit works
+# Exception: P : current project name
 #            R : build result indicator ( 0=OK 1=KO 2=False positive )
 #            V : verbose messages (V=1 => verbose message V= => no verbose message, iow: [ $V ] && log_msgs ....
 #         MAKE : environement variable is use if set to point to a gnu-make
 #                otherwise overriden to a gne-make found in the PATH
 #
-# profile_* reserved for functions specific to .../<profile_name>/phases.sh
-# branches_* reserved for functions specific to .../<branch_name>/phases.sh
 # canonical_* reserverved for phase implementation in tb_phases.sh
 # canonical_[pre|do|post]_<phase> is garanteed to exist, even if it is a no-op function.
 #
 # The rational for these namespace is to allow lower-level overload to still call
 # the implementation at higher level.
 #
-# for instance if a branche phase.sh want derefine the TMPDIR and clean it up
+# for instance if a profile phase.sh want derefine the TMPDIR and clean it up
 # in the pre-clean phase, but still want to do what-ever the tb_phase.sh normally do
 # it can implement
 # pre_clean()
@@ -39,24 +36,9 @@
 #    canonical_pre_clean() to invoke the defautl impelmentation
 # }
 #
-# similarely at the profile level one can override pre-clean in this fashion:
-#
-# profile_pre_clean()
-# {
-#     profile override implementation fo pre-clean()
-# }
-#
-# pre_clean()
-# {
-#     profile_pre_clean()
-# }
-#
-# that way a branch's phase.sh can invoke profile_pre_clean in it's own implemenation of pre_clean()
-#
 # ATTENTION: do not abuse this scheme by having defferent level invoking different phase
-# at higher level... so a branch's pre_clean() for instance shall not invoke canonical_do_clean()
+# at higher level... so a profile's pre_clean() for instance shall not invoke canonical_do_clean()
 # or any other phase than *_pre_clean()
-# Obviously profile level phase.sh shall not invoke any branche_* functions.
 #
 # Configuration files layout
 #
@@ -64,18 +46,6 @@
 #       /meta/
 #       /phases.sh
 #       /profiles/<profile_name>/autogen.lastrun
-#       /profiles/<profile_name>/autogen.lastrun_gerrit
-#       /profiles/<profile_name>/autogen.lastrun_tb
-#       /profiles/<profile_name>/branches/<branch_name>/autogen.lastrun
-#       /profiles/<profile_name>/branches/<branch_name>/autogen.lastrun_gerrit
-#       /profiles/<profile_name>/branches/<branch_name>/autogen.lastrun_tb
-#       /profiles/<profile_name>/branches/<branch_name>/config
-#       /profiles/<profile_name>/branches/<branch_name>/config_gerrit
-#       /profiles/<profile_name>/branches/<branch_name>/config_tb
-#       /profiles/<profile_name>/branches/<branch_name>/false_negatives
-#       /profiles/<profile_name>/branches/<branch_name>/phase.sh
-#       /profiles/<profile_name>/branches/<branch_name>/phase_gerrit.sh
-#       /profiles/<profile_name>/branches/<branch_name>/phase_tb.sh
 #       /profiles/<profile_name>/config
 #       /profiles/<profile_name>/false_negatives
 #       /profiles/<profile_name>/phases.sh
@@ -85,33 +55,7 @@
 
 # XRef :
 #
-# tb_BIN_DIR :
-# tb_BRANCHES :
-# tb_BRANCH_AUTHOR :
-# tb_BUILD_COMMIT :
-# tb_BUILD_TRIGGERED : "1" if the build was controlled by a trigger file
-# tb_BUILD_TYPE :
-# tb_CONFIG_DIR :
-# tb_GERRIT_BRANCHES :
-# tb_GERRIT_PLATFORM :
-# tb_KEEP_AUTOGEN :
-# tb_LOGFILE :
-# tb_MODE :
-# tb_NEXT_PRIORITY :
-# tb_ONE_SHOT :
-# tb_OPT_DIR :
-# tb_PRIORITY :
-# tb_PRODILE_DIR :
-# tb_PROFILE_DIR :
-# tb_PUSH_NIGHTLIES :
-# tb_REPORT_LOG :
-# tb_REPORT_MSGS :
-# tb_SEND_MAIL :
-# tb_TB_BRANCHES :
-# tb_TINDERBOX_BRANCH :
-
-
-B=
+
 P=
 V=
 tb_LOGFILE="/dev/null"
@@ -133,269 +77,13 @@ bibisect_post()
 }
 
 #
-# Check if a branch is suitably configured
-# to be build for tb and/or gerrit
-#
-check_branch_profile()
-{
-    local b="$1"
-    local type=
-    local ret=
-    local rb=
-
-    if [ ! -d "${tb_PROFILE_DIR?}/branches/${b?}" ] ; then
-        log_msgs "No branch specific config for branch '${b?}', using default from profile"
-    fi
-    if [ "${tb_MODE?}" = "dual" -o "${tb_MODE?}" = "tb" ] ; then
-        rb=$(check_branch_profile_tb "$b")
-        ret=$?
-        if [ "$ret" = "0" ] ; then
-            if [ -z "${tb_TB_BRANCHES}" ] ; then
-                tb_TB_BRANCHES="${rb?}"
-            else
-                tb_TB_BRANCHES="${tb_TB_BRANCHES?} ${rb?}"
-            fi
-        fi
-    fi
-    if [ "${tb_MODE?}" = "dual" -o "${tb_MODE?}" = "gerrit" ] ; then
-        rb=$(check_branch_profile_gerrit "${b?}")
-        ret=$?
-        if [ "${ret?}" = "0" ] ; then
-            if [ -z "${tb_GERRIT_BRANCHES}" ] ; then
-                tb_GERRIT_BRANCHES="${rb?}"
-            else
-                tb_GERRIT_BRANCHES="${tb_GERRIT_BRANCHES?} ${rb?}"
-            fi
-        fi
-    fi
-}
-
-#
-# Checks common to both tb and gerrit
-# buildability of a branch profile
-#
-check_branch_profile_common()
-{
-    local b="$1"
-
-    if [ -z "${TB_GIT_DIR}" ] ; then
-        die "Missing TB_GIT_DIR for branch ${b?}"
-    else
-        if [ ! -d "${TB_GIT_DIR?}" ] ; then
-            die "TB_GIT_DIR:${TB_GIT_DIR?} for branch ${b?} is not a directory"
-        fi
-        if [ ! -d "${TB_GIT_DIR?}/.git" ] ; then
-            die "TB_GIT_DIR:${TB_GIT_DIR?} for branch ${b?} is not a git repository"
-        fi
-    fi
-    if [ -n "${TB_BUILD_DIR}" ] ; then
-        if [ ! -d "${TB_BUILD_DIR?}" ] ; then
-            die "TB_BUILD_DIR:${TB_BUILD_DIR?} for branch ${b?} does not exist"
-        fi
-    fi
-}
-
-#
-# Check specific to gerrit builability
-# of a branch profile
-#
-check_branch_profile_gerrit()
-{
-    local b="$1"
-
-    # unset higher level CCACHE_DIR setting
-    unset CCACHE_DIR
-
-    source_branch_level_config "${b?}" "gerrit"
-
-    # if we intented that branch to be tb only let's bail-out early
-    if [ "$TB_BRANCH_MODE" = "tb" ] ; then
-        exit -1;
-    fi
-
-    check_branch_profile_common "${b?}"
-
-    # if CCACHE_DIR is set it has been set by the branch's profile
-    # if TB_CCACHE_SIZE is set make sure the cache is as big as specified
-    # note: no need to restore the old CCACHE value
-    # since check_branches is run in a sub-shell
-    if [ -n "${CCACHE_DIR}" ] ; then
-        if [ -n "${TB_CCACHE_SIZE}" ] ; then
-            ccache -M "${TB_CCACHE_SIZE?}" > /dev/null
-        fi
-    fi
-
-    # if we did not die yet... we are good for this branch: print it
-    echo "${b?}"
-
-}
-
-#
-# Checks psecific to tb buildability
-# of a branch
-#
-check_branch_profile_tb()
-{
-    local b="$1"
-    local sha=
-
-    # unset higher level CCACHE_DIR setting
-    unset CCACHE_DIR
-
-    source_branch_level_config "${b?}" "tb"
-
-    # if we intented that branch to be gerrit only let's bail-out early
-    if [ "$TB_BRANCH_MODE" = "gerrit" ] ; then
-        exit -1;
-    fi
-
-    check_branch_profile_common "${b?}"
-
-    if [ -z "${TB_TINDERBOX_BRANCH}" ] ; then
-        TB_TINDERBOX_BRANCH=$(determine_default_tinderbox_branch "${b?}")
-        # FIXME: determine if we can derive that value
-        # from ${b}
-        if [ -z "${TB_TINDERBOX_BRANCH}" ] ; then
-            die "Missing TB_TINDERBOX_BRANCH to associate a BRANCH name on the tiderbox server to the branch ${b?}"
-        fi
-    fi
-
-    if [ "${TB_BIBISECT}" == "1" ] ; then
-        if  [ -z "${TB_BIBISECT_DIR}" ] ; then
-            die "To do bibisect you must define TB_BIBISECT_DIR to point to your bibisect git repo"
-        fi
-        if [ ! -d "${TB_BIBISECT_DIR?}" -o ! -d "${TB_BIBISECT_DIR}/.git" ] ; then
-            die "TB_BIBISECT_DIR:${TB_BIBISECT_DIR?} is not a git repository"
-        fi
-        pushd "${TB_BIBISECT_DIR?}" > /dev/null || die "Cannot cd to ${TB_BIBISECT_DIR?} for branch ${b?}"
-        sha=$(git rev-parse "${b?}")
-        if [ "$?" != "0" ] ; then
-            die "Branch ${b?} does not exist in the bibisect repo, Cannot collect the requested bibisect"
-        fi
-        popd > /dev/null
-    fi
-
-    # if CCACHE_DIR is set it has been set by the branch's profile
-    # if TB_CCACHE_SIZE is set make sure the cache is as big as specified
-    # note: no need to restore the old CCACHE value
-    # since check_branches is run in a sub-shell
-    if [ -n "${CCACHE_DIR}" ] ; then
-        if [ -n "${TB_CCACHE_SIZE}" ] ; then
-            ccache -M "${TB_CCACHE_SIZE?}" > /dev/null
-        fi
-    fi
-
-    # if we did not die yet... we are good for this branch: print it
-    echo "${b?}"
-}
-
-
-#
-# Check all the branches under consideration
-# for suitable configuration
-#
-check_branches_profile()
-{
-local b
-
-    tb_TB_BRANCHES=""
-    tb_GERRIT_BRANCHES=""
-
-    for b in ${tb_BRANCHES?} ; do
-        if [ -z "$b" ] ; then
-            die "Internal Error: trying to process and empty branch name"
-        fi
-        check_branch_profile "$b"
-    done
-
-    # Accumulate valid branches for tb and gerrit
-    # depending of the mode
-    if [ "${tb_MODE?}" = "dual" -o "${tb_MODE?}" = "gerrit" ] ; then
-        if [ -z "$tb_GERRIT_BRANCHES" ] ; then
-            die "No branches are configured properly for gerrit"
-        fi
-    fi
-    if [ "${tb_MODE?}" = "dual" -o "${tb_MODE?}" = "tb" ] ; then
-        if [ -z "$tb_TB_BRANCHES" ] ; then
-            die "No branches are configured properly for tb"
-        fi
-    fi
-}
-
-#
-# Determine if there are new commits
-# on a given branch
-#
-check_for_commit()
-{
-    local b="$1"
-    local err_msgs=
-    local rev=
-    local refspec=
-    local r="-1"
-
-    [ $V ] && echo "Checking for new commit for tb-branch ${b?}"
-
-    source_branch_level_config "${b?}" "tb"
-
-    pushd "${TB_GIT_DIR?}" > /dev/null || die "Cannot cd to git repo ${TB_GIT_DIR?} for tb-branch ${b?}"
-
-    err_msgs="$( $tb_TIMEOUT git fetch 2>&1)"
-    if [ "$?" -ne "0" ] ; then
-        printf "Git repo broken - error is:\n\n$err_msgs" > error_log.log
-        report_error owner "$(print_date)" error_log.log
-        exit -1
-    else
-        refspec="origin/${b?}"
-        if [ -n "${TB_BRANCH_REMOTE_REFSPEC}" ] ; then
-            refspec="${TB_BRANCH_REMOTE_REFSPEC?}"
-        fi
-        [ $V ] && echo "collect current head for branch ${b?} refspec ${refspec?}"
-        rev=$(git rev-parse ${refspec?})
-        if [ "$?" = "0" ] ; then
-            echo "${rev?}" > "${TB_METADATA_DIR?}/${P}_${b?}_current-git-head.log"
-            print_date > "${TB_METADATA_DIR?}/${P}_${b?}_current-git-timestamp.log"
-
-            if [ ! -f "${TB_METADATA_DIR?}/prev-${P?}_${b?}_current-git-head.log" ] ; then
-                [ $V ] && echo "New commit for tb-branch ${b?} (no primer)"
-                r=0
-            elif [ "$(cat "${TB_METADATA_DIR?}/${P}_${b?}_current-git-head.log")" != "$(cat "${TB_METADATA_DIR?}/prev-${P?}_${b?}_current-git-head.log")" ] ; then
-                [ $V ] && echo "New commit for tb-branch ${b?}"
-                r=0
-            else
-                [ $V ] && echo "No New commit for tb-branch ${b?}"
-                r=2
-            fi
-        else
-            log_msgs "Git error while checking for commit on ${TB_GIT_REPO?} for branch ${b?}"
-            printf "Git repo broken - error is:\n\n$err_msgs" > error_log.log
-            report_error owner "$(print_date)" error_log.log
-            exit -1
-        fi
-    fi
-    [ $V ] && echo "pulling from the repo ${TB_GIT_REPO?} for branch ${b?} -> r=${r?}"
-    if [ "${r?}" = "0" ] ; then
-        if [ -n "${TB_TRIGGER_FILE}" ] ; then
-            if [ -f "${TB_TRIGGER_FILE}" ] ; then
-                r=1
-                [ $V ] && echo "Trigger file ${TB_TRIGGER_FILE} detected for branch ${b?} -> r=${r?}"
-            else
-                r=3
-                [ $V ] && echo "Trigger file ${TB_TRIGGER_FILE} missing for branch ${b?} -> r=${r?}"
-            fi
-        fi
-    fi
-    exit ${r?}
-}
-
-#
-# Save the sha assoicated with the HEAD of the current branch
+# Save the sha associated with the HEAD of the current branch
 #
 collect_current_head()
 {
     [ $V ] && echo "collect_current_head"
-    echo "$(git rev-parse HEAD)" > "${TB_METADATA_DIR?}/${P}_${B?}_current-git-head.log"
-    print_date > "${TB_METADATA_DIR?}/${P}_${B?}_current-git-timestamp.log"
+    echo "$(git rev-parse HEAD)" > "${TB_METADATA_DIR?}/${P?}_current-git-head.log"
+    print_date > "${TB_METADATA_DIR?}/${P?}_current-git-timestamp.log"
 }
 
 #
@@ -407,16 +95,7 @@ collect_current_head()
 #
 copy_autogen_config()
 {
-    if [ -f "${tb_PROFILE_DIR?}/branches/${B}/autogen.lastrun_${tb_BUILD_TYPE?}" ] ; then
-        cp "${tb_PROFILE_DIR?}/branches/${B}/autogen.lastrun_${tb_BUILD_TYPE?}" autogen.lastrun
-    elif [ -f "${tb_PROFILE_DIR?}/branches/${B}/autogen" ] ; then
-        cp "${tb_PROFILE_DIR?}/branches/${B}/autogen.lastrun" autogen.lastrun
-    elif [ -f "${tb_PROFILE_DIR?}/autogen.lastrun_${tb_BUILD_TYPE?}" ] ; then
-        cp "${tb_PROFILE_DIR?}/autogen.lastrun_${tb_BUILD_TYPE?}" autogen.lastrun
-    elif [ -f "${tb_PROFILE_DIR?}/autogen.lastrun" ] ; then
-        cp "${tb_PROFILE_DIR?}/autogen.lastrun" autogen.lastrun
-    fi
-
+    cp "${tb_CONFIG_DIR?}/profiles/${P?}/autogen.lastrun" autogen.lastrun
 }
 
 deliver_lo_to_bibisect()
@@ -433,7 +112,6 @@ deliver_to_bibisect()
     local oc=""
 
     [ $V ] && echo "deliver_to_bibisect()"
-    pushd "$TB_GIT_DIR" > /dev/null
 
     if [ -n ${tb_OPT_DIR} ] ; then
         # verify that someone did not screw-up bibisect repo
@@ -454,10 +132,10 @@ deliver_to_bibisect()
 
                 [ $V ] && echo "Bibisect: Include interesting logs/other data"
                 # Include the autogen log.
-                cp tb_${B?}_autogen.log "${TB_BIBISECT_DIR?}/."
+                cp tb_${P?}_autogen.log "${TB_BIBISECT_DIR?}/."
 
                 # Include the build, test logs.
-                cp tb_${B?}_build.log "${TB_BIBISECT_DIR?}/."
+                cp tb_${P?}_build.log "${TB_BIBISECT_DIR?}/."
 
                 # Make it easy to grab the commit id.
                 git rev-list -1 HEAD > "${TB_BIBISECT_DIR?}/commit.hash"
@@ -474,7 +152,6 @@ deliver_to_bibisect()
             fi
         fi
     fi
-    popd > /dev/null
 
 }
 
@@ -499,8 +176,15 @@ determine_default_tinderbox_branch()
         libreoffice-4-0)
             echo "${b?}"
             ;;
+        libreoffice-4-1)
+            echo "${b?}"
+            ;;
+        libreoffice-4-2)
+            echo "${b?}"
+            ;;
     esac
 }
+
 #
 # Find a gnu make
 #
@@ -534,7 +218,7 @@ determine_make()
 #
 die()
 {
-    echo "[$(print_date) ${P}:${B}] Error:" "$@" | tee -a ${tb_LOGFILE?}
+    echo "[$(print_date) ${P}] Error:" "$@" | tee -a ${tb_LOGFILE?}
     R=-1
     exit -1;
 }
@@ -546,10 +230,6 @@ epoch_from_utc()
     date -u '+%s' -d "$utc UTC"
 }
 
-epoch_to_utc()
-{
-    date -u -d @${1}
-}
 
 #
 # Fetch a gerrit changeset and check it out
@@ -557,14 +237,14 @@ epoch_to_utc()
 fetch_gerrit()
 {
     GERRIT_PREV_B=`git branch | grep '^\*' | sed 's/^..//' | sed 's/\//_/g'`
-    [ $V ] && echo "fetching gerrit path from ssh://${GERRIT_HOST?}/core ${GERRIT_TASK_REF}"
-    git fetch -q ssh://${GERRIT_HOST?}/core ${GERRIT_TASK_REF}
+    [ $V ] && echo "fetching gerrit path from ssh://${TB_GERRIT_HOST?}/core ${GERRIT_TASK_REF?}"
+    git fetch -q ssh://${TB_GERRIT_HOST?}/core ${GERRIT_TASK_REF?}
     if [ "$?" != "0" ] ; then
         retval="3"
     else
         git checkout -q FETCH_HEAD || die "fatal error checking out gerrit ref"
         git submodule -q update
-        [ $V ] && echo "fetched gerrit path from ssh://${GERRIT_HOST?}/core ${GERRIT_TASK_REF}"
+        [ $V ] && echo "fetched gerrit path from ssh://${TB_GERRIT_HOST?}/core ${GERRIT_TASK_REF?}"
         retval="0"
     fi
 }
@@ -588,10 +268,10 @@ get_commits_since_last_good()
     local repo=
     local sha=
 
-    pushd "$TB_GIT_DIR" > /dev/null
+    pushd "${TB_GIT_DIR?}" > /dev/null
 
-    if [ -f "${TB_METADATA_DIR?}/${P?}_${B?}_last-success-git-head.txt" ] ; then
-        sha=$(head -n1 "${TB_METADATA_DIR?}/${P?}_${B?}_last-success-git-head.txt")
+    if [ -f "${TB_METADATA_DIR?}/${P?}_last-success-git-head.txt" ] ; then
+        sha=$(head -n1 "${TB_METADATA_DIR?}/${P?}_last-success-git-head.txt")
         repo="core"
         if [ "${mode?}" = "people" ] ; then
             git log '--pretty=tformat:%ce' ${sha?}..HEAD
@@ -607,7 +287,7 @@ get_commits_since_last_good()
             echo "no primer available, can't extract the relevant log"
         fi
     fi
-    popd > /dev/null
+    popd > /dev/null # GIT_DIR
 }
 
 get_committers()
@@ -616,24 +296,16 @@ get_committers()
     get_commits_since_last_good people | sort | uniq | tr '\n' ','
 }
 
-get_first_branche()
-{
-    local top="$1"
-
-    echo "$top"
-
-}
-
 interupted_build()
 {
     log_msgs "Interrupted by Signal"
-    if [ "$tb_BUILD_TYPE" = "gerrit" ] ; then
+    if [ "$TB_MODE" = "gerrit" ] ; then
         if [ -n "${GERRIT_TASK_TICKET}" ] ;then
             # repport a cancellation if we already acquired the ticket
             R=2
             report_gerrit
         fi
-    elif [ "$tb_BUILD_TYPE" = "tb" ] ; then
+    elif [ "$TB_MODE" = "tb" ] ; then
         if [ -n "${tb_LAST_CHECKOUT_DATE?}" ] ; then
             # repport a cancellation if we already notified a start
             report_to_tinderbox "${tb_LAST_CHECKOUT_DATE?}" "fold" "no"
@@ -658,66 +330,36 @@ load_config()
 
 load_profile()
 {
-    local p=$1
-    local rc=0
-    local config_file=
-    local old_ccache_dir=
+    local p="$1"
+    source_profile "${p?}"
 
-    if [ -z "$p" ] ; then
-        die "A profile is needed to run: use -p or configure one"
-    else
-        tb_PROFILE_DIR="${tb_CONFIG_DIR?}/profiles/${p}"
-        if [ ! -d "${tb_PROFILE_DIR}" ] ; then
-            die "You need to configure the profile ${p} to use it"
-        fi
-
-        #save the current CCACHE_DIR setting
-        if [ -n "${CCACHE_DIR}" ] ; then
-            old_ccache_dir="${CCACHE_DIR?}"
-            unset CCACHE_DIR
-        fi
-        config_file="${tb_PROFILE_DIR?}/config"
-        if [ -f "${config_file?}" ] ; then
-            source "${config_file?}"
-        fi
-        # global level phase override
-        if [ -f "${tb_CONFIG_DIR?}/phases.sh" ] ; then
-            source "${tb_CONFIG_DIR?}/phases.sh"
-        fi
-        # project level phase override
-        if [ -f "${tb_PROFILE_DIR?}/phases.sh" ] ; then
-            source "${tb_PROFILE_DIR?}/phases.sh"
-        fi
-
-        # if we have a CCACHE_DIR here, it has been set by
-        # the profile. if we also haev a TB_CCACHE_SIZE
-        # make sure the cache is as big as indicated
-        # if CCACHE_DIR is not set, restaure the potential
-        # previous value
-        if [ -n "${CCACHE_DIR}" ] ; then
-            if [ -n "${TB_CCACHE_SIZE}" ] ; then
-                ccache -M "${TB_CCACHE_SIZE?}" > /dev/null
-            fi
-        else
-            if [ -n "${old_ccache_dir}" ] ; then
-                CCACHE_DIR="${old_ccache_dir?}"
-            fi
-        fi
+    # deal with missing or default value
+    if [ "${TB_TYPE?}" = "gerrit" ]; then
+        profile_gerrit_defaults
+    elif [ "${TB_TYPE?}" = "tb" ]; then
+        profile_tb_defaults
     fi
 }
 
 log_msgs()
 {
-    echo "[$(print_date) ${P?}:${B}]" "$@" | tee -a ${tb_LOGFILE?}
+    echo "[$(print_date) ${P?}]" "$@" | tee -a ${tb_LOGFILE?}
 }
 
-prepare_git_repo_for_gerrit()
+position_bibisect_branch()
 {
-    if [ -z "$TB_BUILD_DIR" ] ; then
-        TB_BUILD_DIR="${TB_GIT_DIR?}"
+    pushd ${TB_BIBISECT_DIR?} > /dev/null
+    git checkout -q ${TB_BRANCH?}
+    if [ "$?" -ne "0" ] ; then
+        echo "Error could not position the bibisect repository to the branch $B" 1>&2
+        exit 1;
     fi
-    pushd ${TB_GIT_DIR?} > /dev/null || die "Cannot cd to build dir : ${TB_GIT_DIR?}"
-    [ $V ] && echo "fetching gerrit path from ssh://${TB_GERRIT_HOST?}/core ${GERRIT_TASK_REF}"
+    popd > /dev/null
+}
+
+prepare_git_repo_for_gerrit()
+{
+    [ $V ] && echo "fetching gerrit path from ssh://${TB_GERRIT_HOST?}/core ${GERRIT_TASK_REF?}"
 
     (
         git clean -fd && git fetch -q ssh://${TB_GERRIT_HOST?}/core ${GERRIT_TASK_REF}
@@ -730,37 +372,26 @@ prepare_git_repo_for_gerrit()
     ) 2>&1 > ${TB_BUILD_DIR}/error_log.log
 
     if [ "$?" != "0" ] ; then
-        popd > /dev/null
         report_error owner "$(print_date)" error_log.log
-        die "Cannot reposition repo ${TB_GIT_DIR} to the proper branch"
+        die "Cannot reposition repo ${TB_GIT_DIR?} to the proper branch"
     fi
-    popd > /dev/null
 
 }
 
 prepare_git_repo_for_tb()
 {
-    local remote_sha="$(cat "${TB_METADATA_DIR?}/${P}_${B?}_current-git-head.log")"
+    local remote_sha="$(cat "${TB_METADATA_DIR?}/${P?}_current-git-head.log")"
     local local_sha=
     local refspec=
     local remote_refspec=
 
     # by default the local branch name is the 'branch' name for the profile
-    refspec="${B?}"
-    if [ -n "${TB_BRANCH_LOCAL_REFSPEC}" ] ; then
-        refspec="${TB_BRANCH_LOCAL_REFSPEC?}"
-    fi
-
-    # by default the remote branch name is identical to the local one with origin/ in front
-    remote_refspec="origin/${refspec?}"
-    if [ -n "${TB_BRANCH_REMOTE_REFSPEC}" ] ; then
-        remote_refspec="${TB_BRANCH_REMOTE_REFSPEC?}"
-    fi
+    refspec="${TB_LOCAL_REFSPEC?}"
+    remote_refspec="${TB_REMOTE_REFSPEC?}"
 
     if [ -z "$TB_BUILD_DIR" ] ; then
         TB_BUILD_DIR="${TB_GIT_DIR?}"
     fi
-    pushd ${TB_GIT_DIR?} > /dev/null || die "Cannot cd to build dir : ${TB_GIT_DIR?}"
 
     (
         local_sha=$(git rev-parse ${refspec?})
@@ -777,11 +408,9 @@ prepare_git_repo_for_tb()
     ) 2>&1 > ${TB_BUILD_DIR}/error_log.log
 
     if [ "$?" != "0" ] ; then
-        popd > /dev/null
         report_error owner "$(print_date)" error_log.log
-        die "Cannot reposition repo ${TB_GIT_DIR} to the proper branch"
+        die "Cannot reposition repo ${TB_GIT_DIR?} to the proper branch"
     fi
-    popd > /dev/null
 
 }
 
@@ -794,12 +423,12 @@ prepare_upload_manifest()
     echo "tinderbox: administrator: ${TB_OWNER?}" >> $manifest_file
     echo "tinderbox: buildname: ${TB_NAME?}" >> $manifest_file
     echo "tinderbox: tree: ${tb_TINDERBOX_BRANCH?}" >> $manifest_file
-    echo "tinderbox: pull time $(cat "${TB_METADATA_DIR?}/${P?}_${B?}_current-git-timestamp.log")" >> $manifest_file
+    echo "tinderbox: pull time $(cat "${TB_METADATA_DIR?}/${P?}_current-git-timestamp.log")" >> $manifest_file
     echo "tinderbox: git sha1s"  >> $manifest_file
-    echo "core:$(cat ${TB_METADATA_DIR?}/{P?}_${B?}_current-git-head.log)"  >> $manifest_file
+    echo "core:$(cat ${TB_METADATA_DIR?}/{P?}_current-git-head.log)"  >> $manifest_file
     echo ""  >> $manifest_file
     echo "tinderbox: autogen log"  >> $manifest_file
-    cat tb_${P?}_${B?}_autogen.log  >> $manifest_file
+    cat tb_${P?}_autogen.log  >> $manifest_file
 
 }
 
@@ -813,15 +442,29 @@ print_local_date()
     date '+%Y-%m-%d %H:%M:%S'
 }
 
-position_bibisect_branch()
+profile_gerrit_defaults()
 {
-    pushd ${TB_BIBISECT_DIR?} > /dev/null
-    git checkout -q ${B?}
-    if [ "$?" -ne "0" ] ; then
-        echo "Error could not position the bibisect repository to the branch $B" 1>&2
-        exit 1;
+    if [ -z "$TB_BUILD_DIR" ] ; then
+        TB_BUILD_DIR="${TB_GIT_DIR?}"
     fi
-    popd > /dev/null
+    if [ "${TB_GERRIT_TEST}" = "1" -o "${TB_TEST}" = "1" ] ; then
+        tb_GERRIT_TEST="-t"
+    fi
+
+}
+
+profile_tb_defaults()
+{
+    if [ -z "$TB_BUILD_DIR" ] ; then
+        TB_BUILD_DIR="${TB_GIT_DIR?}"
+    fi
+    if [ -z "${TB_LOCAL_REFSPEC}" ] ; then
+        TB_LOCAL_REFSPEC="${TB_BRANCH?}"
+    fi
+    if [ -z "${TB_REMOTE_REFSPEC}" ] ; then
+        TB_REMOTE_REFSPEC="origin/${TB_LOCAL_REFSPEC}"
+    fi
+
 }
 
 push_bibisect()
@@ -833,7 +476,7 @@ push_bibisect()
 
         [ $V ] && echo "Push: bibisec builds enabled"
         curr_day=$(date -u '+%Y%j')
-        last_day_upload="$(cat "${TB_METADATA_DIR?}/${P}_${B?}_last-bibisect-day.txt" 2>/dev/null)"
+        last_day_upload="$(cat "${TB_METADATA_DIR?}/${P?}_last-bibisect-day.txt" 2>/dev/null)"
         if [ -z "$last_day_upload" ] ; then
             last_day_upload=0
         fi
@@ -848,7 +491,7 @@ push_bibisect()
         [ $V ] && echo "Record bibisect"
         deliver_to_bibisect
 
-        echo "$curr_day" > "${TB_METADATA_DIR?}/${P}_${B?}_last-bibisect-day.txt"
+        echo "$curr_day" > "${TB_METADATA_DIR?}/${P?}_last-bibisect-day.txt"
 
     fi
 }
@@ -868,7 +511,7 @@ push_nightly()
     # Push build up to the project server (if enabled).
     [ $V ] && echo "Push: Nightly builds enabled"
     curr_day=$(date -u '+%Y%j')
-    last_day_upload="$(cat "${TB_METADATA_DIR?}/${P}_${B?}_last-upload-day.txt" 2>/dev/null)"
+    last_day_upload="$(cat "${TB_METADATA_DIR?}/${P?}_last-upload-day.txt" 2>/dev/null)"
     if [ -z "$last_day_upload" ] ; then
         last_day_upload=0
     fi
@@ -883,13 +526,13 @@ push_nightly()
     [ $V ] && echo "Push Nightly builds"
     prepare_upload_manifest
 
-    upload_time="$(cat "${TB_METADATA_DIR?}/${P?}_${B?}_current-git-timestamp.log")"
-    ssh upload at gimli.documentfoundation.org "mkdir -p \"/srv/www/dev-builds.libreoffice.org/daily/${B?}/${TB_NAME?}/${upload_time?}\"" || return 1
+    upload_time="$(cat "${TB_METADATA_DIR?}/${P?}_current-git-timestamp.log")"
+    ssh upload at gimli.documentfoundation.org "mkdir -p \"/srv/www/dev-builds.libreoffice.org/daily/${TB_BRANCH?}/${TB_NAME?}/${upload_time?}\"" || return 1
 
     if [ -f config_host.mk ] ; then
         inpath=$(grep INPATH= config_host.mk | sed -e "s/.*=//")
     fi
-    if [ -z "${inpath?}" -o ! -d "instsetoo_native/${inpath?}" ] ; then
+    if [ -z "${inpath?}" -o  -d "instsetoo_native/${inpath?}" ] ; then
         pack_loc="instsetoo_native/${inpath?}"
     else
         pack_loc="workdir"
@@ -897,7 +540,7 @@ push_nightly()
     pushd "${pack_loc?}" > /dev/null
     mkdir push 2>/dev/null || return 1
     stage="./push"
-    tag="${B?}~${upload_time?}"
+    tag="${P?}~${upload_time?}"
 
     for file in $(find . -name "*.dmg" -o -name '*.apk' -o -name "Lib*.tar.gz" -o -name "Lib*.exe" -o -name "Lib*.zip" -o -path '*/native/install/*.msi' | grep -v "/push/")
     do
@@ -906,11 +549,12 @@ push_nightly()
         mv $file "$stage/$target"
     done;
 
-    rsync --bwlimit=${TB_BANDWIDTH_LIMIT} -avPe ssh ${stage}/${tag}_* "upload at gimli.documentfoundation.org:/srv/www/dev-builds.libreoffice.org/daily/${B?}/${TB_NAME?}/${upload_time?}/" || return 1
+    rsync --bwlimit=${TB_BANDWIDTH_LIMIT} -avPe ssh ${stage}/${tag}_* "upload at gimli.documentfoundation.org:/srv/www/dev-builds.libreoffice.org/daily/${TB_BRANCH?}/${TB_NAME?}/${upload_time?}/" || return 1
     if [ "$?" == "0" ] ; then
-        ssh upload at gimli.documentfoundation.org "cd \"/srv/www/dev-builds.libreoffice.org/daily/${B?}/${TB_NAME?}/\" && { rm current; ln -s \"${upload_time}\" current ; }"
+        ssh upload at gimli.documentfoundation.org "cd \"/srv/www/dev-builds.libreoffice.org/daily/${TB_BRANCH?}/${TB_NAME?}/\" && { rm current; ln -s \"${upload_time}\" current ; }"
     fi
-    echo "$curr_day" > "${TB_METADATA_DIR?}/${P}_${B?}_last-upload-day.txt"
+    echo "$curr_day" > "${TB_METADATA_DIR?}/${P?}_last-upload-day.txt"
+    popd  > /dev/null # pack_loc
     return 0
 }
 
@@ -926,7 +570,7 @@ report_error ()
     local error_log="$1"
     shift
 
-    local last_success=$(cat "${TB_METADATA_DIR?}/${P}_${B?}_last-success-git-timestamp.txt")
+    local last_success=$(cat "${TB_METADATA_DIR?}/${P?}_last-success-git-timestamp.txt")
     to_mail=
     if [ "${tb_SEND_MAIL?}" = "owner" -o "${tb_SEND_MAIL?}" = "debug" -o "${tb_SEND_MAIL?}" = "author" ] ; then
         to_mail="${TB_OWNER?}"
@@ -998,7 +642,7 @@ local gzlog=
             echo ""
             echo "Build: OK"
             echo ""
-            cat tb_${B}_autogen.log 2>/dev/null
+            cat tb_${P?}_autogen.log 2>/dev/null
         ) | gzip -c > "${gzlog}"
     else
         gzlog="tinder.log.gz"
@@ -1013,7 +657,7 @@ local gzlog=
                 echo "Build: FAIL"
             fi
             echo ""
-            cat tb_${B}_autogen.log tb_${B}_clean.log tb_${B}_build.log tb_${B}_tests.log 2>/dev/null
+            cat tb_${P?}_autogen.log tb_${P?}_clean.log tb_${P?}_build.log tb_${P?}_tests.log 2>/dev/null
         ) | gzip -c > "${gzlog}"
     fi
 
@@ -1063,9 +707,9 @@ tinderbox: END
         gzlog="tinder.log.gz"
         (
             echo "$message_content"
-            cat "${TB_METADATA_DIR?}/${P}_${B?}_current-git-timestamp.log"
-            for cm in $(cat ${TB_METADATA_DIR?}/${P?}_${B?}_current-git-head.log) ; do echo "TinderboxPrint: $(generate_cgit_link "${cm}")" ; done
-            cat tb_${B?}_autogen.log tb_${B?}_clean.log tb_${B?}_build.log tb_${B?}_tests.log 2>/dev/null
+            cat "${TB_METADATA_DIR?}/${P?}_current-git-timestamp.log"
+            for cm in $(cat "${TB_METADATA_DIR?}/${P?}_current-git-head.log") ; do echo "TinderboxPrint: $(generate_cgit_link "${cm}")" ; done
+            cat tb_${P?}_autogen.log tb_${P?}_clean.log tb_${P?}_build.log tb_${P?}_tests.log 2>/dev/null
         ) | gzip -c > "${gzlog}"
         xtinder="X-Tinder: gzookie"
         subject="tinderbox gzipped logfile"
@@ -1083,36 +727,76 @@ tinderbox: END
     fi
 }
 
+rotate_active_profiles()
+{
+    local x=
+    local p="$1"
+    local rot=""
+
+    for x in ${tb_ACTIVE_PROFILES} ; do
+        if [ "${x?}" != "${p?}" ] ; then
+            if [ -z "${rot?}" ] ; then
+                rot="${x?}"
+            else
+                rot="${rot?} ${x?}"
+            fi
+        fi
+    done
+    if [ -z "${rot?}" ] ; then
+        rot="${p?}"
+    else
+        rot="${rot?} ${p?}"
+    fi
+    tb_ACTIVE_PROFILES="${rot?}"
+}
+
 rotate_logs()
 {
     if [ "${R?}" = "0" ] ; then
-        cp -f "${TB_METADATA_DIR?}/${P}_${B?}_current-git-head.log" "${TB_METADATA_DIR?}/${P}_${B?}_last-success-git-head.txt" 2>/dev/null
-        cp -f "${TB_METADATA_DIR?}/${P}_${B?}_current-git-timestamp.log" "${TB_METADATA_DIR?}/${P}_${B?}_last-success-git-timestamp.txt" 2>/dev/null
+        cp -f "${TB_METADATA_DIR?}/${P?}_current-git-head.log" "${TB_METADATA_DIR?}/${P?}_last-success-git-head.txt" 2>/dev/null
+        cp -f "${TB_METADATA_DIR?}/${P?}_current-git-timestamp.log" "${TB_METADATA_DIR?}/${P?}_last-success-git-timestamp.txt" 2>/dev/null
     elif [ "${R}" != "2" ]; then # do not count abandonned false_negative loop as failure
-        cp -f "${TB_METADATA_DIR?}/${P}_${B?}_current-git-head.log" "${TB_METADATA_DIR?}/${P}_${B?}_last-failure-git-head.txt" 2>/dev/null
-        cp -f "${TB_METADATA_DIR?}/${P}_${B?}_current-git-timestamp.log" "${TB_METADATA_DIR?}/${P}_${B?}_last-failure-git-timestamp.txt" 2>/dev/null
+        cp -f "${TB_METADATA_DIR?}/${P?}_current-git-head.log" "${TB_METADATA_DIR?}/${P?}_last-failure-git-head.txt" 2>/dev/null
+        cp -f "${TB_METADATA_DIR?}/${P?}_current-git-timestamp.log" "${TB_METADATA_DIR?}/${P?}_last-failure-git-timestamp.txt" 2>/dev/null
     fi
-    for f in tb_${B}*.log ; do
+    for f in tb_${P?}_*.log ; do
         mv -f ${f} prev-${f} 2>/dev/null
     done
     pushd "${TB_METADATA_DIR?}" > /dev/null
-    for f in ${P?}_${B}*.log ; do
+    for f in ${P?}_*.log ; do
         mv -f ${f} prev-${f} 2>/dev/null
     done
     popd > /dev/null
 
 }
 
-rotate_branches()
+#
+# Run a gerrit build
+#
+# Run a a subshell to isolate Branch-level config
+#
+run_gerrit_task()
 {
-    local top="$1"
+    log_msgs "Starting build gerrit ref:${GERRIT_TASK_TICKET?}"
 
-    shift
-    if [ -n "$1" ] ; then
-        echo "$@ ${top}"
-    else
-        echo "$top"
-    fi
+    # clean-up the git repo associated with the
+    # branch and checkout the target sha
+    prepare_git_repo_for_gerrit
+
+    # gerrit build are not incremental
+    # always use all the phases
+    local phase_list="autogen clean make test push"
+
+    pushd ${TB_BUILD_DIR?} > /dev/null || die "Cannot cd to build dir : ${TB_BUILD_DIR?}"
+
+    # run the build
+    do_build ${phase_list?}
+
+    # tell teh gerrit buildbot of the result of the build
+    # R contain the overall result
+    report_gerrit
+
+    popd > /dev/null # BUILD_DIR
 }
 
 #
@@ -1122,8 +806,6 @@ run_loop()
 {
 local s=0
 
-    check_branches_profile
-
     while true; do
 
         # Check for stop request
@@ -1134,30 +816,18 @@ local s=0
         fi
 
         # Select the next task
-        # this set tb_BUILD_TYPE and B
-        select_next_task
+        # this set P
+        run_next_task
 
         # based on the build type run the appropriate build
-        case "$tb_BUILD_TYPE" in
-            tb)
-                run_one_tb
-                s=${TB_POST_BUILD_DELAY?}
-                ;;
-            gerrit)
-                run_one_gerrit
-                s=${TB_POST_BUILD_DELAY?}
-                ;;
-            wait)
-                if [ "${s?}" != "${TB_POLL_DELAY?}" ] ; then
-                    log_msgs "Nothing to do. waiting ${TB_POLL_DELAY?} seconds."
-                fi
-                s=${TB_POLL_DELAY?}
-                ;;
-            *)
-                die "Invalid next mode $tb_BUILD_TYPE."
-                ;;
-        esac
-
+        if [ -z "${P?}" ] ; then
+            if [ "${s?}" != "${TB_POLL_DELAY?}" ] ; then
+                log_msgs "Nothing to do. waiting ${TB_POLL_DELAY?} seconds."
+            fi
+            s=${TB_POLL_DELAY?}
+        else
+            s=${TB_POST_BUILD_DELAY?}
+        fi
     done
 
     # if we were stopped by request, let's log that
@@ -1170,166 +840,92 @@ local s=0
 }
 
 #
-# Run a gerrit build
+# Find a profile that has something to do then run it
 #
-# Run a a subshell to isolate Branch-level config
-#
-run_one_gerrit()
+run_next_task()
 {
+    P=
     R=0
-    (
-        trap 'interupted_build' SIGINT SIGQUIT
-
-        log_msgs "Starting tb build gerrit ref:${GERRIT_TASK_TICKET?}"
-        # source branch-level configuration
-        source_branch_level_config "${B?}" "gerrit"
-
-        if [ -z "$TB_BUILD_DIR" ] ; then
-            TB_BUILD_DIR="${TB_GIT_DIR?}"
+    for P in ${tb_ACTIVE_PROFILES} ; do
+        try_run_task "$P"
+        if [ "${R}" = "0" ] ; then
+            break;
+        fi
+        P=
+    done
+    if [ "${TB_MODE}" = "fair" ] ; then
+        if [ -n "$P" -a "${R}" = "0" ] ; then
+            rotate_active_profiles "${P?}"
         fi
-
-        # clean-up the git repo associated with the
-        # branch and checkout the target sha
-        prepare_git_repo_for_gerrit
-
-        # gerrit build are not incremental
-        # always use all the phases
-        local phase_list="autogen clean make test push"
-
-        pushd ${TB_BUILD_DIR?} > /dev/null || die "Cannot cd to build dir : ${TB_BUILD_DIR?}"
-
-        # run the build
-        do_build ${phase_list?}
-
-        # tell teh gerrit buildbot of the result of the build
-        # R contain the overall result
-        report_gerrit
-
-        popd > /dev/null
-        exit ${R?}
-    )
-    R="$?"
-
-    # check we we intercepted a signal, if so bail
-    if [ "${R?}" = "4" ] ; then
-        exit -1
     fi
 }
 
-#
-# Run a tinderbox build
-#
-# Run as subshel to isolate Branch-level config
-#
-run_one_tb()
+run_tb_task()
 {
-    R=0
-    (
-        trap 'interupted_build' SIGINT SIGQUIT
-
-        log_msgs "Starting tb build for sha:$(cat "${TB_METADATA_DIR?}/${P}_${B?}_current-git-head.log")"
-        source_branch_level_config "${B?}" "${tb_BUILD_TYPE?}"
-        if [ -z "$TB_BUILD_DIR" ] ; then
-            TB_BUILD_DIR="${TB_GIT_DIR?}"
-        fi
+    local phase_list
+    local retry_count=3
 
-        # for 'primer' build we expect the repo to be in a buildable
-        # condition already
-        if [ "${tb_ONE_SHOT?}" != "1" ] ; then
-            prepare_git_repo_for_tb
-        else
-            collect_current_head
-        fi
+    if [ "${tb_ONE_SHOT?}" != "1" ] ; then
+        prepare_git_repo_for_tb
+    else
+        collect_current_head
+    fi
 
-        local phase_list
-        local retry_count=3
+    log_msgs "Starting tb build for sha:$(cat "${TB_METADATA_DIR?}/${P?}_current-git-head.log")"
 
-        tb_LAST_CHECKOUT_DATE="$(cat "${TB_METADATA_DIR?}/${P}_${B?}_current-git-timestamp.log")"
-        report_to_tinderbox "${tb_LAST_CHECKOUT_DATE?}" "building" "no"
-        tb_TB_BUILD_REPORTED=1
+    tb_LAST_CHECKOUT_DATE="$(cat "${TB_METADATA_DIR?}/${P?}_current-git-timestamp.log")"
+    report_to_tinderbox "${tb_LAST_CHECKOUT_DATE?}" "building" "no"
 
-        if [ "$TB_INCREMENTAL" = "1" ] ; then
-            phase_list="autogen make test push"
-        else
-            phase_list="autogen clean make test push"
-        fi
+    if [ "$TB_INCREMENTAL" = "1" ] ; then
+        phase_list="autogen make test push"
+    else
+        phase_list="autogen clean make test push"
+    fi
 
-        pushd ${TB_BUILD_DIR?} > /dev/null || die "Cannot cd to build dir : ${TB_BUILD_DIR?}"
+    pushd ${TB_BUILD_DIR?} > /dev/null || die "Cannot cd to build dir : ${TB_BUILD_DIR?}"
 
-        while [ "${phase_list}" != "" ] ; do
+    while [ "${phase_list}" != "" ] ; do
 
-            do_build ${phase_list?}
+        do_build ${phase_list?}
 
-            if [ "${R?}" = "0" ] ; then
-                report_to_tinderbox "${tb_LAST_CHECKOUT_DATE}" "success" "yes"
-                phase_list=
-                log_msgs "Successful tb build for sha:$(cat "${TB_METADATA_DIR?}/${P}_${B?}_current-git-head.log")"
-            elif [ "${R?}" = "2" ] ; then
-                log_msgs "False negative build, skip reporting"
+        if [ "${R?}" = "0" ] ; then
+            report_to_tinderbox "${tb_LAST_CHECKOUT_DATE}" "success" "yes"
+            phase_list=
+            log_msgs "Successful tb build for sha:$(cat "${TB_METADATA_DIR?}/${P?}_current-git-head.log")"
+        elif [ "${R?}" = "2" ] ; then
+            log_msgs "False negative build, skip reporting"
                     # false negative does not need a full clean build, let's just redo make and after
-                retry_count=$((retry_count - 1))
-                if [ "$retry_count" = "0" ] ; then
-                    log_msgs "False Negative Failed tb build for sha:$(cat "${TB_METADATA_DIR?}/${P}_${B?}_current-git-head.log")"
-                    phase_list=""
-                    R=2
-                    if [ "${tb_ONE_SHOT?}" != "1" ] ; then
-                        report_to_tinderbox "${tb_LAST_CHECKOUT_DATE?}" "fold" "no"
-                    fi
-                else
-                    log_msgs "False Negative Retry tb build for sha:$(cat "${TB_METADATA_DIR?}/${P}_${B?}_current-git-head.log")"
-                    phase_list="make test push"
-                    R=0
+            retry_count=$((retry_count - 1))
+            if [ "$retry_count" = "0" ] ; then
+                log_msgs "False Negative Failed tb build for sha:$(cat "${TB_METADATA_DIR?}/${P?}_current-git-head.log")"
+                phase_list=""
+                R=2
+                if [ "${tb_ONE_SHOT?}" != "1" ] ; then
+                    report_to_tinderbox "${tb_LAST_CHECKOUT_DATE?}" "fold" "no"
                 fi
             else
-                printf "${tb_REPORT_MSGS?}:\n\n" > report_error.log
-                echo "======" >> report_error.log
-                if [ "${tb_REPORT_LOG?}" == "tb_${B}_build.log" ] ; then
-                    tail -n1000 ${tb_REPORT_LOG?} >> report_error.log
-                else
-                    cat ${tb_REPORT_LOG?} >> report_error.log
-                fi
-                report_error committer "${tb_LAST_CHECKOUT_DATE?}" report_error.log
-                report_to_tinderbox "${tb_LAST_CHECKOUT_DATE?}" "build_failed" "yes"
-                phase_list=""
-                log_msgs "Failed tb build for sha:$(cat "${TB_METADATA_DIR?}/${P}_${B?}_current-git-head.log")"
+                log_msgs "False Negative Retry tb build for sha:$(cat "${TB_METADATA_DIR?}/${P?}_current-git-head.log")"
+                phase_list="make test push"
+                R=0
+            fi
+        else
+            printf "${tb_REPORT_MSGS?}:\n\n" > report_error.log
+            echo "======" >> report_error.log
+            if [ "${tb_REPORT_LOG?}" == "tb_${P?}_build.log" ] ; then
+                tail -n1000 ${tb_REPORT_LOG?} >> report_error.log
+            else
+                cat ${tb_REPORT_LOG?} >> report_error.log
             fi
-        done
-        tb_LAST_CHECKOUT_DATE=
-        rotate_logs
-        popd > /dev/null
-        if [ "${R?}" = "0" -a "${tb_BUILD_TRIGERRED}" = "1" ] ; then
-            rm -f "${TB_TRIGGER_FILE?}"
+            report_error committer "${tb_LAST_CHECKOUT_DATE?}" report_error.log
+            report_to_tinderbox "${tb_LAST_CHECKOUT_DATE?}" "build_failed" "yes"
+            phase_list=""
+            log_msgs "Failed tb build for sha:$(cat "${TB_METADATA_DIR?}/${P?}_current-git-head.log")"
         fi
-        exit ${R?}
-    )
-    R="$?"
-
-    # check we we intercepted a signal, if so bail
-    if [ "${R?}" = "4" ] ; then
-        exit -1
-    fi
-}
+    done
+    tb_LAST_CHECKOUT_DATE=
+    rotate_logs
+    popd > /dev/null # BUILD_DIR
 
-#
-# run a one-shot tb run
-#
-run_primer()
-{
-    check_branches_profile
-
-    # as a special case the select_next_task
-    # if tb_ONE_SHOT=1 return the first branch
-    # of the slected list
-    # a primer build build one and one branch only.
-    select_next_task
-
-    # as a special case tun_one_tb() does not reset the repo
-    # do it will just build what is there.
-    # it is the user responsability to make sure that the state
-    # of the repo is correct.
-    # the rational is to allow 'primer' build to be use
-    # to test uncommited changes and/or local commit
-    run_one_tb
 }
 
 #
@@ -1340,15 +936,24 @@ select_next_gerrit_task()
 {
     local result
     local has_task
+    local r=0
+
+    # short-cut triiger based build
+    if [ -n "${TB_TRIGGER_FILE}" ] ; then
+        if [ ! -f "${TB_TRIGGER_FILE}" ] ; then
+            R=3
+            [ $V ] && echo "Trigger file ${TB_TRIGGER_FILE} missing for profile ${P?} -> R=${R?}"
+            return
+        fi
+    fi
 
     [ $V ] && echo "Try to get a task for gerrit buildbot"
 
-    tb_BUILD_TYPE="wait"
     GERRIT_TASK_TICKET=""
     GERRIT_TASK_BRANCH=""
     GERRIT_TASK_REF=""
     GERRIT_TASK_FEATURE=""
-    result=$(ssh ${TB_GERRIT_HOST?} buildbot get -p core -a ${tb_GERRIT_PLATFORM?} --format BASH ${tb_GERRIT_BRANCHES?})
+    result=$(ssh ${TB_GERRIT_HOST?} buildbot get -p core -a ${tb_GERRIT_PLATFORM?} --format BASH ${TB_GERRIT_BRANCH?} ${tb_GERRIT_TEST})
     [ $V ] && echo "Get task result:${result}"
 
     has_task=$(echo "$result" | grep "^GERRIT_TASK_")
@@ -1356,15 +961,21 @@ select_next_gerrit_task()
         eval "${result}"
         if [ -z "${GERRIT_TASK_TICKET}" -o -z "${GERRIT_TASK_REF}" -o -z "${GERRIT_TASK_BRANCH}" ] ; then
             [ $V ] && echo "no valid task from gerrit buildbot"
+            R=2
         else
-            tb_BUILD_TYPE="gerrit"
-            B="${GERRIT_TASK_BRANCH?}"
-            [ $V ] && echo "got task TASK_TICKET=$GERRIT_TASK_TICKET TASK_REF=$GERRIT_TASK_REF TASK_BRANCH=${B?} "
+            [ $V ] && echo "got task TASK_TICKET=$GERRIT_TASK_TICKET TASK_REF=$GERRIT_TASK_REF TASK_BRANCH=${GERRIT_TASK_BRANCH} for profile ${P?} "
+            R=0
         fi
     else
         [ $V ] && echo "no task from gerrit buildbot"
+        R=2
+    fi
+    if [ "${R?}" = "0" ] ; then
+        if [ -n "${TB_TRIGGER_FILE}" ] ; then
+            R=1
+            [ $V ] && echo "Trigger file ${TB_TRIGGER_FILE} detected for profile ${P?} -> R=${R?}"
+        fi
     fi
-
 }
 
 #
@@ -1374,33 +985,12 @@ select_next_gerrit_task()
 #
 select_next_task()
 {
-
-    if [ "${tb_MODE?}" = "tb" ] ; then
+    if [ "${TB_TYPE?}" = "tb" ] ; then
         select_next_tb_task
-    elif [ "${tb_MODE?}" = "gerrit" ] ; then
+    elif [ "${TB_TYPE?}" = "gerrit" ] ; then
         select_next_gerrit_task
     else
-        if [ "${tb_NEXT_PRIORITY}" = "tb" ] ; then
-            select_next_tb_task
-            if [ "${tb_BUILD_TYPE?}" = "wait" ] ; then
-                select_next_gerrit_task
-            fi
-        else
-            select_next_gerrit_task
-            if [ "${tb_BUILD_TYPE?}" = "wait" ] ; then
-                select_next_tb_task
-            fi
-        fi
-
-        # if we use a 'fair' priority
-        # switch the order in which we try to get stuff
-        if [ "${tb_MODE?}" = "fair" ] ; then
-            if [ "${tb_BUILD_TYPE?}" = "tb" ] ; then
-                tb_NEXT_PRIORITY="gerrit"
-            elif [ "${tb_BUILD_TYPE?}" = "gerrit" ] ; then
-                tb_NEXT_PRIORITY="tb"
-            fi
-        fi
+        die "Invalid TB_TYPE:$TB_TYPE"
     fi
 }
 
@@ -1411,28 +1001,60 @@ select_next_task()
 #
 select_next_tb_task()
 {
-    local b
-    local r
-
-    tb_BUILD_TYPE="wait"
-    for b in ${tb_TB_BRANCHES?} ; do
-        if [ "${tb_ONE_SHOT?}" = "1" ] ; then
-            B="${b?}"
-            tb_BUILD_TYPE="tb"
-            tb_BUILD_TRIGGERED="0"
-            break
+    # short-cut triiger based build
+    if [ -n "${TB_TRIGGER_FILE}" ] ; then
+        if [ ! -f "${TB_TRIGGER_FILE}" ] ; then
+            R=3
+            [ $V ] && echo "Trigger file ${TB_TRIGGER_FILE} missing for profile ${P?} -> R=${R?}"
+            return
+        fi
+    fi
+
+    [ $V ] && echo "Checking for new commit for profile ${P?}"
+
+    err_msgs="$( $tb_TIMEOUT git fetch 2>&1)"
+    if [ "$?" -ne "0" ] ; then
+        printf "Git repo broken - error is:\n\n$err_msgs" > error_log.log
+        report_error owner "$(print_date)" error_log.log
+        R="-1"
+    else
+        refspec="${TB_REMOTE_REFSPEC?}"
+
+        [ $V ] && echo "collect current head for profile ${P?} refspec ${refspec?}"
+        rev=$(git rev-parse ${refspec?})
+        if [ "$?" = "0" ] ; then
+            echo "${rev?}" > "${TB_METADATA_DIR?}/${P?}_current-git-head.log"
+            print_date > "${TB_METADATA_DIR?}/${P?}_current-git-timestamp.log"
+
+            if [ ! -f "${TB_METADATA_DIR?}/prev-${P?}_current-git-head.log" ] ; then
+                [ $V ] && echo "New commit for profile ${P?} (no primer)"
+                R=0
+            elif [ "$(cat "${TB_METADATA_DIR?}/${P?}_current-git-head.log")" != "$(cat "${TB_METADATA_DIR?}/prev-${P?}_current-git-head.log")" ] ; then
+                [ $V ] && echo "New commit for profile ${P?}"
+                R=0
+            else
+                [ $V ] && echo "No New commit for profile ${P?}"
+                R=2
+            fi
         else
-            ( check_for_commit "$b" )
-            r="$?"
-            if [ "${r?}" = "0" -o "${r?}" = "1" ] ; then
-                B="${b?}"
-                tb_TB_BRANCHES=$(rotate_branches ${tb_TB_BRANCHES?})
-                tb_BUILD_TYPE="tb"
-                tb_BUILD_TRIGGERED="${r?}"
-                break
+            log_msgs "Git error while checking for commit on ${TB_GIT_DIR?} for profile ${P?}"
+            printf "Git repo broken - error is:\n\n$err_msgs" > error_log.log
+            report_error owner "$(print_date)" error_log.log
+            return -1
+        fi
+    fi
+    [ $V ] && echo "pulling from the repo ${TB_GIT_DIR?} for profile ${P?} -> R=${R?}"
+    if [ "${R?}" = "0" ] ; then
+        if [ -n "${TB_TRIGGER_FILE}" ] ; then
+            if [ -f "${TB_TRIGGER_FILE}" ] ; then
+                R=1
+                [ $V ] && echo "Trigger file ${TB_TRIGGER_FILE} detected for profile ${P?} -> R=${R?}"
+            else
+                R=3
+                [ $V ] && echo "Trigger file ${TB_TRIGGER_FILE} missing for profile ${P?} -> R=${R?}"
             fi
         fi
-    done
+    fi
 }
 
 send_mail_msg()
@@ -1451,13 +1073,13 @@ send_mail_msg()
 
     [ $V ] && log_msgs "send mail to ${to?} with subject \"${subject?}\""
     [ $V ] && quiet=""
-    if [ -n "${log}" ] ; then
-        ${tb_BIN_DIR?}/tb_send_email $quiet -f "${TB_OWNER?}" -s "${TB_SMTP_HOST?}" $smtp_auth -t "${to?}" -bcc "${bcc?}" -u "${subject?}" -o "message-header=${headers?}" -a "${log?}"
-    elif [ -n "${headers?}" ] ; then
-        ${tb_BIN_DIR?}/tb_send_email $quiet -f "${TB_OWNER?}" -s "${TB_SMTP_HOST?}" $smtp_auth -t "${to?}" -bcc "${bcc?}" -u "${subject?}" -o "message-header=${headers?}"
-    else
-        ${tb_BIN_DIR?}/tb_send_email $quiet -f "${TB_OWNER?}" -s "${TB_SMTP_HOST?}" $smtp_auth -t "${to?}" -bcc "${bcc?}" -u "${subject?}"
-    fi
+#    if [ -n "${log}" ] ; then
+#        ${tb_BIN_DIR?}/tb_send_email $quiet -f "${TB_OWNER?}" -s "${TB_SMTP_HOST?}" $smtp_auth -t "${to?}" -bcc "${bcc?}" -u "${subject?}" -o "message-header=${headers?}" -a "${log?}"
+#    elif [ -n "${headers?}" ] ; then
+#        ${tb_BIN_DIR?}/tb_send_email $quiet -f "${TB_OWNER?}" -s "${TB_SMTP_HOST?}" $smtp_auth -t "${to?}" -bcc "${bcc?}" -u "${subject?}" -o "message-header=${headers?}"
+#    else
+#        ${tb_BIN_DIR?}/tb_send_email $quiet -f "${TB_OWNER?}" -s "${TB_SMTP_HOST?}" $smtp_auth -t "${to?}" -bcc "${bcc?}" -u "${subject?}"
+#    fi
 }
 
 #
@@ -1477,11 +1099,13 @@ set_factory_default()
     TB_BANDWIDTH_LIMIT=2000
 
     tb_ONE_SHOT=
-
+    tb_SEND_MAIL="none"
+    tb_PUSH_NIGHTLIES=0
+    tb_CONFIG_DIR="~/.tb"
 }
 
 #
-# Setup default at the profile level
+# Setup default at the global level
 #
 # Based on the content of the profile
 # setup some interna variable
@@ -1490,7 +1114,7 @@ set_factory_default()
 #
 # Verify that mandatory profile
 # variables are defined
-setup_profile_defaults()
+set_global_defaults()
 {
     local os
 
@@ -1501,121 +1125,186 @@ setup_profile_defaults()
         tb_LOGFILE="${TB_LOGFILE?}"
     fi
 
-    if [ -z "{TB_METADATA_DIR}" ] ; then
-        TB_METADATA_DIR="${tb_CONFIG_DIR?}/meta/"
+    if [ -z "${TB_METADATA_DIR}" ] ; then
+        TB_METADATA_DIR="${tb_CONFIG_DIR?}/meta"
     fi
-    if [ ! -d ${TB_METADATA_DIR} ] ; then
+    if [ ! -d "${TB_METADATA_DIR?}" ] ; then
         mkdir -p "${TB_METADATA_DIR?}" || die "Creating ${TB_METADATA_DIR?}"
     fi
 
-    if [ -z "${TB_OWNER}" ] ; then
-        die "Error: TB_OWNER is required to be configured"
+}
+
+source_profile()
+{
+    local p="$1"
+
+    if [ -f "${tb_CONFIG_DIR?}/profiles/${p?}/config" ] ; then
+        source "${tb_CONFIG_DIR?}/profiles/${p?}/config"
+    else
+        die "config ${tb_CONFIG_DIR?}/profiles/${p?}/config does not exist"
+    fi
+    if [ -f "${tb_CONFIG_DIR?}/profiles/${p?}/phases.sh" ] ; then
+        source "${tb_CONFIG_DIR?}/profiles/${p?}/phases.sh"
+    fi
+
+}
+
+try_run_task()
+{
+    (
+        local triggered=0
+        R=0
+        trap 'interupted_build' SIGINT SIGQUIT
+        load_profile "${P?}"
+
+        pushd "${TB_GIT_DIR?}" > /dev/null || die "Cannot cd to git repo ${TB_GIT_DIR?} for profile ${P?}"
+
+        select_next_task
+        # do not delete the trigger until we succeed
+        if [ "$R" = "1" ] ; then
+            triggered="$R"
+            R=0
+        fi
+        # best effort and delete
+        if [ "$R" = "5" ] ; then
+            triggered="$R"
+            R=0
+        fi
+        if [ "$R" = "0" ] ; then
+            if [ "${TB_TYPE?}" = "gerrit" ]; then
+                run_gerrit_task
+            elif [ "${TB_TYPE?}" = "tb" ]; then
+                run_tb_task
+            fi
+        fi
+
+        popd > /dev/null # GIT_DIR
+
+        if [ "${triggered}" != "0" ] ; then
+            if [ "triggered" = "1" -a "$R" = 0 ] ; then
+                rm -f "${TB_TRIGGER_FILE?}"
+            elif [ "triggered" = "5" ] ; then
+                rm -f "${TB_TRIGGER_FILE?}"
+            fi
+        fi
+        return $R
+    )
+    R="$?"
+    # check we we intercepted a signal, if so bail
+    if [ "${R?}" = "4" ] ; then
+        exit -1
     fi
+}
 
+validate_active_profile()
+{
+    local p="$1"
+    (
+        source_profile "${p?}"
+
+        # check for mandatory values
+        if [ -z "${TB_TYPE}" ] ; then
+            die "Missing TB_TYPE for profile ${p?}"
+        elif [ "${TB_TYPE}" = "gerrit" ] ; then
+            validate_gerrit_profile "${p?}"
+        elif [ "${TB_TYPE}" = "tb" ] ; then
+            validate_tb_profile "${p?}"
+        else
+            die "Invalid TB_TYPE:${TB_TYPE} for profile ${p?}"
+        fi
+    )
+    if test $? -ne 0;  then
+        R=8
+    fi
+}
+
+validate_active_profiles()
+{
+    if [ -z "${tb_ACTIVE_PROFILES}" ] ; then
+        tb_ACTIVE_PROFILES="$TB_ACTIVE_PROFILES"
+    fi
+    if [ -z "${tb_ACTIVE_PROFILES}" ] ; then
+        die "TB_ACTIVE_PROFILES, or -p <profile>  is required"
+    fi
+    R=0
+    for P in ${tb_ACTIVE_PROFILES} ; do
+        validate_active_profile $P
+    done
+    if [ "$R" != "0" ] ; then
+        die "Error while validating actives profiles"
+    fi
+}
+
+validate_gerrit_profile()
+{
+    local p="$1"
     if [ -z "${TB_NAME}" ] ; then
         die "TB_NAME is required to be configured"
     fi
-
-    if [ -z "${tb_GERRIT_PLATFORM}" ] ; then
+    if [ -z "${TB_GIT_DIR}" ] ; then
+        die "TB_GIT_DIR is required to be configured"
+    fi
+    if [ ! -d "${TB_GIT_DIR?}" ] ; then
+        die "TB_GIT_DIR:${TB_GIT_DIR?} is not a directory"
+    fi
+    if [ ! -d "${TB_GIT_DIR?}/.git" ] ; then
+        die "TB_GIT_DIR:${TB_GIT_DIR?} is not a git repo"
+    fi
+    if [ -z "${TB_GERRIT_PLATFORM}" ] ; then
         os=$(uname)
         case "$os" in
             *Linux*)
-                tb_GERRIT_PLATFORM="Linux"
+                TB_GERRIT_PLATFORM="Linux"
                 ;;
             Darwin)
-                tb_GERRIT_PLATFORM="MacOSX"
+                TB_GERRIT_PLATFORM="MacOSX"
                 ;;
             CYGWIN*)
-                tb_GERRIT_PLATFORM="Windows"
+                TB_GERRIT_PLATFORM="Windows"
                 ;;
         esac
-    fi
-
-    if [ -z "${tb_MODE}" ] ; then
-        tb_MODE="${TB_DEFAULT_MODE:-tb}"
-    fi
-
-    if [ -z "${tb_DUAL_PRIORITY}" ] ; then
-        tb_DUAL_PRIORITY="${TB_DUAL_PRIORITY:-fair}"
-    fi
-
-    if [ -z "${tb_BRANCHES}" ] ; then
-        tb_BRANCHES="${TB_BRANCHES}"
-        if [ -z "${tb_BRANCHES}" ] ; then
-            log_msgs "TB_BRANCHES and -b not specified. Default to 'master'"
-            tb_BRANCHES="master"
+        if [ -z "${TB_GERRIT_PLATFORM}" ] ; then
+            die "Could not determine gerrit platform for ${os}"
         fi
     fi
 }
 
-source_branch_level_config()
+validate_tb_profile()
 {
-    local b="$1"
-    local t="$2"
+    local p="$1"
 
-    if [ -f "${tb_PROFILE_DIR?}/branches/${b?}/config" ] ; then
-        source "${tb_PROFILE_DIR?}/branches/${b?}/config"
+    if [ -z "${TB_NAME}" ] ; then
+        die "TB_NAME is required to be configured"
     fi
-    if [ -f "${tb_PROFILE_DIR?}/branches/${b?}/config_${t?}" ] ; then
-        source "${tb_PROFILE_DIR?}/branches/${b?}/config_${t?}"
+    if [ -z "${TB_OWNER}" ] ; then
+        die "TB_OWNER is required to be configured"
+    fi
+    if [ -z "${TB_BRANCH}" ] ; then
+        die "TB_BRANCH is required to be configured"
+    fi
+    if [ -z "${TB_NAME}" ] ; then
+        die "TB_NAME is required to be configured"
     fi
-    # we have verified the branch before so that should work
     if [ -z "${TB_TINDERBOX_BRANCH}" ] ; then
-        TB_TINDERBOX_BRANCH=$(determine_default_tinderbox_branch "${b?}")
+        TB_TINDERBOX_BRANCH=$(determine_default_tinderbox_branch "${TB_BRANCH?}")
     fi
-    if [ -f "${tb_PROFILE_DIR?}/branches/${b?}/phase.sh" ] ; then
-        source "${tb_PROFILE_DIR?}/branches/${b?}/phase.sh"
+    if [ -z "${TB_TINDERBOX_BRANCH}" ] ; then
+        die "TB_TINDERBOX_BRANCH is required to be configured"
     fi
-    if [ -f "${tb_PROFILE_DIR?}/branches/${b?}/phase_${t?}.sh" ] ; then
-        source "${tb_PROFILE_DIR?}/branches/${b?}/phase_${t?}.sh"
+    if [ -z "${TB_GIT_DIR}" ] ; then
+        die "TB_GIT_DIR is required to be configured"
+    fi
+    if [ ! -d "${TB_GIT_DIR?}" ] ; then
+        die "TB_GIT_DIR:${TB_GIT_DIR?} is not a directory"
+    fi
+    if [ ! -d "${TB_GIT_DIR?}/.git" ] ; then
+        die "TB_GIT_DIR:${TB_GIT_DIR?} is not a git repo"
+    fi
+    if [ -n "$TB_BUILD_DIR" ] ; then
+        if [ ! -d "${TB_BUILD_DIR}" ] ; then
+            die "TB_BULD_DIR:${TB_BUILD_DIR?} is not a directory"
+        fi
     fi
-}
-
-#
-# Verify the coherence of the command line arguments
-#
-verify_command()
-{
-local rc
-
-    case "${tb_MODE?}" in
-        dual)
-            if [ -z "$tb_GERRIT_PLATFORM" ] ; then
-                die "tb_GERRIT_PLATFORM is required for mode involving gerrit"
-            fi
-            case "${tb_DUAL_PRIORITY?}" in
-                fair|gerrit|tb)
-                    ;;
-                *)
-                    log_msgs "TB_DUAL_PRIORITY:${tb_DUAL_PRIORITY?} is not a valid value, defaulting to 'fair'"
-                    tb_DUAL_PRIORITY="fair"
-                    ;;
-            esac
-            ;;
-        gerrit)
-            if [ -z "$tb_GERRIT_PLATFORM" ] ; then
-                die "tb_GERRIT_PLATFORM is required for mode involving gerrit"
-            fi
-            ;;
-        gerrit-patch)
-            tb_SEND_MAIL="none"
-            tb_PUSH_NIGHTLIES=0
-            ;;
-        tb)
-            if [ "${tb_ONE_SHOT?}" = "1" ] ; then
-                tb_SEND_MAIL="none"
-                tb_TB_BRANCHES="${tb_BRANCHES?}"
-                B=$(get_first_branche ${tb_BRANCHES?})
-                if [ "${tb_PUSH_NIGHTLIES}" = "1" ] ; then
-                    rm -f "${METADATA_DIR?}/${P?}_${B?}_last-upload-day.txt"
-                fi
-            fi
-            ;;
-        *)
-            die "Invalid mode $tb_MODE"
-            ;;
-    esac
-
 
     if [ -z "${tb_SEND_MAIL}" ] ; then
         tb_SEND_MAIL="${TB_SEND_MAIL}"
@@ -1636,12 +1325,13 @@ local rc
         none)
             ;;
         *)
-            die "Invalid -m/TB_SEND_MAIL argument:${tb_SEND_MAIL}"
+            die "Invalid TB_SEND_MAIL argument:${tb_SEND_MAIL}"
             ;;
     esac
 
 }
 
+
 # Do we have timeout? If yes, guard git pull with that - which has a
 # tendency to hang forever, when connection is flaky
 if which timeout > /dev/null 2>&1 ; then
diff --git a/tb/tb_phases.sh b/tb/tb_phases.sh
index 7472198..aeb4181 100644
--- a/tb/tb_phases.sh
+++ b/tb/tb_phases.sh
@@ -22,9 +22,11 @@ pre_autogen()
 canonical_do_autogen()
 {
     if [ "${R}" = "0" ] ; then
-        if ! ${TB_NICE} ${TB_GIT_DIR?}/autogen.sh > "tb_${B}_autogen.log" 2>&1 ; then
-            tb_REPORT_LOG=tb_${B}_autogen.log
+        if ! ${TB_NICE} ${TB_GIT_DIR?}/autogen.sh > "tb_${P?}_autogen.log" 2>&1 ; then
+            tb_REPORT_LOG=tb_${P?}_autogen.log
             tb_REPORT_MSGS="autogen/configure failed - error is:"
+            [ $V ] && echo "autogen failed"
+            [ $V ] && cat tb_${P?}_autogen.log
             R=1
         fi
     fi
@@ -55,8 +57,8 @@ pre_clean()
 canonical_do_clean()
 {
     if [ "${R}" = "0" ] ; then
-        if ! ${TB_NICE} ${TB_WATCHDOG} ${MAKE?} -sr clean > "tb_${B?}_clean.log" 2>&1 ; then
-            tb_REPORT_LOG="tb_${B?}_clean.log"
+        if ! ${TB_NICE} ${TB_WATCHDOG} ${MAKE?} -sr clean > "tb_${P?}_clean.log" 2>&1 ; then
+            tb_REPORT_LOG="tb_${P?}_clean.log"
             tb_REPORT_MSGS="cleaning up failed - error is:"
             R=1
         fi
@@ -80,21 +82,23 @@ local optdir=""
 local extra_buildid=""
 
     tb_OPT_DIR=""
-    if [ "${tb_BUILD_TYPE?}" = "tb" ] ; then
-        current_timestamp=$(sed -e "s/ /_/" "${TB_METADATA_DIR?}/${P?}_${B}_current-git-timestamp.log")
-        extra_buildid="TinderBox: ${TB_NAME?}, Branch:${B}, Time: $current_timestamp"
+    if [ "${TB_TYPE?}" = "tb" ] ; then
+        current_timestamp=$(sed -e "s/ /_/" "${TB_METADATA_DIR?}/${P?}_current-git-timestamp.log")
+        extra_buildid="TinderBox: ${TB_NAME?}, Branch:${TB_BRANCH?}, Time: $current_timestamp"
     fi
     if [ "${R}" = "0" ] ; then
         export EXTRA_BUILDID="$extra_buildid"
-        if ! ${TB_NICE} ${TB_WATCHDOG} ${MAKE?} -sr > "tb_${B?}_build.log" 2>&1 ; then
-            tb_REPORT_LOG="tb_${B?}_build.log"
+        if ! ${TB_NICE} ${TB_WATCHDOG} ${MAKE?} -sr > "tb_${P?}_build.log" 2>&1 ; then
+            tb_REPORT_LOG="tb_${P?}_build.log"
             tb_REPORT_MSGS="build failed - error is:"
+            [ $V ] && echo "make failed :"
+            [ $V ] && cat tb_${P?}_build.log
             R=1
         else
             # if we want to populate bibisect we need to 'install'
-            if [ "${tb_BUILD_TYPE?}" = "tb" -a ${TB_BIBISECT} != "0" ] ; then
-                if ! ${TB_NICE} ${TB_WATCHDOG} ${MAKE?} -sr install-tb >>"tb_${B?}_build.log" 2>&1 ; then
-                    tb_REPORT_LOG="tb_${B}_build.log"
+            if [ "${TB_TYPE?}" = "tb" -a ${TB_BIBISECT} != "0" ] ; then
+                if ! ${TB_NICE} ${TB_WATCHDOG} ${MAKE?} -sr install-tb >>"tb_${P?}_build.log" 2>&1 ; then
+                    tb_REPORT_LOG="tb_${P}_build.log"
                     tb_REPORT_MSGS="build failed - error is:"
                     R=1
                 else
@@ -112,16 +116,11 @@ do_make()
 
 canonical_post_make()
 {
-    if [ "${tb_BUILD_TYPE?}" = "tb" ] ; then
+    if [ "${TB_TYPE?}" = "tb" ] ; then
         if [ "${R}" != "0" ] ; then
             if [ -f "${tb_REPORT_LOG?}" ] ; then
-                if [ -f "${tb_PROFILE_DIR?}/branches/${B?}/false_negatives" ] ; then
-                    grep -F "$(cat "${tb_PROFILE_DIR?}/branhces/${B?}/false_negatives")" "${tb_REPORT_LOG?}" && R="2"
-                    if [ "${R?}" == "2" ] ; then
-                        log_msgs "False negative detected"
-                    fi
-                elif [ -f "${tb_PROFILE_DIR?}/false_negatives" ] ; then
-                    grep -F "$(cat "${tb_PROFILE_DIR?}/false_negatives")" "${tb_REPORT_LOG?}" && R="2"
+                if [ -f "${tb_CONFIG_DIR?}/profiles/${P?}false_negatives" ] ; then
+                    grep -F "$(cat "${tb_CONFIG_DIR?}/profiles/${P?}/false_negatives")" "${tb_REPORT_LOG?}" && R="2"
                     if [ "${R?}" == "2" ] ; then
                         log_msgs "False negative detected"
                     fi
@@ -145,8 +144,8 @@ canonical_do_test()
 {
     if [ "${R}" = "0" ] ; then
         if [ "${TB_DO_TESTS}" = "1" ] ; then
-            if ! ${TB_NICE} ${TB_WATCHDOG} ${MAKE?} -sr check > "tb_${B?}_tests.log" 2>&1 ; then
-                tb_REPORT_LOG="tb_${B?}_tests.log"
+            if ! ${TB_NICE} ${TB_WATCHDOG} ${MAKE?} -sr check > "tb_${P?}_tests.log" 2>&1 ; then
+                tb_REPORT_LOG="tb_${P?}_tests.log"
                 tb_REPORT_MSGS="check failed - error is:"
                 R=1
             fi
@@ -177,7 +176,7 @@ canonical_do_push()
         return 0;
     fi
 
-    if [ "${tb_BUILD_TYPE?}" = "tb" ] ; then
+    if [ "${TB_TYPE?}" = "tb" ] ; then
         # Push nightly build if needed
         if [ "$TB_PUSH_NIGHTLIES" = "1" ] ; then
             push_nightly
@@ -219,7 +218,7 @@ do_build()
 {
     local phases="$@"
     local p
-    [ $V ] && echo "do_build (${tb_BUILD_TYPE?}) phase_list=${phases?}"
+    [ $V ] && echo "do_build (${TB_TYPE?}) phase_list=${phases?}"
 
     for p in ${phases?} ; do
         [ $V ] && echo "phase $p"


More information about the Libreoffice-commits mailing list