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
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
#!/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]));
#!/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]));
+++ /dev/null
-#!/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
+++ /dev/null
-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
+++ /dev/null
-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
+++ /dev/null
-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
+++ /dev/null
-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
+++ /dev/null
-<?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
+++ /dev/null
-.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
+++ /dev/null
-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
+++ /dev/null
-.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
+++ /dev/null
-.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
+++ /dev/null
-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
+++ /dev/null
-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
+++ /dev/null
-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
--- /dev/null
+#!/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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+<?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
--- /dev/null
+.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
--- /dev/null
+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
--- /dev/null
+.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
--- /dev/null
+.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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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