weston: add weston-ready 29/19029/3
authorScott Murray <scott.murray@konsulko.com>
Fri, 7 Dec 2018 16:43:59 +0000 (11:43 -0500)
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>
Thu, 20 Dec 2018 21:10:07 +0000 (21:10 +0000)
Weston seems to take variable amounts of time to initialize on startup
depending on configuration (e.g. gst-record feature being enabled for
cluster support).  To avoid windowmanager and its dependencies failing,
patch LayerManagerControl so that errors can be detected; then use it
in a new script, weston-ready, to detect if Weston is functional.  A
corresponding systemd service unit is also added so that things can
use it in their dependencies.

Change-Id: I5711e7f9d9a891e1c7a160b5d65711bd6e7fee03
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
meta-agl-profile-graphical/recipes-graphics/wayland/wayland-ivi-extension/0002-add-LayerManagerControl-error-status.patch [new file with mode: 0644]
meta-agl-profile-graphical/recipes-graphics/wayland/wayland-ivi-extension_2.0.2.bb
meta-agl-profile-graphical/recipes-graphics/wayland/weston-ready/weston-ready [new file with mode: 0644]
meta-agl-profile-graphical/recipes-graphics/wayland/weston-ready/weston-ready.service [new file with mode: 0644]
meta-agl-profile-graphical/recipes-graphics/wayland/weston-ready_1.0.bb [new file with mode: 0644]
meta-agl-profile-graphical/recipes-platform/packagegroups/packagegroup-agl-graphical-weston.bb

diff --git a/meta-agl-profile-graphical/recipes-graphics/wayland/wayland-ivi-extension/0002-add-LayerManagerControl-error-status.patch b/meta-agl-profile-graphical/recipes-graphics/wayland/wayland-ivi-extension/0002-add-LayerManagerControl-error-status.patch
new file mode 100644 (file)
index 0000000..9f1ab47
--- /dev/null
@@ -0,0 +1,21 @@
+LayerManagerControl: add error exit status
+
+Tweak to add a non-zero exit status on errors.  This is useful for
+scripting, and allows writing a simple loop to detect Weston readiness.
+
+Upstream-Status: Pending
+
+Signed-off-by: Scott Murray <scott.murray@konsulko.com>
+
+diff --git a/ivi-layermanagement-examples/LayerManagerControl/src/main.cpp b/ivi-layermanagement-examples/LayerManagerControl/src/main.cpp
+index 8ee0546..210e21e 100644
+--- a/ivi-layermanagement-examples/LayerManagerControl/src/main.cpp
++++ b/ivi-layermanagement-examples/LayerManagerControl/src/main.cpp
+@@ -45,6 +45,7 @@ int main(int argc, char* argv[])
+     if (CommandSuccess != interpreter.interpretCommand(userCommand))
+     {
+         cerr << "Interpreter error: " << interpreter.getLastError() << endl;
++        return 1;
+     }
+     return 0;
index 3f0e34f..585c9ad 100644 (file)
@@ -10,7 +10,8 @@ SRC_URI = "git://github.com/GENIVI/${BPN}.git;branch=2.0;protocol=http \
         file://0001-Added-ivi-id-agent-to-CMake.patch \
         file://0002-ivi-id-agent-added-ivi-id-agent.patch \
         file://0003-ivi-controller-load-id-agent-module.patch \
-    "
+        file://0002-add-LayerManagerControl-error-status.patch \
+"
 SRC_URI_append_wandboard = " file://wandboard_fix_build.patch"
 
 S = "${WORKDIR}/git"
diff --git a/meta-agl-profile-graphical/recipes-graphics/wayland/weston-ready/weston-ready b/meta-agl-profile-graphical/recipes-graphics/wayland/weston-ready/weston-ready
new file mode 100644 (file)
index 0000000..5a3ff55
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+# Copyright (c) 2018, Konsulko Group
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Simple script to check if Weston+IVI shell is ready by calling
+# LayerManagerControl, optionally waiting for a specified timeout.
+#
+
+usage="Usage: weston-ready [-t timeout]" 
+timeout=0
+
+if [ $# -eq 2 ]; then
+       if [ $1 = "-t" ]; then
+               timeout=$(($2 * 10))
+       else
+               echo $usage
+               exit 1
+       fi
+fi
+
+time=0
+rc=1
+while true; do
+       if [ $time -gt $timeout ]; then
+               break
+       elif LayerManagerControl get screens >/dev/null 2>&1; then
+               rc=0
+               break
+       fi
+       if [ $timeout -gt 0 ]; then
+               usleep 500000
+       fi
+       time=$(($time + 5))
+done
+exit $rc
diff --git a/meta-agl-profile-graphical/recipes-graphics/wayland/weston-ready/weston-ready.service b/meta-agl-profile-graphical/recipes-graphics/wayland/weston-ready/weston-ready.service
new file mode 100644 (file)
index 0000000..f8db511
--- /dev/null
@@ -0,0 +1,9 @@
+[Unit]
+Description=Wait for Weston readiness
+Requires=weston.service
+After=weston.service
+
+[Service]
+Environment="XDG_RUNTIME_DIR=/run/platform/display"
+ExecStart=/usr/bin/weston-ready -t 10
+Type=oneshot
diff --git a/meta-agl-profile-graphical/recipes-graphics/wayland/weston-ready_1.0.bb b/meta-agl-profile-graphical/recipes-graphics/wayland/weston-ready_1.0.bb
new file mode 100644 (file)
index 0000000..a3d0bb2
--- /dev/null
@@ -0,0 +1,21 @@
+SUMMARY = "Weston readiness checker" 
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" 
+
+inherit systemd
+SRC_URI = "file://weston-ready \
+           file://weston-ready.service \
+"
+do_install() { 
+    install -D -m 0755 ${WORKDIR}/weston-ready ${D}${bindir}/weston-ready
+
+    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
+        install -D -m 0644 ${WORKDIR}/weston-ready.service ${D}${systemd_system_unitdir}/weston-ready.service
+    fi
+} 
+
+SYSTEMD_SERVICE_${PN} = "weston-ready.service"
+
+RDEPENDS_${PN} += "weston bash"
index 1da3d37..53721f0 100644 (file)
@@ -14,6 +14,7 @@ RDEPENDS_${PN} += " \
                   weston-init \
                   weston-ini-conf \
                   weston-examples \
+                  weston-ready \
                   agl-login-manager \
                   agl-desktop-config \
                   "