diff options
author | David Reyna <David.Reyna@windriver.com> | 2017-06-14 21:57:29 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-06-22 09:23:38 +0100 |
commit | 246b2fde383c6b6fdde83db686e0f8a2a9b94615 (patch) | |
tree | 4adc780a81d5eba0ad259858608b53e716800982 | |
parent | 9e622784e16cc38e1334979557f90ce87e9408a1 (diff) | |
download | poky-246b2fde383c6b6fdde83db686e0f8a2a9b94615.tar.gz |
bitbake: toaster: noweb should init database
When the 'noweb' option for Toaster is used, perform the database
check/create if the Toaster database does not yet exist.
This will allow Toaster to not fail if the first use is with 'noweb'.
This avoids potentially clashing database updates if there are
multiple overlaping 'noweb' sessions (for example with a CI system).
If the user wished to update the database, they can either use the
explicit "lsupdate" command or (re)start a web hosted Toaster session
(which is gated by the webserver's PID).
[YOCTO #11378]
(Bitbake rev: 910b96b9894c712aa32b5d4dadda88b766d86e35)
Signed-off-by: David Reyna <David.Reyna@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-x | bitbake/bin/toaster | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/bitbake/bin/toaster b/bitbake/bin/toaster index fd6cabf378..61a4a0f85d 100755 --- a/bitbake/bin/toaster +++ b/bitbake/bin/toaster | |||
@@ -24,6 +24,29 @@ Usage: source toaster start|stop [webport=<address:port>] [noweb] | |||
24 | [webport] Set the development server (default: localhost:8000) | 24 | [webport] Set the development server (default: localhost:8000) |
25 | " | 25 | " |
26 | 26 | ||
27 | databaseCheck() | ||
28 | { | ||
29 | retval=0 | ||
30 | # you can always add a superuser later via | ||
31 | # ../bitbake/lib/toaster/manage.py createsuperuser --username=<ME> | ||
32 | $MANAGE migrate --noinput || retval=1 | ||
33 | |||
34 | if [ $retval -eq 1 ]; then | ||
35 | echo "Failed migrations, aborting system start" 1>&2 | ||
36 | return $retval | ||
37 | fi | ||
38 | # Make sure that checksettings can pick up any value for TEMPLATECONF | ||
39 | export TEMPLATECONF | ||
40 | $MANAGE checksettings --traceback || retval=1 | ||
41 | |||
42 | if [ $retval -eq 1 ]; then | ||
43 | printf "\nError while checking settings; aborting\n" | ||
44 | return $retval | ||
45 | fi | ||
46 | |||
47 | return $retval | ||
48 | } | ||
49 | |||
27 | webserverKillAll() | 50 | webserverKillAll() |
28 | { | 51 | { |
29 | local pidfile | 52 | local pidfile |
@@ -48,22 +71,9 @@ webserverStartAll() | |||
48 | fi | 71 | fi |
49 | 72 | ||
50 | retval=0 | 73 | retval=0 |
51 | # you can always add a superuser later via | ||
52 | # ../bitbake/lib/toaster/manage.py createsuperuser --username=<ME> | ||
53 | $MANAGE migrate --noinput || retval=1 | ||
54 | 74 | ||
55 | if [ $retval -eq 1 ]; then | 75 | # check the database |
56 | echo "Failed migrations, aborting system start" 1>&2 | 76 | databaseCheck || return 1 |
57 | return $retval | ||
58 | fi | ||
59 | # Make sure that checksettings can pick up any value for TEMPLATECONF | ||
60 | export TEMPLATECONF | ||
61 | $MANAGE checksettings --traceback || retval=1 | ||
62 | |||
63 | if [ $retval -eq 1 ]; then | ||
64 | printf "\nError while checking settings; aborting\n" | ||
65 | return $retval | ||
66 | fi | ||
67 | 77 | ||
68 | echo "Starting webserver..." | 78 | echo "Starting webserver..." |
69 | 79 | ||
@@ -240,6 +250,16 @@ case $CMD in | |||
240 | line='INHERIT+="toaster buildhistory"' | 250 | line='INHERIT+="toaster buildhistory"' |
241 | grep -q "$line" $conf || echo $line >> $conf | 251 | grep -q "$line" $conf || echo $line >> $conf |
242 | 252 | ||
253 | if [ $WEBSERVER -eq 0 ] ; then | ||
254 | # Do not update the database for "noweb" unless | ||
255 | # it does not yet exist | ||
256 | if [ ! -f "$TOASTER_DIR/toaster.sqlite" ] ; then | ||
257 | if ! databaseCheck; then | ||
258 | echo "Failed ${CMD}." | ||
259 | return 4 | ||
260 | fi | ||
261 | fi | ||
262 | fi | ||
243 | if [ $WEBSERVER -gt 0 ] && ! webserverStartAll; then | 263 | if [ $WEBSERVER -gt 0 ] && ! webserverStartAll; then |
244 | echo "Failed ${CMD}." | 264 | echo "Failed ${CMD}." |
245 | return 4 | 265 | return 4 |