From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 8AA42E00B3D; Thu, 12 Nov 2015 04:27:40 -0800 (PST) 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 * [192.55.52.88 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 0A90DE00A9C for ; Thu, 12 Nov 2015 04:27:37 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 12 Nov 2015 04:27:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,281,1444719600"; d="scan'208";a="848847631" Received: from linux.intel.com ([10.23.219.25]) by orsmga002.jf.intel.com with ESMTP; 12 Nov 2015 04:27:37 -0800 Received: from vmed.fi.intel.com (vmed.fi.intel.com [10.237.72.51]) by linux.intel.com (Postfix) with ESMTP id 59E046A4083 for ; Thu, 12 Nov 2015 04:26:32 -0800 (PST) From: Ed Bartosh To: toaster@yoctoproject.org Date: Thu, 12 Nov 2015 13:55:15 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [PATCH 01/26] toaster: don't allow to run toaster as a script 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: Thu, 12 Nov 2015 12:27:40 -0000 Removed support of starting toaster as a script. Sourcing a toaster script becomes the only way to start it. It's consistent with the way oe build system is started by sourcing oe-init-build-env. It also returns user back to shell, so user can continue running builds without having to open new terminal window. [YOCTO #8279] Signed-off-by: Ed Bartosh --- bitbake/bin/toaster | 82 ++++------------------------------------------------- 1 file changed, 6 insertions(+), 76 deletions(-) diff --git a/bitbake/bin/toaster b/bitbake/bin/toaster index 2c3432c..d59a8c8 100755 --- a/bitbake/bin/toaster +++ b/bitbake/bin/toaster @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/echo ERROR: This script needs to be sourced. Please run as . # (c) 2013 Intel Corp. # This program is free software; you can redistribute it and/or modify @@ -81,9 +81,7 @@ webserverStartAll() return $retval fi - if [ "$TOASTER_MANAGED" = '1' ]; then - python $BBBASEDIR/lib/toaster/manage.py checksettings --traceback || retval=1 - fi + python $BBBASEDIR/lib/toaster/manage.py checksettings --traceback || retval=1 if [ $retval -eq 1 ]; then printf "\nError while checking settings; aborting\n" @@ -176,8 +174,6 @@ else TOASTER=$0 fi -[ `basename \"$0\"` = `basename \"${TOASTER}\"` ] && TOASTER_MANAGED=1 - BBBASEDIR=`dirname $TOASTER`/.. RUNNING=0 @@ -201,7 +197,7 @@ if [ "$TOASTER_CONF" = "" ]; then fi if [ ! -f $TOASTER_CONF ]; then echo "$TOASTER_CONF configuration file not found. set TOASTER_CONF to specify a path" - [ "$TOASTER_MANAGED" = '1' ] && exit 1 || return 1 + return 1 fi # this defines the dir toaster will use for # 1) clones of layers (in _toaster_clones ) @@ -234,88 +230,22 @@ for param in $*; do esac done -if [ "$TOASTER_MANAGED" = '1' ]; 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. - - if ! verify_prereq; then - echo "Error: Could not verify that the needed dependencies are installed. Please use virtualenv and pip to install dependencies listed in toaster-requirements.txt" 1>&2 - exit 1 - fi - - if [ -n "$BUILDDIR" ]; then - printf "Error: It looks like you sourced oe-init-build-env. Toaster cannot start in build mode from an oe-core build environment.\n You should be starting Toaster from a new terminal window.\n" 1>&2 - exit 1 - fi - - # Define a fake builddir where only the pid files are actually created. No real builds will take place here. - BUILDDIR=/tmp/toaster_$$ - if [ -d "$BUILDDIR" ]; then - echo "Previous toaster run directory $BUILDDIR found, cowardly refusing to start. Please remove the directory when that toaster instance is over" 2>&1 - exit 1 - fi - - mkdir -p "$BUILDDIR" - - RUNNING=1 - trap_ctrlc() { - echo "** Stopping system" - webserverKillAll - RUNNING=0 - } - - do_cleanup() { - find "$BUILDDIR" -type f | xargs rm - rmdir "$BUILDDIR" - } - cleanup() { - if grep -ir error "$BUILDDIR" >/dev/null; then - if grep -irn "That port is already in use" "$BUILDDIR"; then - echo "You can use the \"webport=PORTNUMBER\" parameter to start Toaster on a different port (port $WEB_PORT is already in use)" - do_cleanup - else - printf "\nErrors found in the Toaster log files present in '$BUILDDIR'. Directory will not be cleaned.\n Please review the errors and notify toaster@yoctoproject.org or submit a bug https://bugzilla.yoctoproject.org/enter_bug.cgi?product=Toaster" - fi - else - echo "No errors found, removing the run directory '$BUILDDIR'" - do_cleanup - fi - } - export TOASTER_MANAGED=1 - if [ $WEBSERVER -gt 0 ] && ! webserverStartAll; then - echo "Failed to start the web server, stopping" 1>&2 - cleanup - exit 1 - fi - if [ $WEBSERVER -gt 0 ] && [ $NOBROWSER -eq 0 ] ; then - echo "Starting browser..." - xdg-open http://127.0.0.1:$WEB_PORT/ >/dev/null 2>&1 & - fi - trap trap_ctrlc 2 - echo "Toaster is now running. You can stop it with Ctrl-C" - while [ $RUNNING -gt 0 ]; do - python $BBBASEDIR/lib/toaster/manage.py runbuilds 2>&1 | tee -a "$BUILDDIR/toaster.log" - sleep 1 - done - cleanup - echo "**** Exit" - exit 0 +if [ `basename \"$0\"` = `basename \"${TOASTER}\"` ]; then + echo "Error: This script needs to be sourced. Please run as . $TOASTER" + exit 1 fi - if ! verify_prereq; then echo "Error: Could not verify that the needed dependencies are installed. Please use virtualenv and pip to install dependencies listed in toaster-requirements.txt" 1>&2 return 1 fi - # We make sure we're running in the current shell and in a good environment 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 [ "$1" = 'start' ] || [ "$1" = 'stop' ]; then CMD="$1" -- 2.1.4