Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id A600BE009CD; Mon, 4 May 2015 02:17:12 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high * trust * [134.134.136.24 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 69FA5E009A6 for ; Mon, 4 May 2015 02:16:56 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 04 May 2015 02:16:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,365,1427785200"; d="scan'208";a="689487882" Received: from linux.intel.com ([10.23.219.25]) by orsmga001.jf.intel.com with ESMTP; 04 May 2015 02:16:55 -0700 Received: from vmed.fi.intel.com (vmed.fi.intel.com [10.237.72.65]) by linux.intel.com (Postfix) with ESMTP id 6D0A36A408F; Mon, 4 May 2015 02:16:27 -0700 (PDT) From: Ed Bartosh To: toaster@yoctoproject.org Date: Mon, 4 May 2015 12:16:48 +0300 Message-Id: <1430731008-4213-1-git-send-email-ed.bartosh@linux.intel.com> X-Mailer: git-send-email 2.1.4 Subject: [review-request][PATCH] bitbake: toaster: Make toaster script working in zsh X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2015 09:17:12 -0000 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 --- bitbake/bin/toaster | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/bitbake/bin/toaster b/bitbake/bin/toaster index 7907b57..dde4519 100755 --- a/bitbake/bin/toaster +++ b/bitbake/bin/toaster @@ -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 -- 2.1.4