autotoolize
authorMichael Wallner <mike@php.net>
Fri, 10 Jan 2014 12:08:22 +0000 (13:08 +0100)
committerMichael Wallner <mike@php.net>
Fri, 10 Jan 2014 12:08:22 +0000 (13:08 +0100)
30 files changed:
Makefile.am
bin/btr
bin/btr-irc-relay
bin/btr-irc-send
lib/btr/btr.sh [deleted file]
lib/btr/build/composer.mk [deleted file]
lib/btr/build/gnu.mk [deleted file]
lib/btr/build/pecl.mk [deleted file]
lib/btr/build/php.mk [deleted file]
lib/btr/irc.php [deleted file]
lib/btr/report/irc.mk [deleted file]
lib/btr/report/mail.mk [deleted file]
lib/btr/report/notify-send.mk [deleted file]
lib/btr/report/twilio.mk [deleted file]
lib/btr/source/cvs.mk [deleted file]
lib/btr/source/git.mk [deleted file]
lib/btr/source/svn.mk [deleted file]
share/btr/btr.sh [new file with mode: 0755]
share/btr/build/composer.mk [new file with mode: 0644]
share/btr/build/gnu.mk [new file with mode: 0644]
share/btr/build/pecl.mk [new file with mode: 0644]
share/btr/build/php.mk [new file with mode: 0644]
share/btr/irc.php [new file with mode: 0755]
share/btr/report/irc.mk [new file with mode: 0644]
share/btr/report/mail.mk [new file with mode: 0644]
share/btr/report/notify-send.mk [new file with mode: 0644]
share/btr/report/twilio.mk [new file with mode: 0644]
share/btr/source/cvs.mk [new file with mode: 0644]
share/btr/source/git.mk [new file with mode: 0644]
share/btr/source/svn.mk [new file with mode: 0644]

index 206b33ada8de9be81c5874ca61817277af8fc420..3260af8ca8e3f20a5e94e369854a11b91b578408 100644 (file)
@@ -1,18 +1,18 @@
 dist_bin_SCRIPTS = bin/btr \
                    bin/btr-irc-relay \
                    bin/btr-irc-send
 dist_bin_SCRIPTS = bin/btr \
                    bin/btr-irc-relay \
                    bin/btr-irc-send
-btrlibdir = $(prefix)
-nobase_dist_btrlib_SCRIPTS = lib/btr/build/pecl.mk \
-       lib/btr/build/make.mk \
-       lib/btr/build/gnu.mk \
-       lib/btr/build/php.mk \
-       lib/btr/build/composer.mk \
-       lib/btr/report/mail.mk \
-       lib/btr/report/twilio.mk \
-       lib/btr/report/notify-send.mk \
-       lib/btr/report/irc.mk \
-       lib/btr/source/cvs.mk \
-       lib/btr/source/git.mk \
-       lib/btr/source/svn.mk \
-       lib/btr/btr.sh \
-       lib/btr/irc.php
+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
diff --git a/bin/btr b/bin/btr
index 74464549ff23edeb7d6cf825b407cf572bce2dbd..6f303b7f21cd826fb10ac45736295215a1b7dfe9 100755 (executable)
--- a/bin/btr
+++ b/bin/btr
@@ -4,7 +4,7 @@ export DATE=$(date +%Y%m%d%H%M%S)
 export CPUS=${CPUS:-$(grep -c "^processor" /proc/cpuinfo)}
 
 export BINDIR=$(realpath $(dirname $0)/)
 export CPUS=${CPUS:-$(grep -c "^processor" /proc/cpuinfo)}
 
 export BINDIR=$(realpath $(dirname $0)/)
-export LIBDIR=$(realpath $(dirname $0)/../lib/btr)
+export LIBDIR=$(realpath $(dirname $0)/../share/btr)
 
 . $LIBDIR/btr.sh
 
 
 . $LIBDIR/btr.sh
 
index 7bda9fc62e903c50febfdafaa8f03987e7beaf1e..3251c85474fede1cd3294d77e6b40b1d94eda06d 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 
 #!/usr/bin/env php
 <?php
 
-require __DIR__."/../lib/btr/irc.php";
+require __DIR__."/../share/btr/irc.php";
 
 if ($argc != 3) {
        fatal("Usage: %s <url> <fifo>\n", basename($argv[0]));
 
 if ($argc != 3) {
        fatal("Usage: %s <url> <fifo>\n", basename($argv[0]));
index 4b2259af98fc6748c334040c22493490fb4aac7f..43ab1aee459dd097ac0de769970a53dff0a32ea9 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 
 #!/usr/bin/env php
 <?php
 
-require __DIR__."/../lib/btr/irc.php";
+require __DIR__."/../share/btr/irc.php";
 
 if ($argc != 3) {
        fatal("Usage: %s <url|fifo> <message>\n", basename($argv[0]));
 
 if ($argc != 3) {
        fatal("Usage: %s <url|fifo> <message>\n", basename($argv[0]));
diff --git a/lib/btr/btr.sh b/lib/btr/btr.sh
deleted file mode 100755 (executable)
index d0db095..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-#!/bin/sh
-
-function help {
-       echo "btr v0.3.0, (c) Michael Wallner <mike@php.net>"
-       echo
-       echo "Usage: $(basename $0) [-hyvqcC] [<options>]"
-       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 "    -c, --clean     Clean build"
-       echo "    -C, --vcsclean  Clean repo/branch"
-       echo
-       echo "  Options:"
-       echo "    -f, --config=<file>           Read configuration from a file"
-       echo "    -s, --source=<rules>          Use the specified source ruleset"
-       echo "    -b, --build=<rules>           Use the specified build ruleset"
-       echo "    -r, --report=<rules>          Use the specifued report ruleset"
-       echo "    -T, --test=<args>             Provide test runner arguments"
-       echo "    -B, --branch=<branch>         Checkout this branch"
-       echo "    -D, --directory=<directory>   Use this directory as work root"
-       echo "    -S, --suffix=<suffix>         Append suffix to the build name"
-       echo
-       echo "  Rules format:"
-       echo "    type=argument    e.g: git=git@github.com:m6w6/btr.git"
-       echo "                          irc=irc://btr@chat.freenode.org/#btr"
-       echo "                          mail=\"-c copy@to rcpt@to\""
-       echo "                          notify-send=\"-u low\""
-       echo
-       echo "    Note though, that some rules do not use any argument."
-       echo
-       echo "  Rulesets:"
-       for ruleset in source build report
-       do
-               printf "    %10s: %s\n" $ruleset \
-                       "$(find "$LIBDIR/$ruleset" -name '*.mk' -exec basename {} .mk \; | sort | xargs)"
-       done
-       echo
-       echo "  Examples:"
-       echo 
-       echo "  Clone PHP's git, use PHP-5.5 branch, build with php ruleset and"
-       echo "  run the test suite with valgrind (-m) on a debug build and report"
-       echo "  the results with a simple OSD notification:"
-       echo "    $ btr -s git=git@php.net:php/php-src.git -B PHP-5.5 \\"
-       echo "          -b \"php=--enable-debug\" -T-m -r notify-send"
-       echo "  See also php.example.conf"
-       echo
-       echo "  Clone CURL's git (use master), build with GNU autotools"
-       echo "  ruleset which runs 'make check' and mail the report to the"
-       echo "  current user. Verbosely show all actions taken:"
-       echo "    $ btr -v -s git=https://github.com/bagder/curl.git -b gnu -r mail"
-       echo "  See also curl.example.conf"
-       echo
-       exit
-}
-
-function 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 \
-               --options "$shortoptions" \
-               --longoptions "$longoptions" \
-               -- "$@" \
-       )
-
-       if test $? -ne 0 ; then
-               help
-       fi
-       
-       eval set -- "$options"
-       
-       while test $# -gt 0
-       do
-               case "$1" in
-                       -h|--help)
-                               help
-                               ;;
-                       -v|--verbose)
-                               QUIET=false
-                               VERBOSE=true
-                               ;;
-                       -q|--quiet)
-                               QUIET=true
-                               VERBOSE=false
-                               ;;
-                       -y|--yes)
-                               FORCEYES=true
-                               ;;
-                       -c|--clean)
-                               BUILD_CLEAN=true
-                               ;;
-                       -C|--vcsclean)
-                               SOURCE_CLEAN=true
-                               ;;
-                       ####
-                       -f|--config)
-                               source "$2"
-                               shift
-                               ;;
-                       ####
-                       -B|--branch)
-                               BRANCH="$2"
-                               shift
-                               ;;
-                       -D|--directory)
-                               BTRDIR="$2"
-                               shift
-                               ;;
-                       -S|--suffix)
-                               SUFFIX="$2"
-                               shift
-                               ;;
-                       -T|--test)
-                               TEST_ARGS="$2"
-                               shift
-                               ;;
-                       ####
-                       -s|--source)
-                               case "$2" in
-                               git*)
-                                       test -z "$BRANCH" && BRANCH=master
-                                       ;;
-                               svn*)
-                                       test -z "$BRANCH" && BRANCH=trunk
-                                       ;;
-                               cvs*)
-                                       test -z "$BRANCH" && BRANCH=HEAD
-                                       ;;
-                               esac
-                               SOURCE_RULES="$(cut -d= -f1 <<<$2)"
-                               SOURCE_ARGS="$(cut -s -d= -f2- <<<$2)"
-                               shift
-                               ;;
-                       -b|--build)
-                               BUILD_RULES="$(cut -d= -f1 <<<$2)"
-                               BUILD_ARGS="$(cut -s -d= -f2- <<<$2)"
-                               shift
-                               ;;
-                       -r|--report)
-                               REPORT_RULES="$(cut -d= -f1 <<<$2)"
-                               REPORT_ARGS="$(cut -s -d= -f2- <<<$2)"
-                               shift
-                               ;;
-                       ####
-                       --)
-                               # legacy
-                               if test "$2"
-                               then
-                                       SOURCE_ARGS="$2"
-                               fi
-                               shift
-                               ;;
-               esac
-               shift
-       done
-}
-
-function error {
-       echo "$@" >&2
-       exit
-}
-
-function setup {
-       if test -z "$SOURCE_RULES" -o -z "$BUILD_RULES" -o -z "$REPORT_RULES"
-       then
-               help
-       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"
-
-       
-       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
-
-       if test -z "$SUFFIX"
-       then
-               export BUILD="$REPO@$SAFE_BRANCH"
-       else
-               export BUILD="$REPO@$SAFE_BRANCH-$SUFFIX"
-       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"
-}
-
-function show_conf {
-       echo
-       echo "Configuration:"
-       echo "=============="
-       echo
-       echo "BTRDIR         = $BTRDIR"
-       echo "BINDIR         = $BINDIR"
-       echo "LIBDIR         = $LIBDIR"
-       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
-       echo "REPO           = $REPO"
-       echo "BRANCH         = $BRANCH"
-       echo "SAFE_BRANCH    = $SAFE_BRANCH"
-       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
-}
-
-function confirm {
-       local CONTINUE
-       echo -n "$1 (y/N) "
-       read -r CONTINUE
-       case $CONTINUE in
-               y*|Y*)
-                       echo
-                       ;;
-               *)
-                       exit -1
-                       ;;
-       esac
-}
-
-# vim: noet
diff --git a/lib/btr/build/composer.mk b/lib/btr/build/composer.mk
deleted file mode 100644 (file)
index f08e8e2..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-BUILD_CLEAN=false
-BUILD_ARGS= install --dev
-TEST_ARGS= --strict --coverage-text
-
-.PHONY: all clean
-.SUFFIXES:
-
-all: clean $(REPORT)
-       $(SAY) "Result: $$(cat $(REPORT))"
-
-clean: $(CONFIG_REPORT)
-       if $(BUILD_CLEAN); \
-       then \
-               cd $(BUILD_DIR) && \
-                       rm -rf vendor; \
-       fi;
-
-$(REPORT): $(TEST_REPORT)
-       @( \
-               TESTS_PASSED=$$(grep -Pc '^ok \d+' < $(TEST_REPORT)); \
-               TESTS_FAILED=$$(grep -Pc '^not ok \d+' < $(TEST_REPORT)); \
-               \
-               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)); \
-                       DIFF_PASSED=$$(bc <<<"$$TESTS_PASSED - $$LAST_PASSED"); \
-                       DIFF_FAILED=$$(bc <<<"$$TESTS_FAILED - $$LAST_FAILED"); \
-                       printf " %+d/%+d" $$DIFF_PASSED $$DIFF_FAILED >>$@; \
-               fi; \
-               printf "\n" >>$@; \
-       )
-
-$(TEST_REPORT): $(BUILD_REPORT)
-       $(SAY) "Running unit tests..."
-       cd $(BUILD_DIR) && \
-               phpunit --tap $(TEST_ARGS) . >../$@
-
-$(BUILD_REPORT): $(CONFIG_REPORT) $(BUILD_DIR)/composer.lock
-       $(SAY) "Installing dependencies..."
-       cd $(BUILD_DIR) && \
-               ./composer.phar -n --no-ansi $(QUIET_FLAG) $(VERBOSE_FLAG) $(BUILD_ARGS) \
-                       >../$@
-
-$(CONFIG_REPORT): $(BUILD_DIR)/composer.json $(BUILD_DIR)/composer.phar 
-       touch $(CONFIG_REPORT)
-
-$(BUILD_DIR)/composer.phar:
-       $(SAY) "Orchestrating composer..."
-       @cd $(BUILD_DIR) && ( \
-               COMPOSER=$$(command -v composer); \
-               if test $$? -eq 0; \
-               then \
-                       ln -s $$COMPOSER composer.phar; \
-               else \
-                       curl $(SILENT_FLAG) -S http://getcomposer.org/installer | php; \
-               fi; \
-       ) >>$(CONFIG_REPORT)
-
-$(BUILD_DIR)/composer.json: $(BRANCH_DIR)/composer.json
-       rsync $(QUIET_FLAG) $(VERBOSE_FLAG) -a --delete $(BRANCH_DIR)/ $(BUILD_DIR)/ \
-               >> $(CONFIG_REPORT)
-
-$(BUILD_DIR)/composer.lock: $(BUILD_DIR)/composer.json $(BUILD_DIR)/composer.phar
-
-# vim: noet
diff --git a/lib/btr/build/gnu.mk b/lib/btr/build/gnu.mk
deleted file mode 100644 (file)
index 8dc05e3..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-BUILD_CLEAN=false
-BUILD_ARGS=
-TEST_ARGS=
-
-.PHONY: all clean
-.SUFFIXES:
-
-CONFIGS=$(wildcard $(BRANCH_DIR)/configure.*)
-
-all: clean $(REPORT)
-       $(SAY) "Result: $$(cat $(REPORT))"
-
-clean: $(CONFIG_REPORT)
-       if $(BUILD_CLEAN); \
-       then \
-               cd $(BUILD_DIR) && \
-                       make $(SILENT_FLAG) clean; \
-       fi;
-
-$(REPORT): $(TEST_REPORT)
-       if test -z "$(LAST_REPORT)"; then \
-               echo 0; \
-       elif test -s "$(LAST_REPORT)" -o -s "$(TEST_REPORT)"; then \
-               cmp $(LAST_REPORT) $(TEST_REPORT) 2>&1 || true; \
-       else \
-               echo 0; \
-       fi;
-
-$(TEST_REPORT): $(BUILD_REPORT)
-       $(SAY) "Running checks..."
-       cd $(BUILD_DIR) && \
-               make check $(TEST_ARGS) >../$@ 2>&1
-
-$(BUILD_REPORT): $(CONFIG_REPORT)
-       $(SAY) "Making build..."
-       cd $(BUILD_DIR) && \
-               make -j $(CPUS) >../$@ 2>&1
-       
-$(CONFIG_REPORT): $(BRANCH_DIR)/configure $(BUILD_DIR)
-       $(SAY) "Running configure..."
-       cd $(BUILD_DIR) && \
-               ../$(BRANCH_DIR)/configure -C $(BUILD_ARGS) >../$@ 2>&1
-
-$(BUILD_DIR):
-       mkdir -p $@
-       
-$(BRANCH_DIR)/configure: $(CONFIGS)
-       $(SAY) "Building configure..."
-       cd $(BRANCH_DIR) && \
-               autoreconf -i -f -W none >/dev/null
-
-# vim: noet
diff --git a/lib/btr/build/pecl.mk b/lib/btr/build/pecl.mk
deleted file mode 100644 (file)
index c27b23a..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-BUILD_CLEAN=false
-BUILD_ARGS=
-TEST_ARGS= -q
-
-.PHONY: all clean
-.SUFFIXES:
-
-CONFIGS=$(wildcard $(BRANCH_DIR)/config*.m4 $(BRANCH_DIR)/*/config*.m4)
-
-all: clean $(REPORT)
-       $(SAY) "Result: $$(cat $(REPORT))"
-
-clean: $(CONFIG_REPORT)
-       if $(BUILD_CLEAN); \
-       then \
-               cd $(BUILD_DIR) && \
-                       make $(SILENT_FLAG) clean; \
-       fi;
-
-$(REPORT): $(TEST_REPORT)
-       @(\
-               TESTS_PASSED=$$(awk '/^Tests passed/{print $$4}' < $(TEST_REPORT)); \
-               TESTS_FAILED=$$(awk '/^Tests failed/{print $$4}' < $(TEST_REPORT)); \
-               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)); \
-                       DIFF_PASSED=$$(bc <<<"$$TESTS_PASSED - $$LAST_PASSED"); \
-                       DIFF_FAILED=$$(bc <<<"$$TESTS_FAILED - $$LAST_FAILED"); \
-                       printf " %+d/%+d" $$DIFF_PASSED $$DIFF_FAILED >>$@; \
-               fi; \
-               printf "\n" >>$@; \
-       )
-
-$(TEST_REPORT): $(BUILD_REPORT)
-       $(SAY) "Running tests... "
-       cd $(BUILD_DIR) && \
-               make test TESTS="$(TEST_ARGS) -s ../$@" >/dev/null
-
-$(BUILD_REPORT): $(CONFIG_REPORT)
-       $(SAY) "Making build..."
-       cd $(BUILD_DIR) && \
-               make -j $(CPUS) >../$@ 2>&1
-       
-$(CONFIG_REPORT): $(BRANCH_DIR)/configure $(BUILD_DIR)
-       $(SAY) "Running 'configure'..."
-       cd $(BUILD_DIR) && \
-               ../$(BRANCH_DIR)/configure -C $(BUILD_ARGS) >../$@ 2>&1
-
-$(BUILD_DIR):
-       mkdir -p $@
-       
-$(BRANCH_DIR)/configure: $(CONFIGS)
-       $(SAY) "Running phpize..."
-       cd $(BRANCH_DIR) && \
-               phpize >/dev/null
-
-# vim: noet
diff --git a/lib/btr/build/php.mk b/lib/btr/build/php.mk
deleted file mode 100644 (file)
index 35a7c71..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-BUILD_CLEAN=false
-BUILD_ARGS= --enable-debug
-TEST_ARGS= -q
-
-.PHONY: all clean
-.SUFFIXES:
-
-CONFIGS=$(wildcard $(BRANCH_DIR)/ext/*/config*.m4)
-
-all: clean $(REPORT)
-       $(SAY) "Result: $$(cat $(REPORT))"
-
-clean: $(CONFIG_REPORT)
-       if $(BUILD_CLEAN); \
-       then \
-               cd $(BUILD_DIR) && \
-                       make $(SILENT_FLAG) clean; \
-       fi;
-
-$(REPORT): $(TEST_REPORT)
-       @(\
-               TESTS_PASSED=$$(awk '/^Tests passed/{print $$4}' < $(TEST_REPORT)); \
-               TESTS_FAILED=$$(awk '/^Tests failed/{print $$4}' < $(TEST_REPORT)); \
-               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)); \
-                       DIFF_PASSED=$$(bc <<<"$$TESTS_PASSED - $$LAST_PASSED"); \
-                       DIFF_FAILED=$$(bc <<<"$$TESTS_FAILED - $$LAST_FAILED"); \
-                       printf " %+d/%+d" $$DIFF_PASSED $$DIFF_FAILED >>$@; \
-               fi; \
-               printf "\n" >>$@; \
-       )
-
-$(TEST_REPORT): $(BUILD_REPORT)
-       $(SAY) "Running tests... "
-       cd $(BUILD_DIR) && \
-               make test TESTS="$(TEST_ARGS) -s ../$@"
-
-$(BUILD_REPORT): $(CONFIG_REPORT)
-       $(SAY) "Making build..."
-       cd $(BUILD_DIR) && \
-               make -j $(CPUS) >../$@ 2>&1
-       
-$(CONFIG_REPORT): $(BRANCH_DIR)/configure $(BUILD_DIR)
-       $(SAY) "Running 'configure'..."
-       cd $(BUILD_DIR) && \
-               ../$(BRANCH_DIR)/configure -C $(BUILD_ARGS) >../$@ 2>&1
-
-$(BUILD_DIR):
-       mkdir -p $@
-       
-$(BRANCH_DIR)/configure: $(BRANCH_DIR)/buildconf $(CONFIGS)
-       $(SAY) "Building configure..."
-       cd $(BRANCH_DIR) && \
-               ./buildconf >/dev/null
-
-# vim: noet
diff --git a/lib/btr/irc.php b/lib/btr/irc.php
deleted file mode 100755 (executable)
index 8af2209..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-
-function fatal() {
-       if (func_num_args()) {
-               $args = func_get_args();
-       } elseif (($error = error_get_last())) {
-               $args = ["%s", $error["message"]];
-       }
-       
-       if (!empty($args)) {
-               if (count($args) === 1 && is_numeric($args[0])) {
-                       array_unshift($args, "Got signal %d");
-               }
-               trigger_error(call_user_func_array("sprintf", $args), E_USER_ERROR);
-       }
-       
-       exit;
-}
-
-function mkfifo($path) {
-       if (!isfifo($path, $stat)) {
-               $stat and unlink($path);
-               if (!posix_mkfifo($path, 0660)) {
-                       return false;
-               }
-       }
-       return fopen($path, "r+");
-}
-
-function isfifo($path, &$stat = null) {
-       return ($stat = @stat($path)) && ($stat["mode"] & POSIX_S_IFIFO);
-}
-
-class Client
-{
-       protected $session;
-       protected $channel;
-       protected $keyword;
-       protected $joined;
-       protected $queue = array();
-       
-       function __construct($url, callable $onJoin) {
-               if (!$url = parse_url($url)) {
-                       fatal("could not parse url: '%s'", $url);
-               }
-               
-               $this->session = $session = new irc\client\Session(
-                       $url["user"],
-                       $url["user"],
-                       $url["user"]
-               );
-               
-               @list($this->channel, $this->keyword) = 
-                       explode(" ", $url["fragment"]);
-               
-               $session->onConnect = $session->onPart = function($origin, array $args) {
-                       $this->joined = false;
-                       $this->session->doJoin("#".$this->channel, $this->keyword);
-               };
-               $session->onJoin = function($origin, array $args) use ($onJoin) {
-                       $this->joined = true;
-                       $onJoin($this, $origin, $args);
-               };
-               $session->doConnect(false, $url["host"], @$url["port"]?:6667, @$url["pass"]);
-       }
-       
-       function send($message = null) {
-               if (isset($message)) {
-                       $this->queue[] = $message;
-               }
-               
-               if ($this->joined) {
-                       while ($this->queue) {
-                               $this->session->doMsg("#".$this->channel, array_shift($this->queue));
-                       }
-               }
-       }
-       
-       function getSession() {
-               return $this->session;
-       }
-}
-
-if (!extension_loaded("ircclient")) {
-       fatal("ext/ircclient not loaded");
-}
-
-# vim: noet
diff --git a/lib/btr/report/irc.mk b/lib/btr/report/irc.mk
deleted file mode 100644 (file)
index 7360fa6..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-.PHONY: 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";
-
-# vim: noet
diff --git a/lib/btr/report/mail.mk b/lib/btr/report/mail.mk
deleted file mode 100644 (file)
index d16a646..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-REPORT_ARGS=$(USER)
-
-.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)
-
-# vim: noet
diff --git a/lib/btr/report/notify-send.mk b/lib/btr/report/notify-send.mk
deleted file mode 100644 (file)
index cfc20cc..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-.PHONY: all
-.SUFFIXES:
-
-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";
-
-# vim: noet
diff --git a/lib/btr/report/twilio.mk b/lib/btr/report/twilio.mk
deleted file mode 100644 (file)
index 54ac53a..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-.PHONY: all
-.SUFFIXES:
-
-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))" \
-       -u $(TWILIO_ACCOUNT):$(TWILIO_TOKEN)
-
-# vim: noet
diff --git a/lib/btr/source/cvs.mk b/lib/btr/source/cvs.mk
deleted file mode 100644 (file)
index 839efa2..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-SOURCE_CLEAN=false
-CVSROOT=$(shell cut -d'\#' -f1 <<<$(SOURCE_ARGS))
-CVS_MOD=$(shell cut -d'\#' -f2 -s <<<$(SOURCE_ARGS))
-CVS_RSH=ssh
-
-export
-
-ifeq ($(value QUIET_FLAG), -q)
-override QUIET_FLAG = -Q
-endif
-
-.PHONY: all clean login
-.SUFFIXES:
-
-all: $(BRANCH_DIR) clean
-       $(SAY) "Updating $(BRANCH)..."
-       cd $(BRANCH_DIR) && \
-               cvs $(QUIET_FLAG) -z3 update -RPd;
-
-clean: $(BRANCH_DIR)
-       if $(SOURCE_CLEAN); \
-       then \
-               cd $(BRANCH_DIR) && \
-                       cvs $(QUIET_FLAG) -z3 update -CRPd; \
-       fi;
-
-$(BRANCH_DIR):
-       $(SAY) "Performing checkout of $(CVS_MOD) from $(CVSROOT)..."
-       cvs $(QUIET_FLAG) checkout -RP -r $(BRANCH) -d $(BRANCH_DIR) $(CVS_MOD)
-
-# vim: noet
diff --git a/lib/btr/source/git.mk b/lib/btr/source/git.mk
deleted file mode 100644 (file)
index 3808590..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-SOURCE_CLEAN=false
-
-.PHONY: fetch all clean
-.SUFFIXES:
-
-all: $(BRANCH_DIR) clean fetch
-       $(SAY) "Merging $(BRANCH) of $(REPO)..."
-       cd $(BRANCH_DIR) && \
-               git merge $(QUIET_FLAG) --ff-only;
-
-clean: $(BRANCH_DIR)
-       if $(SOURCE_CLEAN); \
-       then \
-               cd $(BRANCH_DIR) && \
-                       git reset --hard $(QUIET_FLAGS); \
-       fi;
-
-fetch: $(CLEAN_DIR)
-       $(SAY) "Fetching $(REPO)..."
-       cd $(CLEAN_DIR) && \
-               git fetch $(QUIET_FLAG);
-
-$(CLEAN_DIR):
-       $(SAY) "Cloning from $(SOURCE_ARGS)..."
-       git clone $(QUIET_FLAG) $(SOURCE_ARGS) $(CLEAN_DIR);
-
-$(BRANCH_DIR): $(CLEAN_DIR)
-       $(SAY) "Creating workdir for $(BRANCH)"
-       git-new-workdir $(CLEAN_DIR) $(BRANCH_DIR) $(BRANCH)
-
-# vim: noet
diff --git a/lib/btr/source/svn.mk b/lib/btr/source/svn.mk
deleted file mode 100644 (file)
index b18782e..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-SOURCE_CLEAN=false
-
-.PHONY: all clean
-.SUFFIXES:
-
-all: $(BRANCH_DIR) clean
-       $(SAY) "Updating $(BRANCH)..."
-       cd $(BRANCH_DIR) && \
-               svn update $(QUIET_FLAG);
-
-clean: $(BRANCH_DIR)
-       if $(SOURCE_CLEAN); \
-       then \
-               cd $(BRANCH_DIR) && \
-                       svn revert $(QUIET_FLAG); \
-       fi;
-
-$(BRANCH_DIR):
-       $(SAY) "Performing checkout from $(SOURCE_ARGS)..."
-       svn checkout $(QUIET_FLAG) $(SOURCE_ARGS)/$(BRANCH) $(BRANCH_DIR)
-
-# vim: noet
diff --git a/share/btr/btr.sh b/share/btr/btr.sh
new file mode 100755 (executable)
index 0000000..d0db095
--- /dev/null
@@ -0,0 +1,276 @@
+#!/bin/sh
+
+function help {
+       echo "btr v0.3.0, (c) Michael Wallner <mike@php.net>"
+       echo
+       echo "Usage: $(basename $0) [-hyvqcC] [<options>]"
+       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 "    -c, --clean     Clean build"
+       echo "    -C, --vcsclean  Clean repo/branch"
+       echo
+       echo "  Options:"
+       echo "    -f, --config=<file>           Read configuration from a file"
+       echo "    -s, --source=<rules>          Use the specified source ruleset"
+       echo "    -b, --build=<rules>           Use the specified build ruleset"
+       echo "    -r, --report=<rules>          Use the specifued report ruleset"
+       echo "    -T, --test=<args>             Provide test runner arguments"
+       echo "    -B, --branch=<branch>         Checkout this branch"
+       echo "    -D, --directory=<directory>   Use this directory as work root"
+       echo "    -S, --suffix=<suffix>         Append suffix to the build name"
+       echo
+       echo "  Rules format:"
+       echo "    type=argument    e.g: git=git@github.com:m6w6/btr.git"
+       echo "                          irc=irc://btr@chat.freenode.org/#btr"
+       echo "                          mail=\"-c copy@to rcpt@to\""
+       echo "                          notify-send=\"-u low\""
+       echo
+       echo "    Note though, that some rules do not use any argument."
+       echo
+       echo "  Rulesets:"
+       for ruleset in source build report
+       do
+               printf "    %10s: %s\n" $ruleset \
+                       "$(find "$LIBDIR/$ruleset" -name '*.mk' -exec basename {} .mk \; | sort | xargs)"
+       done
+       echo
+       echo "  Examples:"
+       echo 
+       echo "  Clone PHP's git, use PHP-5.5 branch, build with php ruleset and"
+       echo "  run the test suite with valgrind (-m) on a debug build and report"
+       echo "  the results with a simple OSD notification:"
+       echo "    $ btr -s git=git@php.net:php/php-src.git -B PHP-5.5 \\"
+       echo "          -b \"php=--enable-debug\" -T-m -r notify-send"
+       echo "  See also php.example.conf"
+       echo
+       echo "  Clone CURL's git (use master), build with GNU autotools"
+       echo "  ruleset which runs 'make check' and mail the report to the"
+       echo "  current user. Verbosely show all actions taken:"
+       echo "    $ btr -v -s git=https://github.com/bagder/curl.git -b gnu -r mail"
+       echo "  See also curl.example.conf"
+       echo
+       exit
+}
+
+function 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 \
+               --options "$shortoptions" \
+               --longoptions "$longoptions" \
+               -- "$@" \
+       )
+
+       if test $? -ne 0 ; then
+               help
+       fi
+       
+       eval set -- "$options"
+       
+       while test $# -gt 0
+       do
+               case "$1" in
+                       -h|--help)
+                               help
+                               ;;
+                       -v|--verbose)
+                               QUIET=false
+                               VERBOSE=true
+                               ;;
+                       -q|--quiet)
+                               QUIET=true
+                               VERBOSE=false
+                               ;;
+                       -y|--yes)
+                               FORCEYES=true
+                               ;;
+                       -c|--clean)
+                               BUILD_CLEAN=true
+                               ;;
+                       -C|--vcsclean)
+                               SOURCE_CLEAN=true
+                               ;;
+                       ####
+                       -f|--config)
+                               source "$2"
+                               shift
+                               ;;
+                       ####
+                       -B|--branch)
+                               BRANCH="$2"
+                               shift
+                               ;;
+                       -D|--directory)
+                               BTRDIR="$2"
+                               shift
+                               ;;
+                       -S|--suffix)
+                               SUFFIX="$2"
+                               shift
+                               ;;
+                       -T|--test)
+                               TEST_ARGS="$2"
+                               shift
+                               ;;
+                       ####
+                       -s|--source)
+                               case "$2" in
+                               git*)
+                                       test -z "$BRANCH" && BRANCH=master
+                                       ;;
+                               svn*)
+                                       test -z "$BRANCH" && BRANCH=trunk
+                                       ;;
+                               cvs*)
+                                       test -z "$BRANCH" && BRANCH=HEAD
+                                       ;;
+                               esac
+                               SOURCE_RULES="$(cut -d= -f1 <<<$2)"
+                               SOURCE_ARGS="$(cut -s -d= -f2- <<<$2)"
+                               shift
+                               ;;
+                       -b|--build)
+                               BUILD_RULES="$(cut -d= -f1 <<<$2)"
+                               BUILD_ARGS="$(cut -s -d= -f2- <<<$2)"
+                               shift
+                               ;;
+                       -r|--report)
+                               REPORT_RULES="$(cut -d= -f1 <<<$2)"
+                               REPORT_ARGS="$(cut -s -d= -f2- <<<$2)"
+                               shift
+                               ;;
+                       ####
+                       --)
+                               # legacy
+                               if test "$2"
+                               then
+                                       SOURCE_ARGS="$2"
+                               fi
+                               shift
+                               ;;
+               esac
+               shift
+       done
+}
+
+function error {
+       echo "$@" >&2
+       exit
+}
+
+function setup {
+       if test -z "$SOURCE_RULES" -o -z "$BUILD_RULES" -o -z "$REPORT_RULES"
+       then
+               help
+       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"
+
+       
+       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
+
+       if test -z "$SUFFIX"
+       then
+               export BUILD="$REPO@$SAFE_BRANCH"
+       else
+               export BUILD="$REPO@$SAFE_BRANCH-$SUFFIX"
+       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"
+}
+
+function show_conf {
+       echo
+       echo "Configuration:"
+       echo "=============="
+       echo
+       echo "BTRDIR         = $BTRDIR"
+       echo "BINDIR         = $BINDIR"
+       echo "LIBDIR         = $LIBDIR"
+       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
+       echo "REPO           = $REPO"
+       echo "BRANCH         = $BRANCH"
+       echo "SAFE_BRANCH    = $SAFE_BRANCH"
+       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
+}
+
+function confirm {
+       local CONTINUE
+       echo -n "$1 (y/N) "
+       read -r CONTINUE
+       case $CONTINUE in
+               y*|Y*)
+                       echo
+                       ;;
+               *)
+                       exit -1
+                       ;;
+       esac
+}
+
+# vim: noet
diff --git a/share/btr/build/composer.mk b/share/btr/build/composer.mk
new file mode 100644 (file)
index 0000000..f08e8e2
--- /dev/null
@@ -0,0 +1,66 @@
+BUILD_CLEAN=false
+BUILD_ARGS= install --dev
+TEST_ARGS= --strict --coverage-text
+
+.PHONY: all clean
+.SUFFIXES:
+
+all: clean $(REPORT)
+       $(SAY) "Result: $$(cat $(REPORT))"
+
+clean: $(CONFIG_REPORT)
+       if $(BUILD_CLEAN); \
+       then \
+               cd $(BUILD_DIR) && \
+                       rm -rf vendor; \
+       fi;
+
+$(REPORT): $(TEST_REPORT)
+       @( \
+               TESTS_PASSED=$$(grep -Pc '^ok \d+' < $(TEST_REPORT)); \
+               TESTS_FAILED=$$(grep -Pc '^not ok \d+' < $(TEST_REPORT)); \
+               \
+               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)); \
+                       DIFF_PASSED=$$(bc <<<"$$TESTS_PASSED - $$LAST_PASSED"); \
+                       DIFF_FAILED=$$(bc <<<"$$TESTS_FAILED - $$LAST_FAILED"); \
+                       printf " %+d/%+d" $$DIFF_PASSED $$DIFF_FAILED >>$@; \
+               fi; \
+               printf "\n" >>$@; \
+       )
+
+$(TEST_REPORT): $(BUILD_REPORT)
+       $(SAY) "Running unit tests..."
+       cd $(BUILD_DIR) && \
+               phpunit --tap $(TEST_ARGS) . >../$@
+
+$(BUILD_REPORT): $(CONFIG_REPORT) $(BUILD_DIR)/composer.lock
+       $(SAY) "Installing dependencies..."
+       cd $(BUILD_DIR) && \
+               ./composer.phar -n --no-ansi $(QUIET_FLAG) $(VERBOSE_FLAG) $(BUILD_ARGS) \
+                       >../$@
+
+$(CONFIG_REPORT): $(BUILD_DIR)/composer.json $(BUILD_DIR)/composer.phar 
+       touch $(CONFIG_REPORT)
+
+$(BUILD_DIR)/composer.phar:
+       $(SAY) "Orchestrating composer..."
+       @cd $(BUILD_DIR) && ( \
+               COMPOSER=$$(command -v composer); \
+               if test $$? -eq 0; \
+               then \
+                       ln -s $$COMPOSER composer.phar; \
+               else \
+                       curl $(SILENT_FLAG) -S http://getcomposer.org/installer | php; \
+               fi; \
+       ) >>$(CONFIG_REPORT)
+
+$(BUILD_DIR)/composer.json: $(BRANCH_DIR)/composer.json
+       rsync $(QUIET_FLAG) $(VERBOSE_FLAG) -a --delete $(BRANCH_DIR)/ $(BUILD_DIR)/ \
+               >> $(CONFIG_REPORT)
+
+$(BUILD_DIR)/composer.lock: $(BUILD_DIR)/composer.json $(BUILD_DIR)/composer.phar
+
+# vim: noet
diff --git a/share/btr/build/gnu.mk b/share/btr/build/gnu.mk
new file mode 100644 (file)
index 0000000..8dc05e3
--- /dev/null
@@ -0,0 +1,52 @@
+BUILD_CLEAN=false
+BUILD_ARGS=
+TEST_ARGS=
+
+.PHONY: all clean
+.SUFFIXES:
+
+CONFIGS=$(wildcard $(BRANCH_DIR)/configure.*)
+
+all: clean $(REPORT)
+       $(SAY) "Result: $$(cat $(REPORT))"
+
+clean: $(CONFIG_REPORT)
+       if $(BUILD_CLEAN); \
+       then \
+               cd $(BUILD_DIR) && \
+                       make $(SILENT_FLAG) clean; \
+       fi;
+
+$(REPORT): $(TEST_REPORT)
+       if test -z "$(LAST_REPORT)"; then \
+               echo 0; \
+       elif test -s "$(LAST_REPORT)" -o -s "$(TEST_REPORT)"; then \
+               cmp $(LAST_REPORT) $(TEST_REPORT) 2>&1 || true; \
+       else \
+               echo 0; \
+       fi;
+
+$(TEST_REPORT): $(BUILD_REPORT)
+       $(SAY) "Running checks..."
+       cd $(BUILD_DIR) && \
+               make check $(TEST_ARGS) >../$@ 2>&1
+
+$(BUILD_REPORT): $(CONFIG_REPORT)
+       $(SAY) "Making build..."
+       cd $(BUILD_DIR) && \
+               make -j $(CPUS) >../$@ 2>&1
+       
+$(CONFIG_REPORT): $(BRANCH_DIR)/configure $(BUILD_DIR)
+       $(SAY) "Running configure..."
+       cd $(BUILD_DIR) && \
+               ../$(BRANCH_DIR)/configure -C $(BUILD_ARGS) >../$@ 2>&1
+
+$(BUILD_DIR):
+       mkdir -p $@
+       
+$(BRANCH_DIR)/configure: $(CONFIGS)
+       $(SAY) "Building configure..."
+       cd $(BRANCH_DIR) && \
+               autoreconf -i -f -W none >/dev/null
+
+# vim: noet
diff --git a/share/btr/build/pecl.mk b/share/btr/build/pecl.mk
new file mode 100644 (file)
index 0000000..c27b23a
--- /dev/null
@@ -0,0 +1,58 @@
+BUILD_CLEAN=false
+BUILD_ARGS=
+TEST_ARGS= -q
+
+.PHONY: all clean
+.SUFFIXES:
+
+CONFIGS=$(wildcard $(BRANCH_DIR)/config*.m4 $(BRANCH_DIR)/*/config*.m4)
+
+all: clean $(REPORT)
+       $(SAY) "Result: $$(cat $(REPORT))"
+
+clean: $(CONFIG_REPORT)
+       if $(BUILD_CLEAN); \
+       then \
+               cd $(BUILD_DIR) && \
+                       make $(SILENT_FLAG) clean; \
+       fi;
+
+$(REPORT): $(TEST_REPORT)
+       @(\
+               TESTS_PASSED=$$(awk '/^Tests passed/{print $$4}' < $(TEST_REPORT)); \
+               TESTS_FAILED=$$(awk '/^Tests failed/{print $$4}' < $(TEST_REPORT)); \
+               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)); \
+                       DIFF_PASSED=$$(bc <<<"$$TESTS_PASSED - $$LAST_PASSED"); \
+                       DIFF_FAILED=$$(bc <<<"$$TESTS_FAILED - $$LAST_FAILED"); \
+                       printf " %+d/%+d" $$DIFF_PASSED $$DIFF_FAILED >>$@; \
+               fi; \
+               printf "\n" >>$@; \
+       )
+
+$(TEST_REPORT): $(BUILD_REPORT)
+       $(SAY) "Running tests... "
+       cd $(BUILD_DIR) && \
+               make test TESTS="$(TEST_ARGS) -s ../$@" >/dev/null
+
+$(BUILD_REPORT): $(CONFIG_REPORT)
+       $(SAY) "Making build..."
+       cd $(BUILD_DIR) && \
+               make -j $(CPUS) >../$@ 2>&1
+       
+$(CONFIG_REPORT): $(BRANCH_DIR)/configure $(BUILD_DIR)
+       $(SAY) "Running 'configure'..."
+       cd $(BUILD_DIR) && \
+               ../$(BRANCH_DIR)/configure -C $(BUILD_ARGS) >../$@ 2>&1
+
+$(BUILD_DIR):
+       mkdir -p $@
+       
+$(BRANCH_DIR)/configure: $(CONFIGS)
+       $(SAY) "Running phpize..."
+       cd $(BRANCH_DIR) && \
+               phpize >/dev/null
+
+# vim: noet
diff --git a/share/btr/build/php.mk b/share/btr/build/php.mk
new file mode 100644 (file)
index 0000000..35a7c71
--- /dev/null
@@ -0,0 +1,58 @@
+BUILD_CLEAN=false
+BUILD_ARGS= --enable-debug
+TEST_ARGS= -q
+
+.PHONY: all clean
+.SUFFIXES:
+
+CONFIGS=$(wildcard $(BRANCH_DIR)/ext/*/config*.m4)
+
+all: clean $(REPORT)
+       $(SAY) "Result: $$(cat $(REPORT))"
+
+clean: $(CONFIG_REPORT)
+       if $(BUILD_CLEAN); \
+       then \
+               cd $(BUILD_DIR) && \
+                       make $(SILENT_FLAG) clean; \
+       fi;
+
+$(REPORT): $(TEST_REPORT)
+       @(\
+               TESTS_PASSED=$$(awk '/^Tests passed/{print $$4}' < $(TEST_REPORT)); \
+               TESTS_FAILED=$$(awk '/^Tests failed/{print $$4}' < $(TEST_REPORT)); \
+               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)); \
+                       DIFF_PASSED=$$(bc <<<"$$TESTS_PASSED - $$LAST_PASSED"); \
+                       DIFF_FAILED=$$(bc <<<"$$TESTS_FAILED - $$LAST_FAILED"); \
+                       printf " %+d/%+d" $$DIFF_PASSED $$DIFF_FAILED >>$@; \
+               fi; \
+               printf "\n" >>$@; \
+       )
+
+$(TEST_REPORT): $(BUILD_REPORT)
+       $(SAY) "Running tests... "
+       cd $(BUILD_DIR) && \
+               make test TESTS="$(TEST_ARGS) -s ../$@"
+
+$(BUILD_REPORT): $(CONFIG_REPORT)
+       $(SAY) "Making build..."
+       cd $(BUILD_DIR) && \
+               make -j $(CPUS) >../$@ 2>&1
+       
+$(CONFIG_REPORT): $(BRANCH_DIR)/configure $(BUILD_DIR)
+       $(SAY) "Running 'configure'..."
+       cd $(BUILD_DIR) && \
+               ../$(BRANCH_DIR)/configure -C $(BUILD_ARGS) >../$@ 2>&1
+
+$(BUILD_DIR):
+       mkdir -p $@
+       
+$(BRANCH_DIR)/configure: $(BRANCH_DIR)/buildconf $(CONFIGS)
+       $(SAY) "Building configure..."
+       cd $(BRANCH_DIR) && \
+               ./buildconf >/dev/null
+
+# vim: noet
diff --git a/share/btr/irc.php b/share/btr/irc.php
new file mode 100755 (executable)
index 0000000..8af2209
--- /dev/null
@@ -0,0 +1,88 @@
+<?php
+
+function fatal() {
+       if (func_num_args()) {
+               $args = func_get_args();
+       } elseif (($error = error_get_last())) {
+               $args = ["%s", $error["message"]];
+       }
+       
+       if (!empty($args)) {
+               if (count($args) === 1 && is_numeric($args[0])) {
+                       array_unshift($args, "Got signal %d");
+               }
+               trigger_error(call_user_func_array("sprintf", $args), E_USER_ERROR);
+       }
+       
+       exit;
+}
+
+function mkfifo($path) {
+       if (!isfifo($path, $stat)) {
+               $stat and unlink($path);
+               if (!posix_mkfifo($path, 0660)) {
+                       return false;
+               }
+       }
+       return fopen($path, "r+");
+}
+
+function isfifo($path, &$stat = null) {
+       return ($stat = @stat($path)) && ($stat["mode"] & POSIX_S_IFIFO);
+}
+
+class Client
+{
+       protected $session;
+       protected $channel;
+       protected $keyword;
+       protected $joined;
+       protected $queue = array();
+       
+       function __construct($url, callable $onJoin) {
+               if (!$url = parse_url($url)) {
+                       fatal("could not parse url: '%s'", $url);
+               }
+               
+               $this->session = $session = new irc\client\Session(
+                       $url["user"],
+                       $url["user"],
+                       $url["user"]
+               );
+               
+               @list($this->channel, $this->keyword) = 
+                       explode(" ", $url["fragment"]);
+               
+               $session->onConnect = $session->onPart = function($origin, array $args) {
+                       $this->joined = false;
+                       $this->session->doJoin("#".$this->channel, $this->keyword);
+               };
+               $session->onJoin = function($origin, array $args) use ($onJoin) {
+                       $this->joined = true;
+                       $onJoin($this, $origin, $args);
+               };
+               $session->doConnect(false, $url["host"], @$url["port"]?:6667, @$url["pass"]);
+       }
+       
+       function send($message = null) {
+               if (isset($message)) {
+                       $this->queue[] = $message;
+               }
+               
+               if ($this->joined) {
+                       while ($this->queue) {
+                               $this->session->doMsg("#".$this->channel, array_shift($this->queue));
+                       }
+               }
+       }
+       
+       function getSession() {
+               return $this->session;
+       }
+}
+
+if (!extension_loaded("ircclient")) {
+       fatal("ext/ircclient not loaded");
+}
+
+# vim: noet
diff --git a/share/btr/report/irc.mk b/share/btr/report/irc.mk
new file mode 100644 (file)
index 0000000..7360fa6
--- /dev/null
@@ -0,0 +1,12 @@
+.PHONY: 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";
+
+# vim: noet
diff --git a/share/btr/report/mail.mk b/share/btr/report/mail.mk
new file mode 100644 (file)
index 0000000..d16a646
--- /dev/null
@@ -0,0 +1,15 @@
+REPORT_ARGS=$(USER)
+
+.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)
+
+# vim: noet
diff --git a/share/btr/report/notify-send.mk b/share/btr/report/notify-send.mk
new file mode 100644 (file)
index 0000000..cfc20cc
--- /dev/null
@@ -0,0 +1,12 @@
+.PHONY: all
+.SUFFIXES:
+
+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";
+
+# vim: noet
diff --git a/share/btr/report/twilio.mk b/share/btr/report/twilio.mk
new file mode 100644 (file)
index 0000000..54ac53a
--- /dev/null
@@ -0,0 +1,11 @@
+.PHONY: all
+.SUFFIXES:
+
+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))" \
+       -u $(TWILIO_ACCOUNT):$(TWILIO_TOKEN)
+
+# vim: noet
diff --git a/share/btr/source/cvs.mk b/share/btr/source/cvs.mk
new file mode 100644 (file)
index 0000000..839efa2
--- /dev/null
@@ -0,0 +1,31 @@
+SOURCE_CLEAN=false
+CVSROOT=$(shell cut -d'\#' -f1 <<<$(SOURCE_ARGS))
+CVS_MOD=$(shell cut -d'\#' -f2 -s <<<$(SOURCE_ARGS))
+CVS_RSH=ssh
+
+export
+
+ifeq ($(value QUIET_FLAG), -q)
+override QUIET_FLAG = -Q
+endif
+
+.PHONY: all clean login
+.SUFFIXES:
+
+all: $(BRANCH_DIR) clean
+       $(SAY) "Updating $(BRANCH)..."
+       cd $(BRANCH_DIR) && \
+               cvs $(QUIET_FLAG) -z3 update -RPd;
+
+clean: $(BRANCH_DIR)
+       if $(SOURCE_CLEAN); \
+       then \
+               cd $(BRANCH_DIR) && \
+                       cvs $(QUIET_FLAG) -z3 update -CRPd; \
+       fi;
+
+$(BRANCH_DIR):
+       $(SAY) "Performing checkout of $(CVS_MOD) from $(CVSROOT)..."
+       cvs $(QUIET_FLAG) checkout -RP -r $(BRANCH) -d $(BRANCH_DIR) $(CVS_MOD)
+
+# vim: noet
diff --git a/share/btr/source/git.mk b/share/btr/source/git.mk
new file mode 100644 (file)
index 0000000..3808590
--- /dev/null
@@ -0,0 +1,31 @@
+SOURCE_CLEAN=false
+
+.PHONY: fetch all clean
+.SUFFIXES:
+
+all: $(BRANCH_DIR) clean fetch
+       $(SAY) "Merging $(BRANCH) of $(REPO)..."
+       cd $(BRANCH_DIR) && \
+               git merge $(QUIET_FLAG) --ff-only;
+
+clean: $(BRANCH_DIR)
+       if $(SOURCE_CLEAN); \
+       then \
+               cd $(BRANCH_DIR) && \
+                       git reset --hard $(QUIET_FLAGS); \
+       fi;
+
+fetch: $(CLEAN_DIR)
+       $(SAY) "Fetching $(REPO)..."
+       cd $(CLEAN_DIR) && \
+               git fetch $(QUIET_FLAG);
+
+$(CLEAN_DIR):
+       $(SAY) "Cloning from $(SOURCE_ARGS)..."
+       git clone $(QUIET_FLAG) $(SOURCE_ARGS) $(CLEAN_DIR);
+
+$(BRANCH_DIR): $(CLEAN_DIR)
+       $(SAY) "Creating workdir for $(BRANCH)"
+       git-new-workdir $(CLEAN_DIR) $(BRANCH_DIR) $(BRANCH)
+
+# vim: noet
diff --git a/share/btr/source/svn.mk b/share/btr/source/svn.mk
new file mode 100644 (file)
index 0000000..b18782e
--- /dev/null
@@ -0,0 +1,22 @@
+SOURCE_CLEAN=false
+
+.PHONY: all clean
+.SUFFIXES:
+
+all: $(BRANCH_DIR) clean
+       $(SAY) "Updating $(BRANCH)..."
+       cd $(BRANCH_DIR) && \
+               svn update $(QUIET_FLAG);
+
+clean: $(BRANCH_DIR)
+       if $(SOURCE_CLEAN); \
+       then \
+               cd $(BRANCH_DIR) && \
+                       svn revert $(QUIET_FLAG); \
+       fi;
+
+$(BRANCH_DIR):
+       $(SAY) "Performing checkout from $(SOURCE_ARGS)..."
+       svn checkout $(QUIET_FLAG) $(SOURCE_ARGS)/$(BRANCH) $(BRANCH_DIR)
+
+# vim: noet