From b1b652ff976655d0c1fcb170fb3f6795e56cd947 Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Tue, 2 Nov 2021 19:29:39 -0400 Subject: meta-agl-core: Update weston/agl-compositor init Changes/rework to get weston and agl-compositor starting again: - Since an upgrade to a newer Yocto release is in the near future, update weston-init and associated files to effectively backport the new weston startup behavior added in 3.3/Hardknott as our new base. The changes mean weston or agl-compositor will by default start as a "weston" user that replaces the "display" user that had been added previously in AGL. The goal is that any new work done on top of this base should hopefully work on 3.5/Kirkstone without further substantial rework. - Add new agl-compositor-init recipe that replaces the previous weston-init bbappend in meta-agl-demo. Having it as a separate recipe in core so weston or agl-compositor "just work" in simple test images seems like a better approach. - As part of the above, drop the --log option to agl-compositor in its command-line to address SPEC-4112. - Add SYSTEMD_DEFAULT_TARGET definition to agl-image-weston and in a new core-image-weston bbappend to result in agl-compositor and weston starting automatically in the corresponding images. This is required with the new weston-init behavior until we upgrade past 3.3/Hardknott, when "weston" in IMAGE_FEATURES can be used instead. Bug-AGL: SPEC-4121, SPEC-4112 Signed-off-by: Scott Murray Change-Id: Ia64894416846569abf8e744006ef26637279a895 Reviewed-on: https://gerrit.automotivelinux.org/gerrit/c/AGL/meta-agl/+/26782 Reviewed-by: Jan-Simon Moeller Tested-by: Jan-Simon Moeller --- meta-agl-core/files/group | 3 +- meta-agl-core/files/passwd | 2 +- .../wayland/agl-compositor-init.bb | 40 ++++++++++++ .../agl-compositor-init/agl-compositor.conf.in | 3 + .../recipes-graphics/wayland/agl-compositor_git.bb | 5 +- .../wayland/weston-init/weston-autologin | 11 ++++ .../wayland/weston-init/weston.service | 71 ++++++++++++++++++++++ .../wayland/weston-init/weston.socket | 14 +++++ .../wayland/weston-init_aglcore.inc | 46 ++++++++++++++ .../recipes-platform/images/agl-image-weston.inc | 4 ++ .../images/core-image-weston.bbappend | 1 + .../images/core-image-weston_aglcore.inc | 3 + 12 files changed, 200 insertions(+), 3 deletions(-) create mode 100644 meta-agl-core/recipes-graphics/wayland/agl-compositor-init.bb create mode 100644 meta-agl-core/recipes-graphics/wayland/agl-compositor-init/agl-compositor.conf.in create mode 100644 meta-agl-core/recipes-graphics/wayland/weston-init/weston-autologin create mode 100644 meta-agl-core/recipes-graphics/wayland/weston-init/weston.service create mode 100644 meta-agl-core/recipes-graphics/wayland/weston-init/weston.socket create mode 100644 meta-agl-core/recipes-platform/images/core-image-weston.bbappend create mode 100644 meta-agl-core/recipes-platform/images/core-image-weston_aglcore.inc (limited to 'meta-agl-core') diff --git a/meta-agl-core/files/group b/meta-agl-core/files/group index 3391cb1d8..f52448920 100644 --- a/meta-agl-core/files/group +++ b/meta-agl-core/files/group @@ -84,7 +84,8 @@ vmail::958: opensaf::957: lldpd::956: postdrop::954: -display::200: +weston::200: +wayland::201: agl-driver::1001: agl-passenger::1002: systemd-network::1005: diff --git a/meta-agl-core/files/passwd b/meta-agl-core/files/passwd index 9673c1ac5..4bbd6f878 100644 --- a/meta-agl-core/files/passwd +++ b/meta-agl-core/files/passwd @@ -56,7 +56,7 @@ vmail::958:958::: opensaf::957:957::: lldpd::956:956::: cyrus::955:8::: -display::200:200::: +weston::200:200::: systemd-network::1005:1005::: systemd-resolve::1006:1006::: mosquitto::1007:1007::: diff --git a/meta-agl-core/recipes-graphics/wayland/agl-compositor-init.bb b/meta-agl-core/recipes-graphics/wayland/agl-compositor-init.bb new file mode 100644 index 000000000..0cdf4d5d6 --- /dev/null +++ b/meta-agl-core/recipes-graphics/wayland/agl-compositor-init.bb @@ -0,0 +1,40 @@ +SUMMARY = "Startup systemd unit drop-in file for the AGL Wayland compositor" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" + +PACKAGE_ARCH = "${MACHINE_ARCH}" + +SRC_URI = "file://agl-compositor.conf.in" + +S = "${WORKDIR}" + +AGL_COMPOSITOR_ARGS ?= " --config ${sysconfdir}/xdg/weston/weston.ini --idle-time=0" +AGL_COMPOSITOR_USE_PIXMAN ??= "0" + +AGL_COMPOSITOR_ARGS:append = " ${@bb.utils.contains("DISTRO_FEATURES", "agl-devel", " --debug", "",d)}" +AGL_COMPOSITOR_ARGS:append = " ${@bb.utils.contains("WESTON_USE_PIXMAN", "1", " --use-pixman", "",d)}" + +do_install() { + # Process ".in" files + files=agl-compositor.conf.in + for f in ${files}; do + g=${f%.in} + if [ "${f}" != "${g}" ]; then + sed -e "s,@AGL_COMPOSITOR_ARGS@,${AGL_COMPOSITOR_ARGS},g" \ + ${WORKDIR}/${f} > ${WORKDIR}/${g} + fi + done + + # Install Weston systemd service drop-in + install -d ${D}${systemd_system_unitdir}/weston.service.d + install -m644 ${WORKDIR}/agl-compositor.conf ${D}/${systemd_system_unitdir}/weston.service.d/agl-compositor.conf +} + +FILES:${PN} += "\ + ${systemd_system_unitdir}/weston.service.d \ + " + +RDEPENDS:${PN} = " \ + agl-compositor \ + weston-init \ +" diff --git a/meta-agl-core/recipes-graphics/wayland/agl-compositor-init/agl-compositor.conf.in b/meta-agl-core/recipes-graphics/wayland/agl-compositor-init/agl-compositor.conf.in new file mode 100644 index 000000000..2918c410c --- /dev/null +++ b/meta-agl-core/recipes-graphics/wayland/agl-compositor-init/agl-compositor.conf.in @@ -0,0 +1,3 @@ +[Service] +ExecStart= +ExecStart=/usr/bin/agl-compositor @AGL_COMPOSITOR_ARGS@ diff --git a/meta-agl-core/recipes-graphics/wayland/agl-compositor_git.bb b/meta-agl-core/recipes-graphics/wayland/agl-compositor_git.bb index 2156c7839..bdf8dc896 100644 --- a/meta-agl-core/recipes-graphics/wayland/agl-compositor_git.bb +++ b/meta-agl-core/recipes-graphics/wayland/agl-compositor_git.bb @@ -30,7 +30,10 @@ FILES:${PN} = " \ ${libdir}/agl-compositor/libexec_compositor.so.0.0.0 \ " -RDEPENDS:${PN} += " ${@bb.utils.contains('AGL_FEATURES', 'waltham-remoting', 'waltham waltham-transmitter-plugin', '', d)}" +RDEPENDS:${PN} += " \ + agl-compositor-init \ + ${@bb.utils.contains('AGL_FEATURES', 'waltham-remoting', 'waltham waltham-transmitter-plugin', '', d)} \ +" FILES:${PN}-dev += " \ ${datadir}/agl-compositor/protocols/agl-shell.xml \ diff --git a/meta-agl-core/recipes-graphics/wayland/weston-init/weston-autologin b/meta-agl-core/recipes-graphics/wayland/weston-init/weston-autologin new file mode 100644 index 000000000..f6e6d106d --- /dev/null +++ b/meta-agl-core/recipes-graphics/wayland/weston-init/weston-autologin @@ -0,0 +1,11 @@ +auth required pam_nologin.so +auth required pam_unix.so try_first_pass nullok + +account required pam_nologin.so +account required pam_unix.so + +session required pam_env.so +session required pam_unix.so +-session optional pam_systemd.so type=wayland class=user desktop=weston +-session optional pam_loginuid.so + diff --git a/meta-agl-core/recipes-graphics/wayland/weston-init/weston.service b/meta-agl-core/recipes-graphics/wayland/weston-init/weston.service new file mode 100644 index 000000000..e09625b31 --- /dev/null +++ b/meta-agl-core/recipes-graphics/wayland/weston-init/weston.service @@ -0,0 +1,71 @@ +# This is a system unit for launching Weston with auto-login as the +# user configured here. +# +# Weston must be built with systemd support, and your weston.ini must load +# the plugin systemd-notify.so. +[Unit] +Description=Weston, a Wayland compositor, as a system service +Documentation=man:weston(1) man:weston.ini(5) +Documentation=http://wayland.freedesktop.org/ + +# Make sure we are started after logins are permitted. +Requires=systemd-user-sessions.service +After=systemd-user-sessions.service + +# If Plymouth is used, we want to start when it is on its way out. +After=plymouth-quit-wait.service + +# D-Bus is necessary for contacting logind. Logind is required. +Wants=dbus.socket +After=dbus.socket + +# Ensure the socket is present +Requires=weston.socket + +# Since we are part of the graphical session, make sure we are started before +# it is complete. +Before=graphical.target + +# Prevent starting on systems without virtual consoles, Weston requires one +# for now. +ConditionPathExists=/dev/tty0 + +[Service] +# Requires systemd-notify.so Weston plugin. +Type=notify +EnvironmentFile=/etc/default/weston +ExecStart=/usr/bin/weston --modules=systemd-notify.so + +# Optional watchdog setup +TimeoutStartSec=60 +WatchdogSec=20 + +# The user to run Weston as. +User=weston +Group=weston + +# Make sure the working directory is the users home directory +WorkingDirectory=/home/weston + +# Set up a full user session for the user, required by Weston. +PAMName=weston-autologin + +# A virtual terminal is needed. +TTYPath=/dev/tty7 +TTYReset=yes +TTYVHangup=yes +TTYVTDisallocate=yes + +# Fail to start if not controlling the tty. +StandardInput=tty-fail +StandardOutput=journal +StandardError=journal + +# Log this user with utmp, letting it show up with commands 'w' and 'who'. +UtmpIdentifier=tty7 +UtmpMode=user + +[Install] +# Note: If you only want weston to start on-demand, remove this line with a +# service drop file +WantedBy=graphical.target diff --git a/meta-agl-core/recipes-graphics/wayland/weston-init/weston.socket b/meta-agl-core/recipes-graphics/wayland/weston-init/weston.socket new file mode 100644 index 000000000..c1bdc83c0 --- /dev/null +++ b/meta-agl-core/recipes-graphics/wayland/weston-init/weston.socket @@ -0,0 +1,14 @@ +[Unit] +Description=Weston socket +RequiresMountsFor=/run + +[Socket] +ListenStream=/run/wayland-0 +SocketMode=0775 +SocketUser=weston +SocketGroup=wayland +RemoveOnStop=yes + +[Install] +WantedBy=sockets.target + diff --git a/meta-agl-core/recipes-graphics/wayland/weston-init_aglcore.inc b/meta-agl-core/recipes-graphics/wayland/weston-init_aglcore.inc index 896f1eafb..070f5f8b5 100644 --- a/meta-agl-core/recipes-graphics/wayland/weston-init_aglcore.inc +++ b/meta-agl-core/recipes-graphics/wayland/weston-init_aglcore.inc @@ -6,3 +6,49 @@ do_install:append() { } RDEPENDS:${PN} += "weston-ini" + +# Temporary effective backport of upstream commit ccdaab97 +# This gets us on the same page as upstream with respect to running +# weston as non-root, and should make migrating to 3.5/Kirkstone +# easier. + +FILESEXTRAPATHS:prepend := "${THISDIR}/weston-init:" + +SRC_URI += " \ + file://weston.service \ + file://weston.socket \ + file://weston-autologin \ +" + +do_install:append() { + rm -f ${D}${sysconfdir}/udev/rules.d/71-weston-drm.rules + rm -f ${D}${systemd_system_unitdir}/weston@.service + rm -f ${D}${systemd_system_unitdir}/weston@.socket + + install -D -p -m0644 ${WORKDIR}/weston.service ${D}${systemd_system_unitdir}/weston.service + install -D -p -m0644 ${WORKDIR}/weston.socket ${D}${systemd_system_unitdir}/weston.socket + if [ "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)}" ]; then + install -D -p -m0644 ${WORKDIR}/weston-autologin ${D}${sysconfdir}/pam.d/weston-autologin + fi + + sed -i -e s:/etc:${sysconfdir}:g \ + -e s:/usr/bin:${bindir}:g \ + -e s:/var:${localstatedir}:g \ + ${D}${systemd_system_unitdir}/weston.service + + install -dm 755 -o weston -g weston ${D}/home/weston +} + +inherit useradd + +USERADD_PACKAGES = "${PN}" + +FILES_${PN} += "\ + ${systemd_system_unitdir}/weston.service \ + ${systemd_system_unitdir}/weston.socket \ + /home/weston \ +" + +SYSTEMD_SERVICE_${PN} = "weston.service weston.socket" +USERADD_PARAM_${PN} = "--home /home/weston --shell /bin/sh --user-group -G video,input weston" +GROUPADD_PARAM_${PN} = "-r wayland" diff --git a/meta-agl-core/recipes-platform/images/agl-image-weston.inc b/meta-agl-core/recipes-platform/images/agl-image-weston.inc index cef3bf64e..f7d2bb600 100644 --- a/meta-agl-core/recipes-platform/images/agl-image-weston.inc +++ b/meta-agl-core/recipes-platform/images/agl-image-weston.inc @@ -2,6 +2,10 @@ require recipes-platform/images/agl-image-minimal.inc IMAGE_FEATURES += "splash package-management ssh-server-dropbear" +# NOTE: In hardknott or later this can be replaced by adding "weston" +# to IMAGE_FEATURES. +SYSTEMD_DEFAULT_TARGET = "graphical.target" + inherit features_check REQUIRED_DISTRO_FEATURES = "wayland" diff --git a/meta-agl-core/recipes-platform/images/core-image-weston.bbappend b/meta-agl-core/recipes-platform/images/core-image-weston.bbappend new file mode 100644 index 000000000..082637b7e --- /dev/null +++ b/meta-agl-core/recipes-platform/images/core-image-weston.bbappend @@ -0,0 +1 @@ +require ${@bb.utils.contains('AGL_FEATURES', 'aglcore', 'core-image-weston_aglcore.inc', '', d)} diff --git a/meta-agl-core/recipes-platform/images/core-image-weston_aglcore.inc b/meta-agl-core/recipes-platform/images/core-image-weston_aglcore.inc new file mode 100644 index 000000000..82e348587 --- /dev/null +++ b/meta-agl-core/recipes-platform/images/core-image-weston_aglcore.inc @@ -0,0 +1,3 @@ +# NOTE: In hardknott or later this can be replaced by adding "weston" +# to IMAGE_FEATURES. +SYSTEMD_DEFAULT_TARGET = "graphical.target" -- cgit 1.2.3-korg