bitbake: toaster: Make toaster script working in zsh
PATCH 1/1 bitbake: toaster: Make toaster script working in zsh
Fixed shell syntax not understood by zsh. Made toaster script to work for both shells in both modes: sourced and directly called.
[YOCTO #6964]
--- bitbake/bin/toaster | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
bitbake/bin/toaster +13 -13
@@ -63,7 +63,7 @@ function webserverStartAll() retval=0 python $BBBASEDIR/lib/toaster/manage.py migrate orm || retval=1 fi - if [ "x$TOASTER_MANAGED" == "x1" ]; then + if [ "$TOASTER_MANAGED" '==' '1' ]; then python $BBBASEDIR/lib/toaster/manage.py migrate bldcontrol || retval=1 python $BBBASEDIR/lib/toaster/manage.py checksettings --traceback || retval=1 fi
@@ -97,7 +97,7 @@ INSTOPSYSTEM=0 function stop_system() { # prevent reentry - if [ $INSTOPSYSTEM == 1 ]; then return; fi + if [ $INSTOPSYSTEM -eq 1 ]; then return; fi INSTOPSYSTEM=1 if [ -f ${BUILDDIR}/.toasterui.pid ]; then kill $(< ${BUILDDIR}/.toasterui.pid ) 2>/dev/null
@@ -119,7 +119,7 @@ function check_pidbyfile() { function notify_chldexit() { - if [ $NOTOASTERUI == 0 ]; then + if [ $NOTOASTERUI -eq 0 ]; then check_pidbyfile ${BUILDDIR}/.toasterui.pid && return stop_system fi
@@ -143,8 +143,7 @@ function verify_prereq() { # read command line parameters - -BBBASEDIR=`dirname ${BASH_SOURCE}`/.. +BBBASEDIR=`dirname ${BASH_SOURCE:-${(%):-%x}}`/.. RUNNING=0 NOTOASTERUI=0
@@ -168,8 +167,9 @@ for param in $*; do esac done +[ -z "$ZSH_NAME" ] && SRCFILE=${BASH_SOURCE} || SRCFILE=$_ -if [ -z "$ZSH_NAME" ] && [ `basename \"$0\"` = `basename \"$BASH_SOURCE\"` ]; then +if [ `basename \"$0\"` = `basename \"${SRCFILE}\"` ]; then # We are called as standalone. We refuse to run in a build environment - we need the interactive mode for that. # Start just the web server, point the web browser to the interface, and start any Django services.
@@ -183,7 +183,7 @@ if [ -z "$ZSH_NAME" ] && [ `basename \"$0\"` = `basename \"$BASH_SOURCE\"` ]; th exit 1; fi - if [ "x`which daemon`" == "x" ]; then + if ! which daemon >/dev/null 2>&1; then echo -e "Failed dependency; toaster needs the 'daemon' program in order to be able to start builds'. Please install the 'daemon' program from your distribution repositories or http://www.libslack.org/daemon/" 1>&2; exit 1; fi
@@ -251,14 +251,14 @@ fi # We make sure we're running in the current shell and in a good environment -if [ -z "$BUILDDIR" ] || [ -z `which bitbake` ]; then +if [ -z "$BUILDDIR" ] || ! which bitbake >/dev/null 2>&1 ; then echo "Error: Build environment is not setup or bitbake is not in path." 1>&2; return 2 fi # Determine the action. If specified by arguments, fine, if not, toggle it -if [ "x$1" == "xstart" ] || [ "x$1" == "xstop" ]; then +if [ "$1" '==' 'start' ] || [ "$1" '==' 'stop' ]; then CMD="$1" else if [ -z "$BBSERVER" ]; then
@@ -274,16 +274,16 @@ echo "The system will $CMD." lock=1 if [ -e $BUILDDIR/bitbake.lock ]; then - (flock -n 200 ) 200<$BUILDDIR/bitbake.lock || lock=0 + python -c "import fcntl; fcntl.flock(open(\"$BUILDDIR/bitbake.lock\"), fcntl.LOCK_EX|fcntl.LOCK_NB)" 2>/dev/null || lock=0 fi -if [ ${CMD} == "start" ] && [ $lock -eq 0 ]; then +if [ ${CMD} '==' 'start' ] && [ $lock -eq 0 ]; then echo "Error: bitbake lock state error. File locks show that the system is on." 1>&2 echo "Please wait for the current build to finish, stop and then start the system again." 1>&2 return 3 fi -if [ ${CMD} == "start" ] && [ -e $BUILDDIR/.toastermain.pid ] && kill -0 `cat $BUILDDIR/.toastermain.pid`; then +if [ ${CMD} '==' 'start' ] && [ -e $BUILDDIR/.toastermain.pid ] && kill -0 `cat $BUILDDIR/.toastermain.pid`; then echo "Warning: bitbake appears to be dead, but the Toaster web server is running. Something fishy is going on." 1>&2 echo "Cleaning up the web server to start from a clean slate." webserverKillAll
@@ -311,7 +311,7 @@ case $CMD in echo "Bitbake server start failed" else export BBSERVER=0.0.0.0:-1 - if [ $NOTOASTERUI == 0 ]; then # we start the TOASTERUI only if not inhibited + if [ $NOTOASTERUI -eq 0 ]; then # we start the TOASTERUI only if not inhibited bitbake --observe-only -u toasterui >>${BUILDDIR}/toaster_ui.log 2>&1 & echo $! >${BUILDDIR}/.toasterui.pid fi fi
Signature · 1 line
2.1.4
Taken for submission,
Thank you,
Alex
Quoted 148 lines · Ed Bartosh
Fixed shell syntax not understood by zsh. Made toaster script to work for both shells in both modes: sourced and directly called.
[YOCTO #6964]
Signed-off-by Ed Bartosh <[email protected]>--- bitbake/bin/toaster | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)bitbake/bin/toaster +0
-0@@ -63,7 +63,7 @@ function webserverStartAll() retval=0 python $BBBASEDIR/lib/toaster/manage.py migrate orm ||retval=1
fibitbake/bin/toaster +1
-1- if [ "x$TOASTER_MANAGED" == "x1" ]; then + if [ "$TOASTER_MANAGED" '==' '1' ]; then python $BBBASEDIR/lib/toaster/manage.py migrate bldcontrol|| retval=1
python$BBBASEDIR/lib/toaster/manage.pychecksettings
--traceback || retval=1
fibitbake/bin/toaster +4
-5@@ -97,7 +97,7 @@ INSTOPSYSTEM=0 function stop_system() { # prevent reentry - if [ $INSTOPSYSTEM == 1 ]; then return; fi + if [ $INSTOPSYSTEM -eq 1 ]; then return; fi INSTOPSYSTEM=1 if [ -f ${BUILDDIR}/.toasterui.pid ]; then kill $(< ${BUILDDIR}/.toasterui.pid ) 2>/dev/null@@ -119,7 +119,7 @@ function check_pidbyfile() { function notify_chldexit() { - if [ $NOTOASTERUI == 0 ]; then + if [ $NOTOASTERUI -eq 0 ]; then check_pidbyfile ${BUILDDIR}/.toasterui.pid && return stop_system fi@@ -143,8 +143,7 @@ function verify_prereq() { # read command line parameters - -BBBASEDIR=`dirname ${BASH_SOURCE}`/.. +BBBASEDIR=`dirname ${BASH_SOURCE:-${(%):-%x}}`/.. RUNNING=0 NOTOASTERUI=0@@ -168,8 +167,9 @@ for param in $*; do esac done +[ -z "$ZSH_NAME" ] && SRCFILE=${BASH_SOURCE} || SRCFILE=$_ -if [ -z "$ZSH_NAME" ] && [ `basename \"$0\"` = `basename\"$BASH_SOURCE\"` ]; then
+if [basename \"$0\"=basename \"${SRCFILE}\"]; then
# We are called as standalone. We refuse to run in a build
environment - we need the interactive mode for that.
# Start just the web server, point the web browser to the interface,
and start any Django services.bitbake/bin/toaster +0
-0@@ -183,7 +183,7 @@ if [ -z "$ZSH_NAME" ] && [ `basename \"$0\"` =
basename \"$BASH_SOURCE\"]; thexit 1; fibitbake/bin/toaster +1
-1- if [ "x`which daemon`" == "x" ]; then + if ! which daemon >/dev/null 2>&1; then echo -e "Failed dependency; toaster needs the 'daemon' program inorder to be able to start builds'. Please install the 'daemon' program from
your distribution repositories or http://www.libslack.org/daemon/" 1>&2; exit 1; fibitbake/bin/toaster +0
-0@@ -251,14 +251,14 @@ fi # We make sure we're running in the current shell and in a goodenvironment
bitbake/bin/toaster +1
-1-if [ -z "$BUILDDIR" ] || [ -z `which bitbake` ]; then +if [ -z "$BUILDDIR" ] || ! which bitbake >/dev/null 2>&1 ; then echo "Error: Build environment is not setup or bitbake is not inpath." 1>&2;
return 2
fi# Determine the action. If specified by arguments, fine, if not, toggle it
bitbake/bin/toaster +2
-2-if [ "x$1" == "xstart" ] || [ "x$1" == "xstop" ]; then +if [ "$1" '==' 'start' ] || [ "$1" '==' 'stop' ]; then CMD="$1" else if [ -z "$BBSERVER" ]; then@@ -274,16 +274,16 @@ echo "The system will $CMD." lock=1 if [ -e $BUILDDIR/bitbake.lock ]; then - (flock -n 200 ) 200<$BUILDDIR/bitbake.lock || lock=0 + python -c "import fcntl;
fcntl.flock(open(\"$BUILDDIR/bitbake.lock\"), fcntl.LOCK_EX|fcntl.LOCK_NB)" 2>/dev/null || lock=0
fibitbake/bin/toaster +1
-1-if [ ${CMD} == "start" ] && [ $lock -eq 0 ]; then +if [ ${CMD} '==' 'start' ] && [ $lock -eq 0 ]; then echo "Error: bitbake lock state error. File locks show that thesystem is on." 1>&2
echo "Please wait for the current build to finish, stop and then
start the system again." 1>&2
return 3
fi-if [ ${CMD} == "start" ] && [ -e $BUILDDIR/.toastermain.pid ] && kill -0
cat $BUILDDIR/.toastermain.pid; then
+if [ ${CMD} '==' 'start' ] && [ -e $BUILDDIR/.toastermain.pid ] && kill -0cat $BUILDDIR/.toastermain.pid; then
echo "Warning: bitbake appears to be dead, but the Toaster web server
is running. Something fishy is going on." 1>&2
echo "Cleaning up the web server to start from a clean slate." webserverKillAllbitbake/bin/toaster +0
-1@@ -311,7 +311,7 @@ case $CMD in echo "Bitbake server start failed" else export BBSERVER=0.0.0.0:-1 - if [ $NOTOASTERUI == 0 ]; then # we start theTOASTERUI only if not inhibited
+ if [ $NOTOASTERUI -eq 0 ]; then # we start the
TOASTERUI only if not inhibitedbitbake --observe-only -u toasteruiQuoted 1 line
Quoted 1 line
${BUILDDIR}/toaster_ui.log 2>&1 & echo $! >${BUILDDIR}/.toasterui.pid
fi
fi
--
2.1.4--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster
Signature · 3 lines
Alex Damian Yocto Project SSG / OTC