4 echo "btr v0.3.0, (c) Michael Wallner <mike@php.net>"
6 echo "Usage: $(basename $0) [-hyvqcC] [<options>]"
8 echo " -h, --help Display this help"
9 echo " -y, --yes Always assume yes"
10 echo " -v, --verbose Be more verbose"
11 echo " -q, --quiet Be more quiet"
12 echo " -c, --clean Clean build"
13 echo " -C, --vcsclean Clean repo/branch"
16 echo " -f, --config=<file> Read configuration from a file"
17 echo " -s, --source=<rules> Use the specified source ruleset"
18 echo " -b, --build=<rules> Use the specified build ruleset"
19 echo " -r, --report=<rules> Use the specifued report ruleset"
20 echo " -T, --test=<args> Provide test runner arguments"
21 echo " -B, --branch=<branch> Checkout this branch"
22 echo " -D, --directory=<directory> Use this directory as work root"
23 echo " -S, --suffix=<suffix> Append suffix to the build name"
26 echo " type=argument e.g: git=git@github.com:m6w6/btr.git"
27 echo " irc=irc://btr@chat.freenode.org/#btr"
28 echo " mail=\"-c copy@to rcpt@to\""
29 echo " notify-send=\"-u low\""
31 echo " Note though, that some rules do not use any argument."
34 for ruleset
in source build report
36 printf " %10s: %s\n" $ruleset \
37 "$(find "$LIBDIR/$ruleset" -name '*.mk' -exec basename {} .mk \; | sort | xargs)"
42 echo " Clone PHP's git, use PHP-5.5 branch, build with php ruleset and"
43 echo " run the test suite with valgrind (-m) on a debug build and report"
44 echo " the results with a simple OSD notification:"
45 echo " $ btr -s git=git@php.net:php/php-src.git -B PHP-5.5 \\"
46 echo " -b \"php=--enable-debug\" -T-m -r notify-send"
47 echo " See also php.example.conf"
49 echo " Clone CURL's git (use master), build with GNU autotools"
50 echo " ruleset which runs 'make check' and mail the report to the"
51 echo " current user. Verbosely show all actions taken:"
52 echo " $ btr -v -s git=https://github.com/bagder/curl.git -b gnu -r mail"
53 echo " See also curl.example.conf"
59 local shortoptions
="hvqycCf:T:B:D:S:s:b:r:"
60 local longoptions
="help,verbose,quiet,yes,clean,vcsclean,config:,test:,branch:,directory:,suffix:,source:,build:,report:"
61 local options
=$
(getopt \
62 --options "$shortoptions" \
63 --longoptions "$longoptions" \
67 if test $?
-ne 0 ; then
71 eval set -- "$options"
122 test -z "$BRANCH" && BRANCH
=master
125 test -z "$BRANCH" && BRANCH
=trunk
128 test -z "$BRANCH" && BRANCH
=HEAD
131 SOURCE_RULES
="$(cut -d= -f1 <<<$2)"
132 SOURCE_ARGS
="$(cut -s -d= -f2- <<<$2)"
136 BUILD_RULES
="$(cut -d= -f1 <<<$2)"
137 BUILD_ARGS
="$(cut -s -d= -f2- <<<$2)"
141 REPORT_RULES
="$(cut -d= -f1 <<<$2)"
142 REPORT_ARGS
="$(cut -s -d= -f2- <<<$2)"
165 if test -z "$SOURCE_RULES" -o -z "$BUILD_RULES" -o -z "$REPORT_RULES"
189 export QUIET VERBOSE FORCEYES QUIET_FLAG SILENT_FLAG VERBOSE_FLAG SAY
193 export BTRDIR
="/tmp/btr"
195 export BTRDIR
=$
(realpath
"$BTRDIR")
198 mkdir
-p "$BTRDIR" || error
"Could not create $BTRDIR"
201 export SOURCE_RULES BUILD_RULES REPORT_RULES
202 test -z "$SOURCE_ARGS" ||
export SOURCE_ARGS
203 test -z "$SOURCE_CLEAN" ||
export SOURCE_CLEAN
204 test -z "$BUILD_ARGS" ||
export BUILD_ARGS
205 test -z "$BUILD_CLEAN" ||
export BUILD_CLEAN
206 test -z "$TEST_ARGS" ||
export TEST_ARGS
207 test -z "$REPORT_ARGS" ||
export REPORT_ARGS
208 REPO
=$
(basename $
(sed -re 's~^.*[/:#]~~' <<<"$SOURCE_ARGS") .git
)
209 SAFE_BRANCH
=$
(tr ":" "_" <<<$
(basename "$BRANCH"))
210 export REPO BRANCH SAFE_BRANCH
214 export BUILD
="$REPO@$SAFE_BRANCH"
216 export BUILD
="$REPO@$SAFE_BRANCH-$SUFFIX"
219 export CLEAN_DIR
="btr+clean-$REPO"
220 export BRANCH_DIR
="btr+branch-$REPO@$SAFE_BRANCH"
221 export BUILD_DIR
="btr+build-$BUILD"
222 export CONFIG_REPORT
="btr+config-$BUILD-$DATE"
223 export BUILD_REPORT
="btr+build-$BUILD-$DATE"
224 export TEST_REPORT
="btr+tests-$BUILD-$DATE"
225 export LAST_REPORT
=$
(basename $
(ls -t "$BTRDIR/btr+tests-$BUILD"* 2>/dev
/null |
head -n1) 2>/dev
/null
)
226 export REPORT
="btr+report-$BUILD-$DATE"
231 echo "Configuration:"
232 echo "=============="
234 echo "BTRDIR = $BTRDIR"
235 echo "BINDIR = $BINDIR"
236 echo "LIBDIR = $LIBDIR"
238 echo "SOURCE_RULES = $SOURCE_RULES"
239 echo "SOURCE_ARGS = $SOURCE_ARGS"
240 echo "SOURCE_CLEAN = $SOURCE_CLEAN"
241 echo "BUILD_RULES = $BUILD_RULES"
242 echo "BUILD_ARGS = $BUILD_ARGS"
243 echo "BUILD_CLEAN = $BUILD_CLEAN"
244 echo "TEST_ARGS = $TEST_ARGS"
245 echo "REPORT_RULES = $REPORT_RULES"
246 echo "REPORT_ARGS = $REPORT_ARGS"
249 echo "BRANCH = $BRANCH"
250 echo "SAFE_BRANCH = $SAFE_BRANCH"
252 echo "CLEAN_DIR = $CLEAN_DIR"
253 echo "BRANCH_DIR = $BRANCH_DIR"
254 echo "BUILD_DIR = $BUILD_DIR"
255 echo "CONFIG_REPORT = $CONFIG_REPORT"
256 echo "BUILD_REPORT = $BUILD_REPORT"
257 echo "TEST_REPORT = $TEST_REPORT"
258 echo "LAST_REPORT = $LAST_REPORT"