btrc & btrd
authorMichael Wallner <mike@php.net>
Tue, 14 Jan 2014 16:24:50 +0000 (17:24 +0100)
committerMichael Wallner <mike@php.net>
Tue, 14 Jan 2014 16:24:50 +0000 (17:24 +0100)
24 files changed:
.gitignore
Makefile.am
TODO.md
bin/btr
bin/btrc [new file with mode: 0755]
bin/btrd [new file with mode: 0755]
configure.ac
curl.example.conf
php.example.conf
share/btr/btr.sh
share/btr/btrc.sh [new file with mode: 0644]
share/btr/btrd.sh [new file with mode: 0755]
share/btr/build/composer.mk
share/btr/build/gnu.mk
share/btr/build/pecl.mk
share/btr/build/php.mk
share/btr/common.sh [new file with mode: 0755]
share/btr/report/irc.mk
share/btr/report/mail.mk
share/btr/report/notify-send.mk
share/btr/report/twilio.mk
share/btr/source/cvs.mk
share/btr/source/git.mk
share/btr/source/svn.mk

index 8d174c97795ef581327e29e668a30433dd0e79b0..5c80847260b0b7b3e9e39a8e5425026f10311d14 100644 (file)
@@ -9,3 +9,5 @@ missing
 Makefile
 config.log
 config.status
 Makefile
 config.log
 config.status
+config.cache
+btr-?.?.*
index 3260af8ca8e3f20a5e94e369854a11b91b578408..9efa5a9eaedabf8f7217a56604d74d9a0db9b690 100644 (file)
@@ -1,18 +1,4 @@
-dist_bin_SCRIPTS = bin/btr \
-                   bin/btr-irc-relay \
-                   bin/btr-irc-send
+EXTRA_SCRIPTS =
 btrdir = $(prefix)
 btrdir = $(prefix)
-nobase_dist_btr_SCRIPTS = share/btr/build/pecl.mk \
-                          share/btr/build/make.mk \
-                          share/btr/build/gnu.mk \
-                          share/btr/build/php.mk \
-                          share/btr/build/composer.mk \
-                          share/btr/report/mail.mk \
-                          share/btr/report/twilio.mk \
-                          share/btr/report/notify-send.mk \
-                          share/btr/report/irc.mk \
-                          share/btr/source/cvs.mk \
-                          share/btr/source/git.mk \
-                          share/btr/source/svn.mk \
-                          share/btr/btr.sh \
-                          share/btr/irc.php
+dist_bin_SCRIPTS = $(BTR_BIN)
+nobase_dist_btr_SCRIPTS = $(BTR_SHARE)
diff --git a/TODO.md b/TODO.md
index 4b8ee4bd7d1839376d3a9ec4b1908f9d052c62d3..bbab2b08325e107899ad37e2f385df189f23a295 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -10,6 +10,8 @@
 * Mercurial  
   Implement!
 
 * Mercurial  
   Implement!
 
+* Push/commit etc. hooks
+
 # Build
 
 * CMake?
 # Build
 
 * CMake?
diff --git a/bin/btr b/bin/btr
index 6f303b7f21cd826fb10ac45736295215a1b7dfe9..a8a29a44701d1d0aa4f912578a943954d5872f92 100755 (executable)
--- a/bin/btr
+++ b/bin/btr
@@ -1,29 +1,21 @@
 #!/bin/bash
 
 #!/bin/bash
 
-export DATE=$(date +%Y%m%d%H%M%S)
-export CPUS=${CPUS:-$(grep -c "^processor" /proc/cpuinfo)}
+export BTR_BINDIR=$(realpath $(dirname $0)/)
+export BTR_LIBDIR=$(realpath $(dirname $0)/../share/btr)
+BTR_BANNER="Build, test & report. Simple and stupid."
 
 
-export BINDIR=$(realpath $(dirname $0)/)
-export LIBDIR=$(realpath $(dirname $0)/../share/btr)
+. $BTR_LIBDIR/common.sh
+. $BTR_LIBDIR/btr.sh
 
 
-. $LIBDIR/btr.sh
+btr-parseopts "$@"
+btr-setup
 
 
-QUIET=false
-VERBOSE=false
-FORCEYES=false
-
-parseopts "$@"
-setup
-
-if $VERBOSE
+if $BTR_VERBOSE
 then
 then
-       show_conf
-       $FORCEYES || confirm "Everything setup. Do you want to continue?" || exit
+       btr-conf-show
+       btr-confirm "Everything setup. Do you want to continue?"
 fi
 
 fi
 
-set -e
-make -e $SILENT_FLAG -C $BTRDIR -f $LIBDIR/source/$SOURCE_RULES.mk
-make -e $SILENT_FLAG -C $BTRDIR -f $LIBDIR/build/$BUILD_RULES.mk
-make -e $SILENT_FLAG -C $BTRDIR -f $LIBDIR/report/$REPORT_RULES.mk
+btr-run
 
 # vim: noet
 
 # vim: noet
diff --git a/bin/btrc b/bin/btrc
new file mode 100755 (executable)
index 0000000..85634bd
--- /dev/null
+++ b/bin/btrc
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+export BTR_BINDIR=$(realpath $(dirname $0)/)
+export BTR_LIBDIR=$(realpath $(dirname $0)/../share/btr)
+BTR_BANNER="Control \`btrd\` daemons."
+
+. $BTR_LIBDIR/common.sh
+. $BTR_LIBDIR/btrc.sh
+
+btrc-parseopts "$@"
+btrc-setup
+
+case "$BTR_ACTION" in
+status)
+       ncat --recv-only -U "$BTR_COMFILE"
+       ;;
+cancel)
+       btrc-signal INT
+       ;;
+run)
+       btrc-signal HUP
+       ;;
+term)
+       btrc-signal TERM
+       ;;
+esac
+
+# vim: noet
diff --git a/bin/btrd b/bin/btrd
new file mode 100755 (executable)
index 0000000..055bd7b
--- /dev/null
+++ b/bin/btrd
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+export BTR_BINDIR=$(realpath $(dirname $0)/)
+export BTR_LIBDIR=$(realpath $(dirname $0)/../share/btr)
+BTR_BANNER="Run btr as background daemon receiving jobs for a repo."
+
+. $BTR_LIBDIR/common.sh
+. $BTR_LIBDIR/btr.sh
+
+btr-parseopts "$@"
+btr-setup
+
+if $BTR_VERBOSE
+then
+       btr-conf-show
+       btr-confirm "Everything setup. Do you want to start the daemon?"
+elif ! $BTR_QUIET
+then
+       echo "Starting the daemon. Control with \`btrc $BTR_BUILD\`"
+else
+       echo "$BUILD"
+fi
+
+setsid $SHELL -c "$BTR_LIBDIR/btrd.sh &"
+
+# vim: noet
index 0e51c879bdfeceb76f0604e8d6436b5fd3098fea..f5f981fe2424a3e8e0df206595cf7a0518fd6bf3 100644 (file)
@@ -1,6 +1,10 @@
-AC_INIT([btr], [1.0.0], [mike@php.net])
-AC_CONFIG_SRCDIR([share/btr/btr.sh])
+AC_INIT([btr], [0.4.0], [mike@php.net])
+AC_CONFIG_SRCDIR([./share/btr/btr.sh])
 AM_INIT_AUTOMAKE([foreign])
 AM_SILENT_RULES([yes])
 AM_INIT_AUTOMAKE([foreign])
 AM_SILENT_RULES([yes])
+BTR_BIN='$(echo $$abs_srcdir/bin/*)'
+BTR_SHARE='$(echo $$abs_srcdir/share/{*,*/*}/*.*)'
+AC_SUBST([BTR_BIN], [$BTR_BIN])
+AC_SUBST([BTR_SHARE], [$BTR_SHARE])
 AC_CONFIG_FILES([Makefile])
 AC_OUTPUT
 AC_CONFIG_FILES([Makefile])
 AC_OUTPUT
index 0039ed6dad90d761332d322c70edd6aa92f4303c..3f7c677ec475f59f771474a762113c912cddc854 100644 (file)
@@ -1,5 +1,5 @@
-VERBOSE=true
-SOURCE_RULES=git
-SOURCE_ARGS=https://github.com/bagder/curl.git
-BUILD_RULES=gnu
-REPORT_RULES=mail
+BTR_VERBOSE=true
+BTR_SOURCE_RULES=git
+BTR_SOURCE_ARGS=https://github.com/bagder/curl.git
+BTR_BUILD_RULES=gnu
+BTR_REPORT_RULES=mail
index 4a1bd1013bcc5906661b2c9fd60c26d954f6ec62..c52ad8b26215abb83caaca0d6e1e46d4f15d2ed0 100644 (file)
@@ -1,7 +1,7 @@
-SOURCE_RULES=git
-SOURCE_ARGS=git@php.net:php/php-src.git
-BRANCH=PHP-5.5
-BUILD_RULES=php
-BUILD_ARGS=--enable-debug
-TEST_ARGS=-m
-REPORT_RULES=notify-send
+BTR_SOURCE_RULES=git
+BTR_SOURCE_ARGS=git@php.net:php/php-src.git
+BTR_BRANCH=PHP-5.5
+BTR_BUILD_RULES=php
+BTR_BUILD_ARGS=--enable-debug
+BTR_TEST_ARGS=-m
+BTR_REPORT_RULES=notify-send
index d0db0953cab4837a538e102f4d0c3fba647f0aba..91bd80102e485820ec93efa1ee56c1eb9a8811d7 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #!/bin/sh
 
-function help {
-       echo "btr v0.3.0, (c) Michael Wallner <mike@php.net>"
+function btr-help {
+       btr-banner
        echo
        echo "Usage: $(basename $0) [-hyvqcC] [<options>]"
        echo
        echo
        echo "Usage: $(basename $0) [-hyvqcC] [<options>]"
        echo
@@ -34,7 +34,7 @@ function help {
        for ruleset in source build report
        do
                printf "    %10s: %s\n" $ruleset \
        for ruleset in source build report
        do
                printf "    %10s: %s\n" $ruleset \
-                       "$(find "$LIBDIR/$ruleset" -name '*.mk' -exec basename {} .mk \; | sort | xargs)"
+                       "$(find "$BTR_LIBDIR/$ruleset" -name '*.mk' -exec basename {} .mk \; | sort | xargs)"
        done
        echo
        echo "  Examples:"
        done
        echo
        echo "  Examples:"
@@ -54,8 +54,9 @@ function help {
        echo
        exit
 }
        echo
        exit
 }
+export -f btr-help
 
 
-function parseopts {
+function btr-parseopts {
        local shortoptions="hvqycCf:T:B:D:S:s:b:r:"
        local longoptions="help,verbose,quiet,yes,clean,vcsclean,config:,test:,branch:,directory:,suffix:,source:,build:,report:"
        local options=$(getopt \
        local shortoptions="hvqycCf:T:B:D:S:s:b:r:"
        local longoptions="help,verbose,quiet,yes,clean,vcsclean,config:,test:,branch:,directory:,suffix:,source:,build:,report:"
        local options=$(getopt \
@@ -74,24 +75,24 @@ function parseopts {
        do
                case "$1" in
                        -h|--help)
        do
                case "$1" in
                        -h|--help)
-                               help
+                               btr-help
                                ;;
                        -v|--verbose)
                                ;;
                        -v|--verbose)
-                               QUIET=false
-                               VERBOSE=true
+                               BTR_QUIET=false
+                               BTR_VERBOSE=true
                                ;;
                        -q|--quiet)
                                ;;
                        -q|--quiet)
-                               QUIET=true
-                               VERBOSE=false
+                               BTR_QUIET=true
+                               BTR_VERBOSE=false
                                ;;
                        -y|--yes)
                                ;;
                        -y|--yes)
-                               FORCEYES=true
+                               BTR_FORCEYES=true
                                ;;
                        -c|--clean)
                                ;;
                        -c|--clean)
-                               BUILD_CLEAN=true
+                               BTR_BUILD_CLEAN=true
                                ;;
                        -C|--vcsclean)
                                ;;
                        -C|--vcsclean)
-                               SOURCE_CLEAN=true
+                               BTR_SOURCE_CLEAN=true
                                ;;
                        ####
                        -f|--config)
                                ;;
                        ####
                        -f|--config)
@@ -100,46 +101,46 @@ function parseopts {
                                ;;
                        ####
                        -B|--branch)
                                ;;
                        ####
                        -B|--branch)
-                               BRANCH="$2"
+                               BTR_BRANCH="$2"
                                shift
                                ;;
                        -D|--directory)
                                shift
                                ;;
                        -D|--directory)
-                               BTRDIR="$2"
+                               BTR_RUNDIR="$2"
                                shift
                                ;;
                        -S|--suffix)
                                shift
                                ;;
                        -S|--suffix)
-                               SUFFIX="$2"
+                               BTR_SUFFIX="$2"
                                shift
                                ;;
                        -T|--test)
                                shift
                                ;;
                        -T|--test)
-                               TEST_ARGS="$2"
+                               BTR_TEST_ARGS="$2"
                                shift
                                ;;
                        ####
                        -s|--source)
                                case "$2" in
                                git*)
                                shift
                                ;;
                        ####
                        -s|--source)
                                case "$2" in
                                git*)
-                                       test -z "$BRANCH" && BRANCH=master
+                                       test -z "$BTR_BRANCH" && BTR_BRANCH=master
                                        ;;
                                svn*)
                                        ;;
                                svn*)
-                                       test -z "$BRANCH" && BRANCH=trunk
+                                       test -z "$BTR_BRANCH" && BTR_BRANCH=trunk
                                        ;;
                                cvs*)
                                        ;;
                                cvs*)
-                                       test -z "$BRANCH" && BRANCH=HEAD
+                                       test -z "$BTR_BRANCH" && BTR_BRANCH=HEAD
                                        ;;
                                esac
                                        ;;
                                esac
-                               SOURCE_RULES="$(cut -d= -f1 <<<$2)"
-                               SOURCE_ARGS="$(cut -s -d= -f2- <<<$2)"
+                               BTR_SOURCE_RULES="$(cut -d= -f1 <<<$2)"
+                               BTR_SOURCE_ARGS="$(cut -s -d= -f2- <<<$2)"
                                shift
                                ;;
                        -b|--build)
                                shift
                                ;;
                        -b|--build)
-                               BUILD_RULES="$(cut -d= -f1 <<<$2)"
-                               BUILD_ARGS="$(cut -s -d= -f2- <<<$2)"
+                               BTR_BUILD_RULES="$(cut -d= -f1 <<<$2)"
+                               BTR_BUILD_ARGS="$(cut -s -d= -f2- <<<$2)"
                                shift
                                ;;
                        -r|--report)
                                shift
                                ;;
                        -r|--report)
-                               REPORT_RULES="$(cut -d= -f1 <<<$2)"
-                               REPORT_ARGS="$(cut -s -d= -f2- <<<$2)"
+                               BTR_REPORT_RULES="$(cut -d= -f1 <<<$2)"
+                               BTR_REPORT_ARGS="$(cut -s -d= -f2- <<<$2)"
                                shift
                                ;;
                        ####
                                shift
                                ;;
                        ####
@@ -147,7 +148,7 @@ function parseopts {
                                # legacy
                                if test "$2"
                                then
                                # legacy
                                if test "$2"
                                then
-                                       SOURCE_ARGS="$2"
+                                       BTR_SOURCE_ARGS="$2"
                                fi
                                shift
                                ;;
                                fi
                                shift
                                ;;
@@ -155,122 +156,107 @@ function parseopts {
                shift
        done
 }
                shift
        done
 }
+export -f btr-parseopts
 
 
-function error {
-       echo "$@" >&2
-       exit
-}
-
-function setup {
-       if test -z "$SOURCE_RULES" -o -z "$BUILD_RULES" -o -z "$REPORT_RULES"
+function btr-setup {
+       if test -z "$BTR_SOURCE_RULES" -o -z "$BTR_BUILD_RULES" -o -z "$BTR_REPORT_RULES"
        then
        then
-               help
+               btr-help
        fi
 
        fi
 
-       if $VERBOSE
-       then
-               QUIET_FLAG=
-               SILENT_FLAG=
-               VERBOSE_FLAG="-v"
-               SAY="echo; echo"
-       elif $QUIET
-       then
-               QUIET_FLAG="-q"
-               SILENT_FLAG="-s"
-               VERBOSE_FLAG=
-               SAY="@true"
-       else
-               QUIET_FLAG=
-               SILENT_FLAG="-s"
-               VERBOSE_FLAG=
-               SAY="@echo"
-       fi
-       
-       export QUIET VERBOSE FORCEYES QUIET_FLAG SILENT_FLAG VERBOSE_FLAG SAY
-       
-       if test -z "$BTRDIR"
-       then
-               export BTRDIR="/tmp/btr"
-       else
-               export BTRDIR=$(realpath "$BTRDIR")
-       fi
-       
-       mkdir -p "$BTRDIR" || error "Could not create $BTRDIR"
+       btr-setup-verbosity true
+       btr-setup-rundir
 
 
-       
-       export SOURCE_RULES BUILD_RULES REPORT_RULES
-       test -z "$SOURCE_ARGS"  || export SOURCE_ARGS
-       test -z "$SOURCE_CLEAN" || export SOURCE_CLEAN
-       test -z "$BUILD_ARGS"   || export BUILD_ARGS
-       test -z "$BUILD_CLEAN"  || export BUILD_CLEAN
-       test -z "$TEST_ARGS"    || export TEST_ARGS
-       test -z "$REPORT_ARGS"  || export REPORT_ARGS
-       REPO=$(basename $(sed -re 's~^.*[/:#]~~' <<<"$SOURCE_ARGS") .git)
-       SAFE_BRANCH=$(tr ":" "_" <<<$(basename "$BRANCH"))
-       export REPO BRANCH SAFE_BRANCH
+       export BTR_SOURCE_RULES BTR_BUILD_RULES BTR_REPORT_RULES
+       test -z "$BTR_SOURCE_ARGS"  || export BTR_SOURCE_ARGS
+       test -z "$BTR_SOURCE_CLEAN" || export BTR_SOURCE_CLEAN
+       test -z "$BTR_BUILD_ARGS"   || export BTR_BUILD_ARGS
+       test -z "$BTR_BUILD_CLEAN"  || export BTR_BUILD_CLEAN
+       test -z "$BTR_TEST_ARGS"    || export BTR_TEST_ARGS
+       test -z "$BTR_REPORT_ARGS"  || export BTR_REPORT_ARGS
+       BTR_REPO=$(basename $(sed -re 's~^.*[/:#]~~' <<<"$BTR_SOURCE_ARGS") .git)
+       BTR_SAFE_BRANCH=$(tr ":/" "_" <<<$(basename "$BTR_BRANCH"))
+       export BTR_REPO BTR_BRANCH BTR_SAFE_BRANCH
 
 
-       if test -z "$SUFFIX"
+       if test -z "$BTR_SUFFIX"
        then
        then
-               export BUILD="$REPO@$SAFE_BRANCH"
+               export BTR_BUILD="$BTR_REPO@$BTR_SAFE_BRANCH"
        else
        else
-               export BUILD="$REPO@$SAFE_BRANCH-$SUFFIX"
+               export BTR_BUILD="$BTR_REPO@$BTR_SAFE_BRANCH-$BTR_SUFFIX"
        fi
 
        fi
 
-       export CLEAN_DIR="btr+clean-$REPO"
-       export BRANCH_DIR="btr+branch-$REPO@$SAFE_BRANCH"
-       export BUILD_DIR="btr+build-$BUILD"
-       export CONFIG_REPORT="btr+config-$BUILD-$DATE"
-       export BUILD_REPORT="btr+build-$BUILD-$DATE"
-       export TEST_REPORT="btr+tests-$BUILD-$DATE"
-       export LAST_REPORT=$(basename $(ls -t "$BTRDIR/btr+tests-$BUILD"* 2>/dev/null | head -n1) 2>/dev/null)
-       export REPORT="btr+report-$BUILD-$DATE"
+       export BTR_REPO_DIR="$BTR_REPO"
+       export BTR_BRANCH_DIR="$BTR_BUILD/checkout"
+       export BTR_BUILD_DIR="$BTR_BUILD/build"
+       export BTR_LOG_DIR="$BTR_BUILD/log"
+       export BTR_CONFIG_REPORT="$BTR_LOG_DIR/config@$DATE.log"
+       export BTR_BUILD_REPORT="$BTR_LOG_DIR/build@$DATE.log"
+       export BTR_TEST_REPORT="$BTR_LOG_DIR/test@$DATE.log"
+       export BTR_LAST_REPORT=$(basename $(ls -t "$BTR_RUNDIR/$BTR_LOG_DIR/test@"* 2>/dev/null | head -n1) 2>/dev/null)
+       export BTR_REPORT="$BTR_LOG_DIR/report@$DATE.log"
 }
 }
+export -f btr-setup
 
 
-function show_conf {
-       echo
-       echo "Configuration:"
-       echo "=============="
+function btr-conf-dump {
+       echo "BTR_QUIET='$BTR_QUIET'"
+       echo "BTR_VERBOSE='$BTR_VEROSE'"
+       echo "BTR_FORCEYES='$BTR_FORCEYES'"
+       echo "BTR_BRANCH='$BTR_BRANCH'"
+       echo "BTR_SUFFIX='$BTR_SUFFIX'"
+       echo "BTR_RUNDIR='$BTR_RUNDIR'"
+       echo "BTR_SOURCE_RULES='$BTR_SOURCE_RULES'"
+       test ${BTR_SOURCE_ARGS+defined} && echo "BTR_SOURCE_ARGS='$BTR_SOURCE_ARGS'"
+       test ${BTR_SOURC_CLEAN+defined} && echo "BTR_SOURCE_CLEAN='$BTR_SOURCE_CLEAN'"
+       echo "BTR_BUILD_RULES='$BTR_BUILD_RULES'"
+       test ${BTR_BUILD_ARGS+defined}  && echo "BTR_BUILD_ARGS='$BTR_BUILD_ARGS'"
+       test ${BTR_BUILD_CLEAN+defined} && echo "BTR_BUILD_CLEAN='$BTR_BUILD_CLEAN'"
+       test ${BTR_TEST_ARGS+defined}   && echo "BTR_TEST_ARGS='$BTR_TEST_ARGS'"
+       echo "BTR_REPORT_RULES='$BTR_REPORT_RULES'"
+       test ${BTR_REPORT_ARGS+defined} && echo "BTR_REPORT_ARGS='$BTR_REPORT_ARGS'"
+}
+export -f btr-conf-dump
+
+function btr-conf-show {
        echo
        echo
-       echo "BTRDIR         = $BTRDIR"
-       echo "BINDIR         = $BINDIR"
-       echo "LIBDIR         = $LIBDIR"
+       echo "# Configuration:"
        echo
        echo
-       echo "SOURCE_RULES   = $SOURCE_RULES"
-       echo "SOURCE_ARGS    = $SOURCE_ARGS"
-       echo "SOURCE_CLEAN   = $SOURCE_CLEAN"
-       echo "BUILD_RULES    = $BUILD_RULES"
-       echo "BUILD_ARGS     = $BUILD_ARGS"
-       echo "BUILD_CLEAN    = $BUILD_CLEAN"
-       echo "TEST_ARGS      = $TEST_ARGS"
-       echo "REPORT_RULES   = $REPORT_RULES"
-       echo "REPORT_ARGS    = $REPORT_ARGS"
+       echo "BTR_RUNDIR         = $BTR_RUNDIR"
+       echo "BTR_BINDIR         = $BTR_BINDIR"
+       echo "BTR_LIBDIR         = $BTR_LIBDIR"
        echo
        echo
-       echo "REPO           = $REPO"
-       echo "BRANCH         = $BRANCH"
-       echo "SAFE_BRANCH    = $SAFE_BRANCH"
+       echo "BTR_SOURCE_RULES   = $BTR_SOURCE_RULES"
+       echo "BTR_SOURCE_ARGS    = $BTR_SOURCE_ARGS"
+       echo "BTR_SOURCE_CLEAN   = $BTR_SOURCE_CLEAN"
+       echo "BTR_BUILD_RULES    = $BTR_BUILD_RULES"
+       echo "BTR_BUILD_ARGS     = $BTR_BUILD_ARGS"
+       echo "BTR_BUILD_CLEAN    = $BTR_BUILD_CLEAN"
+       echo "BTR_TEST_ARGS      = $BTR_TEST_ARGS"
+       echo "BTR_REPORT_RULES   = $BTR_REPORT_RULES"
+       echo "BTR_REPORT_ARGS    = $BTR_REPORT_ARGS"
+       echo "BTR_REPO           = $BTR_REPO"
+       echo "BTR_BRANCH         = $BTR_BRANCH"
+       echo "BTR_SAFE_BRANCH    = $BTR_SAFE_BRANCH"
+       echo "BTR_BUILD          = $BTR_BUILD"
        echo
        echo
-       echo "CLEAN_DIR      = $CLEAN_DIR"
-       echo "BRANCH_DIR     = $BRANCH_DIR"
-       echo "BUILD_DIR      = $BUILD_DIR"
-       echo "CONFIG_REPORT  = $CONFIG_REPORT"
-       echo "BUILD_REPORT   = $BUILD_REPORT"
-       echo "TEST_REPORT    = $TEST_REPORT"
-       echo "LAST_REPORT    = $LAST_REPORT"
+       echo "BTR_REPO_DIR       = $BTR_REPO_DIR"
+       echo "BTR_BRANCH_DIR     = $BTR_BRANCH_DIR"
+       echo "BTR_BUILD_DIR      = $BTR_BUILD_DIR"
+       echo "BTR_LOG_DIR        = $BTR_LOG_DIR"
+       echo "BTR_CONFIG_REPORT  = $BTR_CONFIG_REPORT"
+       echo "BTR_BUILD_REPORT   = $BTR_BUILD_REPORT"
+       echo "BTR_TEST_REPORT    = $BTR_TEST_REPORT"
+       echo "BTR_LAST_REPORT    = $BTR_LAST_REPORT"
        echo
 }
        echo
 }
+export -f btr-conf-show
 
 
-function confirm {
-       local CONTINUE
-       echo -n "$1 (y/N) "
-       read -r CONTINUE
-       case $CONTINUE in
-               y*|Y*)
-                       echo
-                       ;;
-               *)
-                       exit -1
-                       ;;
-       esac
+function btr-run {
+       set -e
+       make -e $BTR_SILENT_FLAG -C $BTR_RUNDIR -f $BTR_LIBDIR/source/$BTR_SOURCE_RULES.mk
+       make -e $BTR_SILENT_FLAG -C $BTR_RUNDIR -f $BTR_LIBDIR/build/$BTR_BUILD_RULES.mk
+       make -e $BTR_SILENT_FLAG -C $BTR_RUNDIR -f $BTR_LIBDIR/report/$BTR_REPORT_RULES.mk
+       set +e
 }
 }
+export -f btr-run
 
 # vim: noet
 
 # vim: noet
diff --git a/share/btr/btrc.sh b/share/btr/btrc.sh
new file mode 100644 (file)
index 0000000..703a909
--- /dev/null
@@ -0,0 +1,159 @@
+#!/bin/bash
+
+function btrc-help {
+       btr-banner
+       echo
+       echo "Usage: $(basename $0) [-hyvq] [<options>] [action] <build>"
+       echo
+       echo "    -h, --help                Display this help"
+       echo "    -y, --yes                 Always assume yes"
+       echo "    -v, --verbose             Be more verbose"
+       echo "    -q, --quiet               Be more quiet"
+       echo
+       echo "  Options:"
+       echo "    -D, --directory=<directory>"
+       echo "                              Use this directory as work root"
+       echo
+       echo "  Actions:"
+       echo "    s[tatus]                  Show the status of the build"
+       echo "    r[un]                     Make a BTR run"
+       echo "    c[ancel]                  Cancel any currently running BTR job"
+       echo "    t[erminate]               Terminate the BTR daemon"
+       echo
+       echo "  Arguments:"
+       echo "    <build>                   The build id of the \`btrd\` daemon, usually"
+       echo "                              something like \$repository@\$branch[-\$suffix]."
+       echo
+       exit
+}
+export -f btrc-help
+
+function btrc-parseargs {
+       while test $# -gt 0
+       do
+               case "$1" in
+               s|st|sta|stat|statu|status)
+                       BTR_ACTION=status
+                       ;;
+               r|ru|run)
+                       BTR_ACTION=run
+                       ;;
+               c|ca|can|cancel)
+                       BTR_ACTION=cancel
+                       ;;
+               t|te|ter|term|termi|termin|termina|terminat|terminate)
+                       BTR_ACTION=term
+                       ;;
+               *)
+                       if test -z "$BTR_BUILD"
+                       then
+                               BTR_BUILD="$1"
+                       else
+                               error "Unknown action: '$BTR_BUILD' for build id '$1'!"
+                       fi
+                       ;;
+               esac
+               shift
+       done
+}
+
+function btrc-parseopts {
+       local shortoptions="hvqyD:"
+       local longoptions="help,verbose,quiet,yes,directory:"
+       local options=$(getopt \
+               --options "$shortoptions" \
+               --longoptions "$longoptions" \
+               -- "$@" \
+       )
+
+       if test $? -ne 0 ; then
+               btrc-help
+       fi
+       
+       eval set -- "$options"
+       
+       while test $# -gt 1
+       do
+               case "$1" in
+               -h|--help)
+                       btrc-help
+                       ;;
+               -y|--yes)
+                       BTR_FORCEYES=true
+                       ;;
+               -v|--verbose)
+                       BTR_VERBOSE=true
+                       BTR_QUIET=false
+                       ;;
+               -q|--quiet)
+                       BTR_QUIET=true
+                       BTR_VERBOSE=false
+                       ;;
+               #
+               -d|--directory)
+                       BTR_RUNDIR="$2"
+                       shift
+                       ;;
+               #
+               --)
+                       shift
+                       btrc-parseargs "$@"
+               esac
+               shift
+       done
+}
+export -f btrc-parseopts
+
+function btrc-setup {
+       if test -z "$BTR_BUILD"
+       then
+               btrc-help
+       fi
+       
+       if test -z "$BTR_ACTION"
+       then
+               BTR_ACTION=status
+       fi
+       
+       btr-setup-rundir
+       btr-setup-verbosity
+       
+       BTR_PIDFILE="$BTR_RUNDIR/$BTR_BUILD.pid"
+       BTR_LOGFILE="$BTR_RUNDIR/$BTR_BUILD.log"
+       BTR_COMFILE="$BTR_RUNDIR/$BTR_BUILD.socket"
+       
+       if test -r "$BTR_PIDFILE"
+       then
+               export BTR_PIDFILE BTR_LOGFILE BTR_COMFILE
+       else
+               if test -e "$BTR_LOGFILE"
+               then
+                       cat "$BTR_LOGFILE"
+                       echo
+               fi
+               error "Could not find pid file of btr daemon for '$BTR_BUILD' in $BTR_RUNDIR."
+       fi
+}
+export -f btrc-setup
+
+function btrc-signal {
+       local sig=$1
+       local pid=$(cat "$BTR_PIDFILE")
+       kill -s $sig $pid
+       kill -s CONT $pid
+       case "$sig" in
+       TERM|SIGTERM|15)
+               $SAY -n "Waiting for the daemon to shutdown..."
+               while kill -s 0 $pid &>/dev/null
+               do
+                       $SAY -n "."
+                       sleep .1
+               done
+               $SAY " Done, bye."
+               ;;
+       esac
+}
+export -f btrc-signal
+
+
+# vim: noet
diff --git a/share/btr/btrd.sh b/share/btr/btrd.sh
new file mode 100755 (executable)
index 0000000..ca9f55c
--- /dev/null
@@ -0,0 +1,126 @@
+#!/bin/bash
+
+function btrd-start {
+       btrd-cancel
+       DATE=$(date +%Y%m%d%H%M%S)
+       btr-setup
+       btr-run &
+       BTR_WORKER=$!
+}
+export -f btrd-start
+
+function btrd-cancel {
+       if btrd-worker-started
+       then
+               kill $BTR_WORKER
+               wait $BTR_WORKER
+       fi
+       BTR_WORKER=0
+}
+export -f btrd-cancel
+
+function btrd-stop {
+       BTR_DAEMON=false
+}
+export -f btrd-stop
+
+function btrd-ctime {
+       stat -c %y "$1"
+}
+export -f btrd-ctime
+
+function btrd-fsize {
+       local bytes=$(stat -c %s "$1")
+}
+export -f btrd-fsize
+
+function btrd-status {
+       echo "BTR_BUILD='$BTR_BUILD'"
+       echo "BTR_SERVER='$BTR_SERVER'"
+       echo "BTR_PIDFILE='$BTR_PIDFILE'"
+       echo "BTR_LOGFILE='$BTR_LOGFILE'"
+       echo "BTR_COMFILE='$BTR_COMFILE'"
+}
+export -f btrd-status
+
+function btrd-logrotate {
+       local i=1
+       local f="$BTR_LOGFILE"
+       
+       if test -e "$f"
+       then
+               while test -e "$f.$i"
+               do 
+                       i=$((i+1))
+               done
+               mv "$f" "$f.$i"
+       fi
+       
+}
+export -f btrd-logrotate
+
+function btrd-worker-started {
+       test "$BTR_WORKER" -gt 1
+}
+export -f btrd-worker-started
+
+function btrd-worker-running {
+       kill -s 0 $BTR_WORKER
+}
+export -f btrd-worker-running
+
+function btrd-worker-reap {
+       wait $BTR_WORKER
+       BTR_WORKER=0
+}
+export -f btrd-worker-reap
+
+function btrd-worker-kill {
+       kill $BTR_WORKER
+}
+export -f btrd-worker-kill
+BTR_DAEMON=true
+BTR_WORKER=0
+BTR_SERVER=0
+BTR_PIDFILE="$BTR_RUNDIR/$BTR_BUILD.pid"
+BTR_LOGFILE="$BTR_RUNDIR/$BTR_BUILD.log"
+BTR_COMFILE="$BTR_RUNDIR/$BTR_BUILD.socket"
+
+export BTR_DAEMON BTR_WORKER BTR_SERVER BTR_PIDFILE BTR_LOGFILE BTR_COMFILE
+
+btrd-logrotate
+
+exec >"$BTR_LOGFILE" 2>&1
+echo $$ >"$BTR_PIDFILE"
+
+ncat -lkU -c btrd-status "$BTR_COMFILE" &
+BTR_SERVER=$!
+
+trap btrd-start HUP
+trap btrd-cancel INT
+trap btrd-stop TERM
+
+while $BTR_DAEMON
+do
+       if btrd-worker-started && btrd-worker-running
+       then
+               btrd-worker-reap
+       else
+               kill -s STOP $$
+       fi
+done
+
+btrd-cancel
+
+if test "$BTR_SERVER" -gt 1
+then
+       kill $BTR_SERVER
+       wait $BTR_SERVER
+fi
+
+test -e "$BTR_PIDFILE" && rm "$BTR_PIDFILE"
+test -e "$BTR_LOGFILE" && rm "$BTR_LOGFILE"
+test -S "$BTR_COMFILE" && rm "$BTR_COMFILE"
+
+# vim: noet
index f08e8e2844450e9ff60fa5ea3715ecb02150eeaa..ce190d03c2a5565c644fe2e2e3c43bec123ea271 100644 (file)
@@ -1,29 +1,29 @@
-BUILD_CLEAN=false
-BUILD_ARGS= install --dev
-TEST_ARGS= --strict --coverage-text
+BTR_BUILD_CLEAN=false
+BTR_BUILD_ARGS= install --dev
+BTR_TEST_ARGS= --strict --coverage-text
 
 .PHONY: all clean
 .SUFFIXES:
 
 
 .PHONY: all clean
 .SUFFIXES:
 
-all: clean $(REPORT)
-       $(SAY) "Result: $$(cat $(REPORT))"
+all: clean $(BTR_REPORT)
+       $(SAY) "Result: $$(cat $(BTR_REPORT))"
 
 
-clean: $(CONFIG_REPORT)
-       if $(BUILD_CLEAN); \
+clean: $(BTR_CONFIG_REPORT)
+       if $(BTR_BUILD_CLEAN); \
        then \
        then \
-               cd $(BUILD_DIR) && \
+               cd $(BTR_BUILD_DIR) && \
                        rm -rf vendor; \
        fi;
 
                        rm -rf vendor; \
        fi;
 
-$(REPORT): $(TEST_REPORT)
+$(BTR_REPORT): $(BTR_TEST_REPORT)
        @( \
        @( \
-               TESTS_PASSED=$$(grep -Pc '^ok \d+' < $(TEST_REPORT)); \
-               TESTS_FAILED=$$(grep -Pc '^not ok \d+' < $(TEST_REPORT)); \
+               TESTS_PASSED=$$(grep -Pc '^ok \d+' < $(BTR_TEST_REPORT)); \
+               TESTS_FAILED=$$(grep -Pc '^not ok \d+' < $(BTR_TEST_REPORT)); \
                \
                printf "%d/%d" $$TESTS_PASSED $$TESTS_FAILED >$@; \
                \
                printf "%d/%d" $$TESTS_PASSED $$TESTS_FAILED >$@; \
-               if test -s "$(LAST_REPORT)"; then \
-                       LAST_PASSED=$$(grep -Pc '^ok \d+' < $(LAST_REPORT)); \
-                       LAST_FAILED=$$(grep -Pc '^not ok \d+' < $(LAST_REPORT)); \
+               if test -s "$(BTR_LAST_REPORT)"; then \
+                       LAST_PASSED=$$(grep -Pc '^ok \d+' < $(BTR_LAST_REPORT)); \
+                       LAST_FAILED=$$(grep -Pc '^not ok \d+' < $(BTR_LAST_REPORT)); \
                        DIFF_PASSED=$$(bc <<<"$$TESTS_PASSED - $$LAST_PASSED"); \
                        DIFF_FAILED=$$(bc <<<"$$TESTS_FAILED - $$LAST_FAILED"); \
                        printf " %+d/%+d" $$DIFF_PASSED $$DIFF_FAILED >>$@; \
                        DIFF_PASSED=$$(bc <<<"$$TESTS_PASSED - $$LAST_PASSED"); \
                        DIFF_FAILED=$$(bc <<<"$$TESTS_FAILED - $$LAST_FAILED"); \
                        printf " %+d/%+d" $$DIFF_PASSED $$DIFF_FAILED >>$@; \
@@ -31,36 +31,43 @@ $(REPORT): $(TEST_REPORT)
                printf "\n" >>$@; \
        )
 
                printf "\n" >>$@; \
        )
 
-$(TEST_REPORT): $(BUILD_REPORT)
+$(BTR_TEST_REPORT): $(BTR_BUILD_REPORT)
        $(SAY) "Running unit tests..."
        $(SAY) "Running unit tests..."
-       cd $(BUILD_DIR) && \
-               phpunit --tap $(TEST_ARGS) . >../$@
+       (cd $(BTR_BUILD_DIR) && \
+               phpunit --tap $(BTR_TEST_ARGS) . \
+       ) >$@
 
 
-$(BUILD_REPORT): $(CONFIG_REPORT) $(BUILD_DIR)/composer.lock
+$(BTR_BUILD_REPORT): $(BTR_CONFIG_REPORT) $(BTR_BUILD_DIR)/composer.lock
        $(SAY) "Installing dependencies..."
        $(SAY) "Installing dependencies..."
-       cd $(BUILD_DIR) && \
-               ./composer.phar -n --no-ansi $(QUIET_FLAG) $(VERBOSE_FLAG) $(BUILD_ARGS) \
-                       >../$@
+       (cd $(BTR_BUILD_DIR) && \
+               ./composer.phar -n --no-ansi $(BTR_QUIET_FLAG) $(BTR_VERBOSE_FLAG) $(BTR_BUILD_ARGS) \
+       ) >$@
 
 
-$(CONFIG_REPORT): $(BUILD_DIR)/composer.json $(BUILD_DIR)/composer.phar 
-       touch $(CONFIG_REPORT)
+$(BTR_CONFIG_REPORT): $(BTR_BUILD_DIR)/composer.json $(BTR_BUILD_DIR)/composer.phar | $(BTR_LOG_DIR)
+       touch $@
 
 
-$(BUILD_DIR)/composer.phar:
+$(BTR_BUILD_DIR):
+       mkdir -p $@
+
+$(BTR_LOG_DIR):
+       mkdir -p $@
+
+$(BTR_BUILD_DIR)/composer.phar: | $(BTR_BUILD_DIR) $(BTR_LOG_DIR)
        $(SAY) "Orchestrating composer..."
        $(SAY) "Orchestrating composer..."
-       @cd $(BUILD_DIR) && ( \
+       (cd $(BTR_BUILD_DIR) && \
                COMPOSER=$$(command -v composer); \
                if test $$? -eq 0; \
                then \
                        ln -s $$COMPOSER composer.phar; \
                else \
                COMPOSER=$$(command -v composer); \
                if test $$? -eq 0; \
                then \
                        ln -s $$COMPOSER composer.phar; \
                else \
-                       curl $(SILENT_FLAG) -S http://getcomposer.org/installer | php; \
+                       curl $(BTR_SILENT_FLAG) -S http://getcomposer.org/installer | php; \
                fi; \
                fi; \
-       ) >>$(CONFIG_REPORT)
+       ) >>$(BTR_CONFIG_REPORT)
 
 
-$(BUILD_DIR)/composer.json: $(BRANCH_DIR)/composer.json
-       rsync $(QUIET_FLAG) $(VERBOSE_FLAG) -a --delete $(BRANCH_DIR)/ $(BUILD_DIR)/ \
-               >> $(CONFIG_REPORT)
+$(BTR_BUILD_DIR)/composer.json: $(BTR_BRANCH_DIR)/composer.json | $(BTR_BUILD_DIR) $(BTR_LOG_DIR)
+       rsync $(BTR_QUIET_FLAG) $(BTR_VERBOSE_FLAG) -a --delete $(BTR_BRANCH_DIR)/ $(BTR_BUILD_DIR)/ \
+               >>$(BTR_CONFIG_REPORT)
 
 
-$(BUILD_DIR)/composer.lock: $(BUILD_DIR)/composer.json $(BUILD_DIR)/composer.phar
+$(BTR_BUILD_DIR)/composer.lock: $(BTR_BUILD_DIR)/composer.json $(BTR_BUILD_DIR)/composer.phar
 
 # vim: noet
 
 # vim: noet
index 8dc05e39cc8532e0cdb047042e36ee83f21170e7..0047ab7d11b19b3d36d65b13bc36455592b26943 100644 (file)
@@ -1,52 +1,55 @@
-BUILD_CLEAN=false
-BUILD_ARGS=
-TEST_ARGS=
+BTR_BUILD_CLEAN=false
+BTR_BUILD_ARGS=
+BTR_TEST_ARGS=
 
 .PHONY: all clean
 .SUFFIXES:
 
 
 .PHONY: all clean
 .SUFFIXES:
 
-CONFIGS=$(wildcard $(BRANCH_DIR)/configure.*)
+CONFIGS=$(wildcard $(BTR_BRANCH_DIR)/configure.*)
 
 
-all: clean $(REPORT)
-       $(SAY) "Result: $$(cat $(REPORT))"
+all: clean $(BTR_REPORT)
+       $(SAY) "Result: $$(cat $(BTR_REPORT))"
 
 
-clean: $(CONFIG_REPORT)
-       if $(BUILD_CLEAN); \
+clean: $(BTR_CONFIG_REPORT)
+       if $(BTR_BUILD_CLEAN); \
        then \
        then \
-               cd $(BUILD_DIR) && \
-                       make $(SILENT_FLAG) clean; \
+               cd $(BTR_BUILD_DIR) && \
+                       make $(BTR_SILENT_FLAG) clean; \
        fi;
 
        fi;
 
-$(REPORT): $(TEST_REPORT)
-       if test -z "$(LAST_REPORT)"; then \
+$(BTR_REPORT): $(BTR_TEST_REPORT)
+       if test -z "$(BTR_LAST_REPORT)"; then \
                echo 0; \
                echo 0; \
-       elif test -s "$(LAST_REPORT)" -o -s "$(TEST_REPORT)"; then \
-               cmp $(LAST_REPORT) $(TEST_REPORT) 2>&1 || true; \
+       elif test -s "$(BTR_LAST_REPORT)" -o -s "$(BTR_TEST_REPORT)"; then \
+               cmp $(BTR_LAST_REPORT) $(BTR_TEST_REPORT) 2>&1 || true; \
        else \
                echo 0; \
        fi;
 
        else \
                echo 0; \
        fi;
 
-$(TEST_REPORT): $(BUILD_REPORT)
+$(BTR_TEST_REPORT): $(BTR_BUILD_REPORT)
        $(SAY) "Running checks..."
        $(SAY) "Running checks..."
-       cd $(BUILD_DIR) && \
-               make check $(TEST_ARGS) >../$@ 2>&1
+       cd $(BTR_BUILD_DIR) && \
+               make check $(BTR_TEST_ARGS) >../$@ 2>&1
 
 
-$(BUILD_REPORT): $(CONFIG_REPORT)
+$(BTR_BUILD_REPORT): $(BTR_CONFIG_REPORT)
        $(SAY) "Making build..."
        $(SAY) "Making build..."
-       cd $(BUILD_DIR) && \
+       cd $(BTR_BUILD_DIR) && \
                make -j $(CPUS) >../$@ 2>&1
        
                make -j $(CPUS) >../$@ 2>&1
        
-$(CONFIG_REPORT): $(BRANCH_DIR)/configure $(BUILD_DIR)
+$(BTR_CONFIG_REPORT): $(BTR_BRANCH_DIR)/configure | $(BTR_BUILD_DIR) $(BTR_LOG_DIR)
        $(SAY) "Running configure..."
        $(SAY) "Running configure..."
-       cd $(BUILD_DIR) && \
-               ../$(BRANCH_DIR)/configure -C $(BUILD_ARGS) >../$@ 2>&1
+       cd $(BTR_BUILD_DIR) && \
+               ../$(BTR_BRANCH_DIR)/configure -C $(BTR_BUILD_ARGS) >../$@ 2>&1
 
 
-$(BUILD_DIR):
+$(BTR_BUILD_DIR):
        mkdir -p $@
        mkdir -p $@
-       
-$(BRANCH_DIR)/configure: $(CONFIGS)
+
+$(BTR_LOG_DIR):
+       mkdir -p $@
+
+$(BTR_BRANCH_DIR)/configure: $(CONFIGS)
        $(SAY) "Building configure..."
        $(SAY) "Building configure..."
-       cd $(BRANCH_DIR) && \
+       cd $(BTR_BRANCH_DIR) && \
                autoreconf -i -f -W none >/dev/null
 
 # vim: noet
                autoreconf -i -f -W none >/dev/null
 
 # vim: noet
index c27b23a2c18e477f6d9f5d93a2953e632f4768eb..3ce75ccf1bbd8dc823975a64384b5f1635b921c7 100644 (file)
@@ -1,30 +1,30 @@
-BUILD_CLEAN=false
-BUILD_ARGS=
-TEST_ARGS= -q
+BTR_BUILD_CLEAN=false
+BTR_BUILD_ARGS=
+BTR_TEST_ARGS= -q
 
 .PHONY: all clean
 .SUFFIXES:
 
 
 .PHONY: all clean
 .SUFFIXES:
 
-CONFIGS=$(wildcard $(BRANCH_DIR)/config*.m4 $(BRANCH_DIR)/*/config*.m4)
+CONFIGS=$(wildcard $(BTR_BRANCH_DIR)/config*.m4 $(BTR_BRANCH_DIR)/*/config*.m4)
 
 
-all: clean $(REPORT)
-       $(SAY) "Result: $$(cat $(REPORT))"
+all: clean $(BTR_REPORT)
+       $(SAY) "Result: $$(cat $(BTR_REPORT))"
 
 
-clean: $(CONFIG_REPORT)
-       if $(BUILD_CLEAN); \
+clean: $(BTR_CONFIG_REPORT)
+       if $(BTR_BUILD_CLEAN); \
        then \
        then \
-               cd $(BUILD_DIR) && \
-                       make $(SILENT_FLAG) clean; \
+               cd $(BTR_BUILD_DIR) && \
+                       make $(BTR_SILENT_FLAG) clean; \
        fi;
 
        fi;
 
-$(REPORT): $(TEST_REPORT)
+$(BTR_REPORT): $(BTR_TEST_REPORT)
        @(\
        @(\
-               TESTS_PASSED=$$(awk '/^Tests passed/{print $$4}' < $(TEST_REPORT)); \
-               TESTS_FAILED=$$(awk '/^Tests failed/{print $$4}' < $(TEST_REPORT)); \
+               TESTS_PASSED=$$(awk '/^Tests passed/{print $$4}' < $(BTR_TEST_REPORT)); \
+               TESTS_FAILED=$$(awk '/^Tests failed/{print $$4}' < $(BTR_TEST_REPORT)); \
                printf "%d/%d" $$TESTS_PASSED $$TESTS_FAILED >$@; \
                printf "%d/%d" $$TESTS_PASSED $$TESTS_FAILED >$@; \
-               if test -s "$(LAST_REPORT)"; then \
-                       LAST_PASSED=$$(awk '/^Tests passed/{print $$4}' < $(LAST_REPORT)); \
-                       LAST_FAILED=$$(awk '/^Tests failed/{print $$4}' < $(LAST_REPORT)); \
+               if test -s "$(BTR_LAST_REPORT)"; then \
+                       LAST_PASSED=$$(awk '/^Tests passed/{print $$4}' < $(BTR_LAST_REPORT)); \
+                       LAST_FAILED=$$(awk '/^Tests failed/{print $$4}' < $(BTR_LAST_REPORT)); \
                        DIFF_PASSED=$$(bc <<<"$$TESTS_PASSED - $$LAST_PASSED"); \
                        DIFF_FAILED=$$(bc <<<"$$TESTS_FAILED - $$LAST_FAILED"); \
                        printf " %+d/%+d" $$DIFF_PASSED $$DIFF_FAILED >>$@; \
                        DIFF_PASSED=$$(bc <<<"$$TESTS_PASSED - $$LAST_PASSED"); \
                        DIFF_FAILED=$$(bc <<<"$$TESTS_FAILED - $$LAST_FAILED"); \
                        printf " %+d/%+d" $$DIFF_PASSED $$DIFF_FAILED >>$@; \
@@ -32,27 +32,30 @@ $(REPORT): $(TEST_REPORT)
                printf "\n" >>$@; \
        )
 
                printf "\n" >>$@; \
        )
 
-$(TEST_REPORT): $(BUILD_REPORT)
+$(BTR_TEST_REPORT): $(BTR_BUILD_REPORT)
        $(SAY) "Running tests... "
        $(SAY) "Running tests... "
-       cd $(BUILD_DIR) && \
-               make test TESTS="$(TEST_ARGS) -s ../$@" >/dev/null
+       cd $(BTR_BUILD_DIR) && \
+               make test TESTS="$(BTR_TEST_ARGS) -s ../$@" >/dev/null
 
 
-$(BUILD_REPORT): $(CONFIG_REPORT)
+$(BTR_BUILD_REPORT): $(BTR_CONFIG_REPORT)
        $(SAY) "Making build..."
        $(SAY) "Making build..."
-       cd $(BUILD_DIR) && \
+       cd $(BTR_BUILD_DIR) && \
                make -j $(CPUS) >../$@ 2>&1
        
                make -j $(CPUS) >../$@ 2>&1
        
-$(CONFIG_REPORT): $(BRANCH_DIR)/configure $(BUILD_DIR)
+$(BTR_CONFIG_REPORT): $(BTR_BRANCH_DIR)/configure | $(BTR_BUILD_DIR) $(BTR_LOG_DIR)
        $(SAY) "Running 'configure'..."
        $(SAY) "Running 'configure'..."
-       cd $(BUILD_DIR) && \
-               ../$(BRANCH_DIR)/configure -C $(BUILD_ARGS) >../$@ 2>&1
+       cd $(BTR_BUILD_DIR) && \
+               ../$(BTR_BRANCH_DIR)/configure -C $(BTR_BUILD_ARGS) >../$@ 2>&1
 
 
-$(BUILD_DIR):
+$(BTR_BUILD_DIR):
        mkdir -p $@
        mkdir -p $@
-       
-$(BRANCH_DIR)/configure: $(CONFIGS)
+
+$(BTR_LOG_DIR):
+       mkdir -p $@
+
+$(BTR_BRANCH_DIR)/configure: $(CONFIGS)
        $(SAY) "Running phpize..."
        $(SAY) "Running phpize..."
-       cd $(BRANCH_DIR) && \
+       cd $(BTR_BRANCH_DIR) && \
                phpize >/dev/null
 
 # vim: noet
                phpize >/dev/null
 
 # vim: noet
index 35a7c71cca26aa95164b6e205e1c7d84e2ad1288..b858e2a6897243749ebf459ccf9f2f7669f1ad1d 100644 (file)
@@ -1,30 +1,30 @@
-BUILD_CLEAN=false
-BUILD_ARGS= --enable-debug
-TEST_ARGS= -q
+BTR_BUILD_CLEAN=false
+BTR_BUILD_ARGS= --enable-debug
+BTR_TEST_ARGS= -q
 
 .PHONY: all clean
 .SUFFIXES:
 
 
 .PHONY: all clean
 .SUFFIXES:
 
-CONFIGS=$(wildcard $(BRANCH_DIR)/ext/*/config*.m4)
+CONFIGS=$(wildcard $(BTR_BRANCH_DIR)/ext/*/config*.m4)
 
 
-all: clean $(REPORT)
-       $(SAY) "Result: $$(cat $(REPORT))"
+all: clean $(BTR_REPORT)
+       $(SAY) "Result: $$(cat $(BTR_REPORT))"
 
 
-clean: $(CONFIG_REPORT)
-       if $(BUILD_CLEAN); \
+clean: $(BTR_CONFIG_REPORT)
+       if $(BTR_BUILD_CLEAN); \
        then \
        then \
-               cd $(BUILD_DIR) && \
-                       make $(SILENT_FLAG) clean; \
+               cd $(BTR_BUILD_DIR) && \
+                       make $(BTR_SILENT_FLAG) clean; \
        fi;
 
        fi;
 
-$(REPORT): $(TEST_REPORT)
+$(BTR_REPORT): $(BTR_TEST_REPORT)
        @(\
        @(\
-               TESTS_PASSED=$$(awk '/^Tests passed/{print $$4}' < $(TEST_REPORT)); \
-               TESTS_FAILED=$$(awk '/^Tests failed/{print $$4}' < $(TEST_REPORT)); \
+               TESTS_PASSED=$$(awk '/^Tests passed/{print $$4}' < $(BTR_TEST_REPORT)); \
+               TESTS_FAILED=$$(awk '/^Tests failed/{print $$4}' < $(BTR_TEST_REPORT)); \
                printf "%d/%d" $$TESTS_PASSED $$TESTS_FAILED >$@; \
                printf "%d/%d" $$TESTS_PASSED $$TESTS_FAILED >$@; \
-               if test -s "$(LAST_REPORT)"; then \
-                       LAST_PASSED=$$(awk '/^Tests passed/{print $$4}' < $(LAST_REPORT)); \
-                       LAST_FAILED=$$(awk '/^Tests failed/{print $$4}' < $(LAST_REPORT)); \
+               if test -s "$(BTR_LAST_REPORT)"; then \
+                       LAST_PASSED=$$(awk '/^Tests passed/{print $$4}' < $(BTR_LAST_REPORT)); \
+                       LAST_FAILED=$$(awk '/^Tests failed/{print $$4}' < $(BTR_LAST_REPORT)); \
                        DIFF_PASSED=$$(bc <<<"$$TESTS_PASSED - $$LAST_PASSED"); \
                        DIFF_FAILED=$$(bc <<<"$$TESTS_FAILED - $$LAST_FAILED"); \
                        printf " %+d/%+d" $$DIFF_PASSED $$DIFF_FAILED >>$@; \
                        DIFF_PASSED=$$(bc <<<"$$TESTS_PASSED - $$LAST_PASSED"); \
                        DIFF_FAILED=$$(bc <<<"$$TESTS_FAILED - $$LAST_FAILED"); \
                        printf " %+d/%+d" $$DIFF_PASSED $$DIFF_FAILED >>$@; \
@@ -32,27 +32,30 @@ $(REPORT): $(TEST_REPORT)
                printf "\n" >>$@; \
        )
 
                printf "\n" >>$@; \
        )
 
-$(TEST_REPORT): $(BUILD_REPORT)
+$(BTR_TEST_REPORT): $(BTR_BUILD_REPORT) 
        $(SAY) "Running tests... "
        $(SAY) "Running tests... "
-       cd $(BUILD_DIR) && \
-               make test TESTS="$(TEST_ARGS) -s ../$@"
+       cd $(BTR_BUILD_DIR) && \
+               make test TESTS="$(BTR_TEST_ARGS) -s ../$@"
 
 
-$(BUILD_REPORT): $(CONFIG_REPORT)
+$(BTR_BUILD_REPORT): $(BTR_CONFIG_REPORT)
        $(SAY) "Making build..."
        $(SAY) "Making build..."
-       cd $(BUILD_DIR) && \
+       cd $(BTR_BUILD_DIR) && \
                make -j $(CPUS) >../$@ 2>&1
        
                make -j $(CPUS) >../$@ 2>&1
        
-$(CONFIG_REPORT): $(BRANCH_DIR)/configure $(BUILD_DIR)
+$(BTR_CONFIG_REPORT): $(BTR_BRANCH_DIR)/configure | $(BTR_BUILD_DIR) $(BTR_LOG_DIR)
        $(SAY) "Running 'configure'..."
        $(SAY) "Running 'configure'..."
-       cd $(BUILD_DIR) && \
-               ../$(BRANCH_DIR)/configure -C $(BUILD_ARGS) >../$@ 2>&1
+       cd $(BTR_BUILD_DIR) && \
+               ../$(BTR_BRANCH_DIR)/configure -C $(BTR_BUILD_ARGS) >../$@ 2>&1
 
 
-$(BUILD_DIR):
+$(BTR_BUILD_DIR):
+       mkdir -p $@
+
+$(BTR_LOG_DIR):
        mkdir -p $@
        
        mkdir -p $@
        
-$(BRANCH_DIR)/configure: $(BRANCH_DIR)/buildconf $(CONFIGS)
+$(BTR_BRANCH_DIR)/configure: $(BTR_BRANCH_DIR)/buildconf $(CONFIGS)
        $(SAY) "Building configure..."
        $(SAY) "Building configure..."
-       cd $(BRANCH_DIR) && \
+       cd $(BTR_BRANCH_DIR) && \
                ./buildconf >/dev/null
 
 # vim: noet
                ./buildconf >/dev/null
 
 # vim: noet
diff --git a/share/btr/common.sh b/share/btr/common.sh
new file mode 100755 (executable)
index 0000000..4c7fb74
--- /dev/null
@@ -0,0 +1,88 @@
+#!/bin/bash
+
+export DATE=$(date +%Y%m%d%H%M%S)
+export CPUS=${CPUS:-$(nproc)}
+
+BTR_QUIET=false
+BTR_VERBOSE=false
+BTR_FORCEYES=false
+
+function error {
+       echo "$@" >&2
+       exit 1
+}
+export -f error
+
+function btr-banner {
+       echo "$(basename ${0:btr}) v0.4.0, (c) Michael Wallner <mike@php.net>"
+       if test "$BTR_BANNER"
+       then
+               echo "$BTR_BANNER"
+       fi
+}
+export -f btr-banner
+
+function btr-confirm {
+       local CONTINUE
+       if ! $BTR_FORCEYES
+       then
+               echo -n "$1 (y/N) "
+               read -r CONTINUE
+               case $CONTINUE in
+                       y*|Y*)
+                               echo
+                               ;;
+                       *)
+                               exit -1
+                               ;;
+               esac
+       fi
+}
+export -f btr-confirm
+
+function btr-setup-rundir {
+       local default_rundir="${1:-/tmp/btr}"
+       
+       if test -z "$BTR_RUNDIR"
+       then
+               export BTR_RUNDIR="$default_rundir"
+       else
+               export BTR_RUNDIR=$(realpath "$BTR_RUNDIR")
+       fi
+       
+       mkdir -p "$BTR_RUNDIR" || error "Could not create directory '$BTR_RUNDIR'"
+}
+export -f btr-setup-rundir
+
+function btr-setup-verbosity {
+       local for_make=${1:-false}
+       
+       if $BTR_VERBOSE
+       then
+               BTR_QUIET_FLAG=
+               BTR_SILENT_FLAG=
+               BTR_VERBOSE_FLAG="-v"
+               SAY="echo; echo"
+       elif $BTR_QUIET
+       then
+               BTR_QUIET_FLAG="-q"
+               BTR_SILENT_FLAG="-s"
+               BTR_VERBOSE_FLAG=
+               SAY="true"
+       else
+               BTR_QUIET_FLAG=
+               BTR_SILENT_FLAG="-s"
+               BTR_VERBOSE_FLAG=
+               SAY="echo"
+       fi
+       
+       if $for_make
+       then
+               SAY="@$SAY"
+       fi
+       
+       export BTR_QUIET BTR_VERBOSE BTR_FORCEYES BTR_QUIET_FLAG BTR_SILENT_FLAG BTR_VERBOSE_FLAG SAY
+}
+export -f btr-setup-verbosity
+
+# vim: noet
index 7360fa62db1a94cb9aff6c7fbf9920c1ad54e23b..583562d58ab324e9e3b6a73343ab027eaf39bd1e 100644 (file)
@@ -2,11 +2,11 @@
 .SUFFIXES:
 
 all: 
 .SUFFIXES:
 
 all: 
-       $(SAY) "Notifying IRC ($(REPORT_ARGS))"
-       CONFIG_URL=$$(curl -sSF sprunge="@$(CONFIG_REPORT)" sprunge.us); \
-       BUILD_URL=$$(curl -sSF sprunge="@$(BUILD_REPORT)" sprunge.us); \
-       TEST_URL=$$(curl -sSF sprunge="@$(TEST_REPORT)" sprunge.us); \
-       $(BINDIR)/btr-irc-send "$(REPORT_ARGS)" "[btr] $(BUILD) $$(cat $(REPORT)) \
-               -- Config: $$CONFIG_URL -- Build: $$BUILD_URL -- Test: $$TEST_URL";
+       $(SAY) "Notifying IRC ($(BTR_REPORT_ARGS))"
+       BTR_CONFIG_URL=$$(curl -sSF sprunge="@$(BTR_CONFIG_REPORT)" sprunge.us); \
+       BTR_BUILD_URL=$$(curl -sSF sprunge="@$(BTR_BUILD_REPORT)" sprunge.us); \
+       BTR_TEST_URL=$$(curl -sSF sprunge="@$(BTR_TEST_REPORT)" sprunge.us); \
+       $(BTR_BINDIR)/btr-irc-send "$(BTR_REPORT_ARGS)" "[btr] $(BTR_BUILD) $$(cat $(BTR_REPORT)) \
+               -- Config: $$BTR_CONFIG_URL -- Build: $$BTR_BUILD_URL -- Test: $$BTR_TEST_URL";
 
 # vim: noet
 
 # vim: noet
index d16a646fb4625510c5b12868dab2e673e6cd5412..76c6b8b8122109edd052e43ce7af5bc8288ec294 100644 (file)
@@ -1,15 +1,15 @@
-REPORT_ARGS=$(USER)
+BTR_REPORT_ARGS=$(USER)
 
 .PHONY: all
 .SUFFIXES:
 
 all: 
 
 .PHONY: all
 .SUFFIXES:
 
 all: 
-       $(SAY) "Mailing report to $(REPORT_ARGS)"
-       @printf "\nbtr %s %s\n\n-- \nbtr mail report\n" "$(BUILD)" "$$(cat $(REPORT))" | \
-               mail -s "[btr] $(BUILD) $$(cat $(REPORT))" \
-                       -a $(CONFIG_REPORT) \
-                       -a $(BUILD_REPORT) \
-                       -a $(TEST_REPORT) \
-                       $(REPORT_ARGS)
+       $(SAY) "Mailing report to $(BTR_REPORT_ARGS)"
+       @printf "\nbtr %s %s\n\n-- \nbtr mail report\n" "$(BTR_BUILD)" "$$(cat $(BTR_REPORT))" | \
+               mail -s "[btr] $(BTR_BUILD) $$(cat $(BTR_REPORT))" \
+                       -a $(BTR_CONFIG_REPORT) \
+                       -a $(BTR_BUILD_REPORT) \
+                       -a $(BTR_TEST_REPORT) \
+                       $(BTR_REPORT_ARGS)
 
 # vim: noet
 
 # vim: noet
index cfc20ccb27d3a8fd2ebd34cc1822de9cc87131a7..e913c3c1fab401fa884f24a1004a9123be907333 100644 (file)
@@ -3,10 +3,10 @@
 
 all: 
        $(SAY) "Notifying $(USER) about the report"
 
 all: 
        $(SAY) "Notifying $(USER) about the report"
-       CONFIG_URL=$$(curl -sSF sprunge="@$(CONFIG_REPORT)" sprunge.us); \
-       BUILD_URL=$$(curl -sSF sprunge="@$(BUILD_REPORT)" sprunge.us); \
-       TEST_URL=$$(curl -sSF sprunge="@$(TEST_REPORT)" sprunge.us); \
-       notify-send $(REPORT_ARGS) "[btr] $(BUILD) $$(cat $(REPORT))" \
-               "Config: $$CONFIG_URL -- Build: $$BUILD_URL -- Test:$$TEST_URL";
+       BTR_CONFIG_URL=$$(curl -sSF sprunge="@$(BTR_CONFIG_REPORT)" sprunge.us); \
+       BTR_BUILD_URL=$$(curl -sSF sprunge="@$(BTR_BUILD_REPORT)" sprunge.us); \
+       BTR_TEST_URL=$$(curl -sSF sprunge="@$(BTR_TEST_REPORT)" sprunge.us); \
+       notify-send $(BTR_REPORT_ARGS) "[btr] $(BTR_BUILD) $$(cat $(BTR_REPORT))" \
+               "Config: $$BTR_CONFIG_URL -- Build: $$BTR_BUILD_URL -- Test: $$BTR_TEST_URL";
 
 # vim: noet
 
 # vim: noet
index 54ac53a711291a0f6957a7cedf2e13b08267dad4..f0dd0bbedb43d4f9fe91d12d120d30d396e41140 100644 (file)
@@ -4,8 +4,8 @@
 all:
        curl "https://api.twilio.com/2010-04-01/Accounts/$(TWILIO_ACCOUNT)/SMS/Messages.json" \
        --data-urlencode "From=$(TWILIO_NUMBER)" \
 all:
        curl "https://api.twilio.com/2010-04-01/Accounts/$(TWILIO_ACCOUNT)/SMS/Messages.json" \
        --data-urlencode "From=$(TWILIO_NUMBER)" \
-       --data-urlencode "To=$(REPORT_NUMBER)" \
-       --data-urlencode "Body=[btr] $(BUILD) $$(cat $(REPORT))" \
+       --data-urlencode "To=$(BTR_REPORT_NUMBER)" \
+       --data-urlencode "Body=[btr] $(BTR_BUILD) $$(cat $(BTR_REPORT))" \
        -u $(TWILIO_ACCOUNT):$(TWILIO_TOKEN)
 
 # vim: noet
        -u $(TWILIO_ACCOUNT):$(TWILIO_TOKEN)
 
 # vim: noet
index 839efa2bbacc3b9c5fb14d6e5d11596974a9c982..7682d2a0654e12f5d3a68e3f4f320346ce2b3c28 100644 (file)
@@ -1,31 +1,31 @@
-SOURCE_CLEAN=false
-CVSROOT=$(shell cut -d'\#' -f1 <<<$(SOURCE_ARGS))
-CVS_MOD=$(shell cut -d'\#' -f2 -s <<<$(SOURCE_ARGS))
+BTR_SOURCE_CLEAN=false
+CVSROOT=$(shell cut -d'\#' -f1 <<<$(BTR_SOURCE_ARGS))
+CVS_MOD=$(shell cut -d'\#' -f2 -s <<<$(BTR_SOURCE_ARGS))
 CVS_RSH=ssh
 
 export
 
 CVS_RSH=ssh
 
 export
 
-ifeq ($(value QUIET_FLAG), -q)
-override QUIET_FLAG = -Q
+ifeq ($(value BTR_QUIET_FLAG), -q)
+override BTR_QUIET_FLAG = -Q
 endif
 
 .PHONY: all clean login
 .SUFFIXES:
 
 endif
 
 .PHONY: all clean login
 .SUFFIXES:
 
-all: $(BRANCH_DIR) clean
-       $(SAY) "Updating $(BRANCH)..."
-       cd $(BRANCH_DIR) && \
-               cvs $(QUIET_FLAG) -z3 update -RPd;
+all: $(BTR_BRANCH_DIR) clean
+       $(SAY) "Updating $(BTR_BRANCH)..."
+       cd $(BTR_BRANCH_DIR) && \
+               cvs $(BTR_QUIET_FLAG) -z3 update -RPd;
 
 
-clean: $(BRANCH_DIR)
-       if $(SOURCE_CLEAN); \
+clean: $(BTR_BRANCH_DIR)
+       if $(BTR_SOURCE_CLEAN); \
        then \
        then \
-               cd $(BRANCH_DIR) && \
-                       cvs $(QUIET_FLAG) -z3 update -CRPd; \
+               cd $(BTR_BRANCH_DIR) && \
+                       cvs $(BTR_QUIET_FLAG) -z3 update -CRPd; \
        fi;
 
        fi;
 
-$(BRANCH_DIR):
+$(BTR_BRANCH_DIR):
        $(SAY) "Performing checkout of $(CVS_MOD) from $(CVSROOT)..."
        $(SAY) "Performing checkout of $(CVS_MOD) from $(CVSROOT)..."
-       cvs $(QUIET_FLAG) checkout -RP -r $(BRANCH) -d $(BRANCH_DIR) $(CVS_MOD)
+       cvs $(BTR_QUIET_FLAG) checkout -RP -r $(BTR_BRANCH) -d $(BTR_BRANCH_DIR) $(CVS_MOD)
 
 # vim: noet
 
 # vim: noet
index 3808590450e2cc09deece2fd99a6aa861e357d98..02744cd2cae9bc9caac56b71bd5df831ae38e7f7 100644 (file)
@@ -1,31 +1,31 @@
-SOURCE_CLEAN=false
+BTR_SOURCE_CLEAN=false
 
 .PHONY: fetch all clean
 .SUFFIXES:
 
 
 .PHONY: fetch all clean
 .SUFFIXES:
 
-all: $(BRANCH_DIR) clean fetch
-       $(SAY) "Merging $(BRANCH) of $(REPO)..."
-       cd $(BRANCH_DIR) && \
-               git merge $(QUIET_FLAG) --ff-only;
+all: $(BTR_BRANCH_DIR) clean fetch
+       $(SAY) "Merging $(BTR_BRANCH) of $(BTR_REPO)..."
+       cd $(BTR_BRANCH_DIR) && \
+               git merge $(BTR_QUIET_FLAG) --ff-only;
 
 
-clean: $(BRANCH_DIR)
-       if $(SOURCE_CLEAN); \
+clean: $(BTR_BRANCH_DIR)
+       if $(BTR_SOURCE_CLEAN); \
        then \
        then \
-               cd $(BRANCH_DIR) && \
-                       git reset --hard $(QUIET_FLAGS); \
+               cd $(BTR_BRANCH_DIR) && \
+                       git reset --hard $(BTR_QUIET_FLAGS); \
        fi;
 
        fi;
 
-fetch: $(CLEAN_DIR)
-       $(SAY) "Fetching $(REPO)..."
-       cd $(CLEAN_DIR) && \
-               git fetch $(QUIET_FLAG);
+fetch: $(BTR_REPO_DIR)
+       $(SAY) "Fetching $(BTR_REPO)..."
+       cd $(BTR_REPO_DIR) && \
+               git fetch $(BTR_QUIET_FLAG);
 
 
-$(CLEAN_DIR):
-       $(SAY) "Cloning from $(SOURCE_ARGS)..."
-       git clone $(QUIET_FLAG) $(SOURCE_ARGS) $(CLEAN_DIR);
+$(BTR_REPO_DIR):
+       $(SAY) "Cloning from $(BTR_SOURCE_ARGS)..."
+       git clone $(BTR_QUIET_FLAG) $(BTR_SOURCE_ARGS) $(BTR_REPO_DIR);
 
 
-$(BRANCH_DIR): $(CLEAN_DIR)
-       $(SAY) "Creating workdir for $(BRANCH)"
-       git-new-workdir $(CLEAN_DIR) $(BRANCH_DIR) $(BRANCH)
+$(BTR_BRANCH_DIR): $(BTR_REPO_DIR)
+       $(SAY) "Creating workdir for $(BTR_BRANCH)"
+       git-new-workdir $(BTR_REPO_DIR) $(BTR_BRANCH_DIR) $(BTR_BRANCH)
 
 # vim: noet
 
 # vim: noet
index b18782e628f362227030c846a2a3913f53786abd..f7edc6b3555a39459db51828c988ab4a3e434c3b 100644 (file)
@@ -1,22 +1,22 @@
-SOURCE_CLEAN=false
+BTR_SOURCE_CLEAN=false
 
 .PHONY: all clean
 .SUFFIXES:
 
 
 .PHONY: all clean
 .SUFFIXES:
 
-all: $(BRANCH_DIR) clean
-       $(SAY) "Updating $(BRANCH)..."
-       cd $(BRANCH_DIR) && \
-               svn update $(QUIET_FLAG);
+all: $(BTR_BRANCH_DIR) clean
+       $(SAY) "Updating $(BTR_BRANCH)..."
+       cd $(BTR_BRANCH_DIR) && \
+               svn update $(BTR_QUIET_FLAG);
 
 
-clean: $(BRANCH_DIR)
-       if $(SOURCE_CLEAN); \
+clean: $(BTR_BRANCH_DIR)
+       if $(BTR_SOURCE_CLEAN); \
        then \
        then \
-               cd $(BRANCH_DIR) && \
-                       svn revert $(QUIET_FLAG); \
+               cd $(BTR_BRANCH_DIR) && \
+                       svn revert $(BTR_QUIET_FLAG); \
        fi;
 
        fi;
 
-$(BRANCH_DIR):
-       $(SAY) "Performing checkout from $(SOURCE_ARGS)..."
-       svn checkout $(QUIET_FLAG) $(SOURCE_ARGS)/$(BRANCH) $(BRANCH_DIR)
+$(BTR_BRANCH_DIR):
+       $(SAY) "Performing checkout from $(BTR_SOURCE_ARGS)..."
+       svn checkout $(BTR_QUIET_FLAG) $(BTR_SOURCE_ARGS)/$(BTR_BRANCH) $(BTR_BRANCH_DIR)
 
 # vim: noet
 
 # vim: noet