6 echo "Usage: $(basename $0) [-hyvq] [<options>] [action] <build>"
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"
14 echo " -D, --directory=<directory>"
15 echo " Use this directory as work root"
18 echo " s[tatus] Show the status of the build"
19 echo " r[un] Make a BTR run"
20 echo " c[ancel] Cancel any currently running BTR job"
21 echo " t[erminate] Terminate the BTR daemon"
24 echo " <build> The build id of the \`btrd\` daemon, usually"
25 echo " something like \$repository@\$branch[-\$suffix]."
31 function btrc-parseargs
{
48 if test -z "$BTR_BUILD"
52 error
"Unknown action: '$BTR_BUILD' for build id '$1'!"
60 function btrc-parseopts
{
61 local shortoptions
="hvqyD:"
62 local longoptions
="help,verbose,quiet,yes,directory:"
63 local options
=$
(getopt \
64 --options "$shortoptions" \
65 --longoptions "$longoptions" \
69 if test $?
-ne 0 ; then
73 eval set -- "$options"
105 export -f btrc-parseopts
107 function btrc-setup
{
108 if test -z "$BTR_BUILD"
113 if test -z "$BTR_ACTION"
121 BTR_PIDFILE
="$BTR_RUNDIR/$BTR_BUILD.pid"
122 BTR_LOGFILE
="$BTR_RUNDIR/$BTR_BUILD.log"
123 BTR_COMFILE
="$BTR_RUNDIR/$BTR_BUILD.socket"
125 if test -r "$BTR_PIDFILE"
127 export BTR_PIDFILE BTR_LOGFILE BTR_COMFILE
129 if test -e "$BTR_LOGFILE"
134 error
"Could not find pid file of btr daemon for '$BTR_BUILD' in $BTR_RUNDIR."
139 function btrc-signal
{
141 local pid
=$
(cat "$BTR_PIDFILE")
146 $SAY -n "Waiting for the daemon to shutdown..."
147 while kill -s 0 $pid &>/dev
/null
156 export -f btrc-signal