3 export BTR_DATE
=$
(date +%Y
%m
%d
%H
%M
%S
)
4 export BTR_CPUS
=${CPUS:-@BTR_CPUS@}
5 export BTR_PROG
=$
(basename "$0")
7 export BTR_VERBOSE
=false
8 export BTR_FORCEYES
=false
17 echo "$BTR_PROG v@PACKAGE_VERSION@, (c) Michael Wallner <mike@php.net>"
25 function btr_confirm
{
44 function btr_setup_rundir
{
45 local default_rundir
="${1:-/tmp/btr}"
47 if test -z "$BTR_RUNDIR"
49 export BTR_RUNDIR
="$default_rundir"
54 mkdir
-p "$BTR_RUNDIR" || error
"Could not create directory '$BTR_RUNDIR'"
56 export -f btr_setup_rundir
58 btr_verbose_echo_n
=false
59 function btr_verbose_echo
{
60 if test "$1" != "-n"; then
61 $btr_verbose_echo_n ||
echo
62 btr_verbose_echo_n
=false
64 btr_verbose_echo_n
=true
68 export -f btr_verbose_echo
70 function btr_setup_verbosity
{
71 local for_make
=${1:-false}
73 if ${BTR_VERBOSE:-false}
78 SAY
="btr_verbose_echo"
97 export BTR_QUIET BTR_VERBOSE BTR_FORCEYES BTR_QUIET_FLAG BTR_SILENT_FLAG BTR_VERBOSE_FLAG SAY
99 export -f btr_setup_verbosity
101 function btr_shortoptions
{
106 for f
in common
$BTR_PROG
110 test -e "$BTR_LIBDIR/$f.$e" && cut
-sf1 <"$BTR_LIBDIR/$f.$e"
113 ) |
xargs |
tr -d " "
115 export -f btr_shortoptions
117 function btr_longoptions
{
122 for f
in common
$BTR_PROG
126 test -e "$BTR_LIBDIR/$f.$e" && cut
-sf2 <"$BTR_LIBDIR/$f.$e"
129 ) |
sed 's/\(:\).*/\1/' |
xargs |
tr " " ","
131 export -f btr_longoptions
138 for f
in common
$BTR_PROG
140 test -e "$BTR_LIBDIR/$f.flags" && cut
-sf1 <"$BTR_LIBDIR/$f.flags"
142 ) |
xargs |
tr -d " "
146 function btr_help_options
{
148 for f
in common
$BTR_PROG
150 test -e "$BTR_LIBDIR/$f.$1" && "$BTR_LIBDIR/opt.awk" <"$BTR_LIBDIR/$f.$1"
167 export -f btr_help_options
169 function btr_help_args
{
172 if test -e "$BTR_LIBDIR/$BTR_PROG.args"
176 sed -e 's/#.*//' -e '/^$/d' < "$BTR_LIBDIR/$BTR_PROG.args" |
while read a d
178 test -z "$a" && continue
179 printf "%b\n" "$d" |
fold -sw46 |
while read l
181 printf " %-16s %s\n" "$a" "$l"
188 export -f btr_help_args
191 if test -e "$BTR_LIBDIR/$BTR_PROG.args"
193 cut
-sf1 <"$BTR_LIBDIR/$BTR_PROG.args" |
xargs
200 echo "Usage: $BTR_PROG [-$(btr_flags)] [<options>]" $
(btr_args
)
201 btr_help_options flags
202 btr_help_options opts
204 if test $BTR_PROG != "btrc"
207 echo " Rules format:"
208 echo " type=arg e.g: notify-send=\"-u low\""
209 echo " mail=\"-c copy@to rcpt@to\""
210 echo " irc=\"tcp://btr@chat.freenode.org/#btr\""
211 echo " git=\$HOME/src/btr.git"
213 echo " Note though, that some rules do not use any argument."
216 for ruleset
in source build report
218 printf " %10s: %s\n" $ruleset \
219 "$(find "$BTR_LIBDIR/$ruleset" -name '*.mk' -exec basename {} .mk \; | sort | xargs)"
227 function btr_parseopts
{
228 local shortoptions
="$(btr_shortoptions common btr-flags btr-options)"
229 local longoptions
="$(btr_longoptions common btr-flags btr-options)"
234 --options "$shortoptions" \
235 --longoptions "$longoptions" \
243 eval set -- "$options"
267 BTR_SOURCE_CLEAN
=true
295 test -z "$BTR_BRANCH" && BTR_BRANCH
=master
298 test -z "$BTR_BRANCH" && BTR_BRANCH
=trunk
301 test -z "$BTR_BRANCH" && BTR_BRANCH
=HEAD
304 BTR_SOURCE_RULES
="$(cut -d= -f1 <<<$2)"
305 BTR_SOURCE_ARGS
="$(cut -s -d= -f2- <<<$2)"
309 BTR_BUILD_RULES
="$(cut -d= -f1 <<<$2)"
310 BTR_BUILD_ARGS
="$(cut -s -d= -f2- <<<$2)"
314 BTR_REPORT_RULES
="$(cut -d= -f1 <<<$2)"
315 BTR_REPORT_ARGS
="$(cut -s -d= -f2- <<<$2)"
328 export -f btr_parseopts
330 function btr_conf_dump
{
331 echo "BTR_QUIET='$BTR_QUIET'"
332 echo "BTR_VERBOSE='$BTR_VEROSE'"
333 echo "BTR_FORCEYES='$BTR_FORCEYES'"
334 echo "BTR_BRANCH='$BTR_BRANCH'"
335 echo "BTR_SUFFIX='$BTR_SUFFIX'"
336 echo "BTR_RUNDIR='$BTR_RUNDIR'"
337 echo "BTR_SOURCE_RULES='$BTR_SOURCE_RULES'"
338 test ${BTR_SOURCE_ARGS+defined} && echo "BTR_SOURCE_ARGS='$BTR_SOURCE_ARGS'"
339 test ${BTR_SOURC_CLEAN+defined} && echo "BTR_SOURCE_CLEAN='$BTR_SOURCE_CLEAN'"
340 echo "BTR_BUILD_RULES='$BTR_BUILD_RULES'"
341 test ${BTR_BUILD_ARGS+defined} && echo "BTR_BUILD_ARGS='$BTR_BUILD_ARGS'"
342 test ${BTR_BUILD_CLEAN+defined} && echo "BTR_BUILD_CLEAN='$BTR_BUILD_CLEAN'"
343 test ${BTR_TEST_ARGS+defined} && echo "BTR_TEST_ARGS='$BTR_TEST_ARGS'"
344 echo "BTR_REPORT_RULES='$BTR_REPORT_RULES'"
345 test ${BTR_REPORT_ARGS+defined} && echo "BTR_REPORT_ARGS='$BTR_REPORT_ARGS'"
347 export -f btr_conf_dump