[OE-core] [PATCH v4 2/5] weston-init: Handle Weston startup correctly

Tom Hochstein tom.hochstein at freescale.com
Mon Mar 28 22:59:59 UTC 2016


Weston is started in different ways depending on the image
configuration and the runtime scenario. Refer to the weston man
page for more information.

Signed-off-by: Tom Hochstein <tom.hochstein at freescale.com>
---
 meta/recipes-graphics/wayland/weston-init.bb       | 10 +++++++++-
 meta/recipes-graphics/wayland/weston-init/init     |  2 +-
 .../wayland/weston-init/weston-start               | 22 ++++++++++++++++++++++
 .../wayland/weston-init/weston.service             |  4 ++--
 4 files changed, 34 insertions(+), 4 deletions(-)
 create mode 100644 meta/recipes-graphics/wayland/weston-init/weston-start

diff --git a/meta/recipes-graphics/wayland/weston-init.bb b/meta/recipes-graphics/wayland/weston-init.bb
index 653541e..7b5481a 100644
--- a/meta/recipes-graphics/wayland/weston-init.bb
+++ b/meta/recipes-graphics/wayland/weston-init.bb
@@ -3,7 +3,9 @@ LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690"
 
 SRC_URI = "file://init \
-           file://weston.service"
+           file://weston.service \
+           file://weston-start \
+           "
 
 S = "${WORKDIR}"
 
@@ -13,6 +15,12 @@ do_install() {
 
 	install -d ${D}${systemd_system_unitdir}
 	install -m0644 ${WORKDIR}/weston.service ${D}${systemd_system_unitdir}
+
+	install -d ${D}${bindir}
+	install -m755 ${WORKDIR}/weston-start ${D}${bindir}
+	if [ "${@bb.utils.contains('DISTRO_FEATURES', 'xwayland', 'xwayland', '', d)}" = "xwayland" ]; then
+		sed -i 's|USE_XWAYLAND="0"|USE_XWAYLAND="1"|g' ${D}${bindir}/weston-start
+	fi
 }
 
 inherit allarch update-rc.d distro_features_check systemd
diff --git a/meta/recipes-graphics/wayland/weston-init/init b/meta/recipes-graphics/wayland/weston-init/init
index 2e938f4..8567dfc 100644
--- a/meta/recipes-graphics/wayland/weston-init/init
+++ b/meta/recipes-graphics/wayland/weston-init/init
@@ -38,7 +38,7 @@ case "$1" in
                 chmod 0700 $XDG_RUNTIME_DIR
         fi
 
-        openvt -s weston -- $OPTARGS
+        weston-start
   ;;
 
   stop)
diff --git a/meta/recipes-graphics/wayland/weston-init/weston-start b/meta/recipes-graphics/wayland/weston-init/weston-start
new file mode 100644
index 0000000..da20921
--- /dev/null
+++ b/meta/recipes-graphics/wayland/weston-init/weston-start
@@ -0,0 +1,22 @@
+#! /bin/sh
+
+# There are multiple ways to start weston.
+if [ "$WAYLAND_DISPLAY" ]; then
+    echo -e "\aError: A Wayland compositor is already running."
+    echo "This script does not support launching a nested Weston instance."
+    exit 1
+else
+    if [ "$DISPLAY" ]; then
+        echo "Launching Weston under X"
+        openvt -s -- sh -c "weston -- $OPTARGS > /var/log/weston.log 2>&1"
+    else
+        echo "Launching Weston as first windowing system"
+        export XDG_CONFIG_HOME=/etc
+        USE_XWAYLAND="0"
+        if [ "$USE_XWAYLAND" = "1" ]; then
+            mkdir -p /tmp/.X11-unix
+            OPTARGS="--modules=xwayland.so $OPTARGS"
+        fi
+        openvt $OPENVT_ARGS -- sh -c "weston-launch -- $OPTARGS > /var/log/weston.log 2>&1"
+    fi
+fi
diff --git a/meta/recipes-graphics/wayland/weston-init/weston.service b/meta/recipes-graphics/wayland/weston-init/weston.service
index 4f1f7ff..856f91f 100644
--- a/meta/recipes-graphics/wayland/weston-init/weston.service
+++ b/meta/recipes-graphics/wayland/weston-init/weston.service
@@ -5,10 +5,10 @@ RequiresMountsFor=/run
 [Service]
 User=root
 EnvironmentFile=-/etc/default/weston
-Environment="XDG_RUNTIME_DIR=/run/user/root"
+Environment="XDG_RUNTIME_DIR=/run/user/root" "OPENVT_ARGS=-w"
 ExecStartPre=/bin/mkdir -p /run/user/root
 ExecStartPre=/bin/chmod 0700 /run/user/root
-ExecStart=/usr/bin/openvt -v -e /usr/bin/weston -- $OPTARGS
+ExecStart=/usr/bin/weston-start
 
 [Install]
 WantedBy=multi-user.target
-- 
2.1.4




More information about the Openembedded-core mailing list