-function btr-help {
- btr-banner
- 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 "$BTR_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
-}
-export -f btr-help
-
-function btr-parseopts {
- local shortoptions="hvqycCf:T:B:D:S:s:b:r:"
- local longoptions="help,verbose,quiet,yes,clean,vcsclean,config:,test:,branch:,directory:,suffix:,source:,build:,report:"
- local options=$(getopt \
- --options "$shortoptions" \
- --longoptions "$longoptions" \
- -- "$@" \
- )
-
- if test $? -ne 0 ; then
- help
- fi
-
- eval set -- "$options"
-
- while test $# -gt 0
- do
- case "$1" in
- -h|--help)
- btr-help
- ;;
- -v|--verbose)
- BTR_QUIET=false
- BTR_VERBOSE=true
- ;;
- -q|--quiet)
- BTR_QUIET=true
- BTR_VERBOSE=false
- ;;
- -y|--yes)
- BTR_FORCEYES=true
- ;;
- -c|--clean)
- BTR_BUILD_CLEAN=true
- ;;
- -C|--vcsclean)
- BTR_SOURCE_CLEAN=true
- ;;
- ####
- -f|--config)
- source "$2"
- shift
- ;;
- ####
- -B|--branch)
- BTR_BRANCH="$2"
- shift
- ;;
- -D|--directory)
- BTR_RUNDIR="$2"
- shift
- ;;
- -S|--suffix)
- BTR_SUFFIX="$2"
- shift
- ;;
- -T|--test)
- BTR_TEST_ARGS="$2"
- shift
- ;;
- ####
- -s|--source)
- case "$2" in
- git*)
- test -z "$BTR_BRANCH" && BTR_BRANCH=master
- ;;
- svn*)
- test -z "$BTR_BRANCH" && BTR_BRANCH=trunk
- ;;
- cvs*)
- test -z "$BTR_BRANCH" && BTR_BRANCH=HEAD
- ;;
- esac
- BTR_SOURCE_RULES="$(cut -d= -f1 <<<$2)"
- BTR_SOURCE_ARGS="$(cut -s -d= -f2- <<<$2)"
- shift
- ;;
- -b|--build)
- BTR_BUILD_RULES="$(cut -d= -f1 <<<$2)"
- BTR_BUILD_ARGS="$(cut -s -d= -f2- <<<$2)"
- shift
- ;;
- -r|--report)
- BTR_REPORT_RULES="$(cut -d= -f1 <<<$2)"
- BTR_REPORT_ARGS="$(cut -s -d= -f2- <<<$2)"
- shift
- ;;
- ####
- --)
- # legacy
- if test "$2"
- then
- BTR_SOURCE_ARGS="$2"
- fi
- shift
- ;;
- esac
- shift
- done
-}
-export -f btr-parseopts
-
-function btr-setup {