mirror of
https://git.yoctoproject.org/poky
synced 2026-09-14 12:49:34 +02:00
bitbake: toaster: Code cleanup: bashisms
Fixed the following bashisms:
replaced echo -e -> printf
removed 'function' from function definitions
replaced $(< ${file}) -> `cat ${file}`
(Bitbake rev: bd95425c35c7d8386c57329e425aa7802537b479)
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
58cd4a14ea
commit
0eaf070337
@@ -28,23 +28,24 @@
|
|||||||
|
|
||||||
# Helper function to kill a background toaster development server
|
# Helper function to kill a background toaster development server
|
||||||
|
|
||||||
function webserverKillAll()
|
webserverKillAll()
|
||||||
{
|
{
|
||||||
local pidfile
|
local pidfile
|
||||||
for pidfile in ${BUILDDIR}/.toastermain.pid; do
|
for pidfile in ${BUILDDIR}/.toastermain.pid; do
|
||||||
if [ -f ${pidfile} ]; then
|
if [ -f ${pidfile} ]; then
|
||||||
while kill -0 $(< ${pidfile}) 2>/dev/null; do
|
pid=`cat ${pidfile}`
|
||||||
kill -SIGTERM -$(< ${pidfile}) 2>/dev/null
|
while kill -0 $pid 2>/dev/null; do
|
||||||
sleep 1
|
kill -SIGTERM -$pid 2>/dev/null
|
||||||
# Kill processes if they are still running - may happen in interactive shells
|
sleep 1
|
||||||
pkill -U $UID -f "python.*manage.py runserver"
|
# Kill processes if they are still running - may happen in interactive shells
|
||||||
done;
|
ps fux | grep "python.*manage.py runserver" | awk '{print $2}' | xargs kill
|
||||||
rm ${pidfile}
|
done
|
||||||
|
rm ${pidfile}
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function webserverStartAll()
|
webserverStartAll()
|
||||||
{
|
{
|
||||||
# do not start if toastermain points to a valid process
|
# do not start if toastermain points to a valid process
|
||||||
if ! cat "${BUILDDIR}/.toastermain.pid" 2>/dev/null | xargs -I{} kill -0 {} ; then
|
if ! cat "${BUILDDIR}/.toastermain.pid" 2>/dev/null | xargs -I{} kill -0 {} ; then
|
||||||
@@ -62,7 +63,7 @@ function webserverStartAll()
|
|||||||
if [ $retval -eq 1 ]; then
|
if [ $retval -eq 1 ]; then
|
||||||
echo "Failed db sync, stopping system start" 1>&2
|
echo "Failed db sync, stopping system start" 1>&2
|
||||||
elif [ $retval -eq 2 ]; then
|
elif [ $retval -eq 2 ]; then
|
||||||
echo -e "\nError on migration, trying to recover... \n"
|
printf "\nError on migration, trying to recover... \n"
|
||||||
python $BBBASEDIR/lib/toaster/manage.py migrate orm 0001_initial --fake
|
python $BBBASEDIR/lib/toaster/manage.py migrate orm 0001_initial --fake
|
||||||
retval=0
|
retval=0
|
||||||
python $BBBASEDIR/lib/toaster/manage.py migrate orm || retval=1
|
python $BBBASEDIR/lib/toaster/manage.py migrate orm || retval=1
|
||||||
@@ -87,7 +88,7 @@ function webserverStartAll()
|
|||||||
|
|
||||||
# Helper functions to add a special configuration file
|
# Helper functions to add a special configuration file
|
||||||
|
|
||||||
function addtoConfiguration()
|
addtoConfiguration()
|
||||||
{
|
{
|
||||||
file=$1
|
file=$1
|
||||||
shift
|
shift
|
||||||
@@ -98,13 +99,13 @@ function addtoConfiguration()
|
|||||||
INSTOPSYSTEM=0
|
INSTOPSYSTEM=0
|
||||||
|
|
||||||
# define the stop command
|
# define the stop command
|
||||||
function stop_system()
|
stop_system()
|
||||||
{
|
{
|
||||||
# prevent reentry
|
# prevent reentry
|
||||||
if [ $INSTOPSYSTEM -eq 1 ]; then return; fi
|
if [ $INSTOPSYSTEM -eq 1 ]; then return; fi
|
||||||
INSTOPSYSTEM=1
|
INSTOPSYSTEM=1
|
||||||
if [ -f ${BUILDDIR}/.toasterui.pid ]; then
|
if [ -f ${BUILDDIR}/.toasterui.pid ]; then
|
||||||
kill $(< ${BUILDDIR}/.toasterui.pid ) 2>/dev/null
|
kill `cat ${BUILDDIR}/.toasterui.pid` 2>/dev/null
|
||||||
rm ${BUILDDIR}/.toasterui.pid
|
rm ${BUILDDIR}/.toasterui.pid
|
||||||
fi
|
fi
|
||||||
BBSERVER=0.0.0.0:-1 bitbake -m
|
BBSERVER=0.0.0.0:-1 bitbake -m
|
||||||
@@ -117,12 +118,12 @@ function stop_system()
|
|||||||
INSTOPSYSTEM=0
|
INSTOPSYSTEM=0
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_pidbyfile() {
|
check_pidbyfile() {
|
||||||
[ -e $1 ] && kill -0 $(< $1) 2>/dev/null
|
[ -e $1 ] && kill -0 `cat $1` 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function notify_chldexit() {
|
notify_chldexit() {
|
||||||
if [ $NOTOASTERUI -eq 0 ]; then
|
if [ $NOTOASTERUI -eq 0 ]; then
|
||||||
check_pidbyfile ${BUILDDIR}/.toasterui.pid && return
|
check_pidbyfile ${BUILDDIR}/.toasterui.pid && return
|
||||||
stop_system
|
stop_system
|
||||||
@@ -130,16 +131,16 @@ function notify_chldexit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function verify_prereq() {
|
verify_prereq() {
|
||||||
# Verify prerequisites
|
# Verify prerequisites
|
||||||
|
|
||||||
if ! echo "import django; print (1,) == django.VERSION[0:1] and django.VERSION[1:2][0] in (6,)" | python 2>/dev/null | grep True >/dev/null; then
|
if ! echo "import django; print (1,) == django.VERSION[0:1] and django.VERSION[1:2][0] in (6,)" | python 2>/dev/null | grep True >/dev/null; then
|
||||||
echo -e "This program needs Django 1.6. Please install with\n\npip install django==1.6\n"
|
printf "This program needs Django 1.6. Please install with\n\npip install django==1.6\n"
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! echo "import south; print reduce(lambda x, y: 2 if x==2 else 0 if x == 0 else y, map(lambda x: 1+cmp(x[1]-x[0],0), zip([0,8,4], map(int,south.__version__.split(\".\"))))) > 0" | python 2>/dev/null | grep True >/dev/null; then
|
if ! echo "import south; print reduce(lambda x, y: 2 if x==2 else 0 if x == 0 else y, map(lambda x: 1+cmp(x[1]-x[0],0), zip([0,8,4], map(int,south.__version__.split(\".\"))))) > 0" | python 2>/dev/null | grep True >/dev/null; then
|
||||||
echo -e "This program needs South 0.8.4. Please install with\n\npip install south==0.8.4\n"
|
printf "This program needs South 0.8.4. Please install with\n\npip install south==0.8.4\n"
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
@@ -182,42 +183,42 @@ if [ `basename \"$0\"` = `basename \"${SRCFILE}\"` ]; then
|
|||||||
# Start just the web server, point the web browser to the interface, and start any Django services.
|
# Start just the web server, point the web browser to the interface, and start any Django services.
|
||||||
|
|
||||||
if ! verify_prereq; then
|
if ! verify_prereq; then
|
||||||
echo -e "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
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$BUILDDIR" ]; then
|
if [ -n "$BUILDDIR" ]; then
|
||||||
echo -e "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." 1>&2
|
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." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Define a fake builddir where only the pid files are actually created. No real builds will take place here.
|
# Define a fake builddir where only the pid files are actually created. No real builds will take place here.
|
||||||
BUILDDIR=/tmp/toaster_$$
|
BUILDDIR=/tmp/toaster_$$
|
||||||
if [ -d "$BUILDDIR" ]; then
|
if [ -d "$BUILDDIR" ]; then
|
||||||
echo -e "Previous toaster run directory $BUILDDIR found, cowardly refusing to start. Please remove the directory when that toaster instance is over" 2>&1
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "$BUILDDIR"
|
mkdir -p "$BUILDDIR"
|
||||||
|
|
||||||
RUNNING=1
|
RUNNING=1
|
||||||
function trap_ctrlc() {
|
trap_ctrlc() {
|
||||||
echo "** Stopping system"
|
echo "** Stopping system"
|
||||||
webserverKillAll
|
webserverKillAll
|
||||||
RUNNING=0
|
RUNNING=0
|
||||||
}
|
}
|
||||||
|
|
||||||
function do_cleanup() {
|
do_cleanup() {
|
||||||
find "$BUILDDIR" -type f | xargs rm
|
find "$BUILDDIR" -type f | xargs rm
|
||||||
rmdir "$BUILDDIR"
|
rmdir "$BUILDDIR"
|
||||||
}
|
}
|
||||||
function cleanup() {
|
cleanup() {
|
||||||
if grep -ir error "$BUILDDIR" >/dev/null; then
|
if grep -ir error "$BUILDDIR" >/dev/null; then
|
||||||
if grep -irn "That port is already in use" "$BUILDDIR"; 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)"
|
echo "You can use the \"webport=PORTNUMBER\" parameter to start Toaster on a different port (port $WEB_PORT is already in use)"
|
||||||
do_cleanup
|
do_cleanup
|
||||||
else
|
else
|
||||||
echo -e "\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"
|
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
|
fi
|
||||||
else
|
else
|
||||||
echo "No errors found, removing the run directory '$BUILDDIR'"
|
echo "No errors found, removing the run directory '$BUILDDIR'"
|
||||||
@@ -248,7 +249,7 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
if ! verify_prereq; then
|
if ! verify_prereq; then
|
||||||
echo -e "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
|
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
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user