Skip to contentSkip to conversation

weston-init: Add possibility to run weston as non-root user

PATCH In review Khem Raj 2 participants 3 messages Sep 16, 2019 – Sep 19, 2019

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH v5 1/1 weston-init: Add possibility to run weston as non-root user

These changes are from meta-96boards primarily
Launch the session via a udev rule based on what kind of display device is available

delete weston-conf and move the fuctionality into weston-init other layers are doing same

weston-init installs machine specific weston.ini therefore mark is machine specific now

---
v2: Drop duplicate isntall rule and use systemd_system_unitdir
v3: Use systemd_system_unitdir in FILES section too
v4: Move weston-conf logic into weston-init and delete it
v5: Mark machine specific

 meta/conf/distro/include/maintainers.inc      |  1 -
 meta/recipes-graphics/wayland/weston-conf.bb  | 35 ---------
 meta/recipes-graphics/wayland/weston-init.bb  | 28 +++++--
 .../wayland/weston-init/71-weston-drm.rules   |  2 +
 .../wayland/weston-init/qemux86-64/weston.ini |  2 +
 .../wayland/weston-init/qemux86/weston.ini    |  2 +
 .../wayland/weston-init/weston.ini            | 74 +++++++++++++++++++
 .../wayland/weston-init/weston.service        | 13 ----
 .../wayland/weston-init/[email protected]       | 37 ++++++++++
 meta/recipes-graphics/wayland/weston_7.0.0.bb |  2 +-
 10 files changed, 141 insertions(+), 55 deletions(-)
 delete mode 100644 meta/recipes-graphics/wayland/weston-conf.bb
 create mode 100644 meta/recipes-graphics/wayland/weston-init/71-weston-drm.rules
 create mode 100644 meta/recipes-graphics/wayland/weston-init/qemux86-64/weston.ini
 create mode 100644 meta/recipes-graphics/wayland/weston-init/qemux86/weston.ini
 create mode 100644 meta/recipes-graphics/wayland/weston-init/weston.ini
 delete mode 100644 meta/recipes-graphics/wayland/weston-init/weston.service
 create mode 100644 meta/recipes-graphics/wayland/weston-init/[email protected]
meta/conf/distro/include/maintainers.inc +0 -1
index 5f21f98b2b..ab0c6c5541 100644
@@ -718,7 +718,6 @@ RECIPE_MAINTAINER_pn-wayland = "Denys Dmytriyenko <[email protected]>"
 RECIPE_MAINTAINER_pn-wayland-protocols = "Denys Dmytriyenko <[email protected]>"
 RECIPE_MAINTAINER_pn-webkitgtk = "Alexander Kanavin <[email protected]>"
 RECIPE_MAINTAINER_pn-weston = "Denys Dmytriyenko <[email protected]>"
-RECIPE_MAINTAINER_pn-weston-conf = "Denys Dmytriyenko <[email protected]>"
 RECIPE_MAINTAINER_pn-weston-init = "Denys Dmytriyenko <[email protected]>"
 RECIPE_MAINTAINER_pn-wget = "Yi Zhao <[email protected]>"
 RECIPE_MAINTAINER_pn-which = "Anuj Mittal <[email protected]>"
meta/recipes-graphics/wayland/weston-conf.bb deleted +0 -35
deleted file mode 100644
index f52200c46a..0000000000
@@ -1,35 +0,0 @@
-SUMMARY = "Weston, a Wayland compositor, configuration files"
-HOMEPAGE = "http://wayland.freedesktop.org"
-LICENSE = "MIT"
-LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
-
-PACKAGE_ARCH = "${MACHINE_ARCH}"
-
-CONFFILES_${PN} = "${sysconfdir}/xdg/weston/weston.ini"
-
-FILES_${PN} = "${sysconfdir}/xdg/weston/weston.ini"
-
-PACKAGES = "${PN}"
-
-do_configure[noexec] = '1'
-do_compile[noexec] = '1'
-
-do_install() {
-	:
-}
-
-do_install_qemux86() {
-	mkdir -p ${D}/${sysconfdir}/xdg/weston
-	cat << EOF > ${D}/${sysconfdir}/xdg/weston/weston.ini
-[core]
-backend=fbdev-backend.so
-EOF
-}
-
-do_install_qemux86-64() {
-	mkdir -p ${D}/${sysconfdir}/xdg/weston
-	cat << EOF > ${D}/${sysconfdir}/xdg/weston/weston.ini
-[core]
-backend=fbdev-backend.so
-EOF
-}
meta/recipes-graphics/wayland/weston-init.bb +23 -5
index 22ba5f3fb3..8b6689717c 100644
@@ -2,23 +2,35 @@ SUMMARY = "Startup script and systemd unit file for the Weston Wayland composito
 LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
 
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
 SRC_URI = "file://init \
-           file://weston.service \
+           file://weston.ini \
+           file://[email protected] \
+           file://71-weston-drm.rules \
            file://weston-start"
 
 S = "${WORKDIR}"
 
 do_install() {
 	install -Dm755 ${WORKDIR}/init ${D}/${sysconfdir}/init.d/weston
-	install -Dm0644 ${WORKDIR}/weston.service ${D}${systemd_system_unitdir}/weston.service
-
+	install -D -p -m0644 ${WORKDIR}/weston.ini ${D}${sysconfdir}/xdg/weston/weston.ini
+
+	# Install Weston systemd service and accompanying udev rule
+	install -D -p -m0644 ${WORKDIR}/[email protected] ${D}${systemd_system_unitdir}/[email protected]
+	sed -i -e s:/etc:${sysconfdir}:g \
+		-e s:/usr/bin:${bindir}:g \
+		-e s:/var:${localstatedir}:g \
+		${D}${systemd_unitdir}/system/[email protected]
+	install -D -p -m0644 ${WORKDIR}/71-weston-drm.rules \
+		${D}${sysconfdir}/udev/rules.d/71-weston-drm.rules
 	# Install weston-start script
 	install -Dm755 ${WORKDIR}/weston-start ${D}${bindir}/weston-start
 	sed -i 's,@DATADIR@,${datadir},g' ${D}${bindir}/weston-start
 	sed -i 's,@LOCALSTATEDIR@,${localstatedir},g' ${D}${bindir}/weston-start
 }
 
-inherit allarch update-rc.d distro_features_check systemd
+inherit update-rc.d distro_features_check systemd
 
 # rdepends on weston which depends on virtual/egl
 REQUIRED_DISTRO_FEATURES = "opengl"
@@ -28,4 +40,10 @@ RDEPENDS_${PN} = "weston kbd"
 INITSCRIPT_NAME = "weston"
 INITSCRIPT_PARAMS = "start 9 5 2 . stop 20 0 1 6 ."
 
-SYSTEMD_SERVICE_${PN} = "weston.service"
+FILES_${PN} += "${sysconfdir}/xdg/weston/weston.ini ${systemd_system_unitdir}/[email protected]"
+
+CONFFILES_${PN} += "${sysconfdir}/xdg/weston/weston.ini"
+
+SYSTEMD_SERVICE_${PN} = "weston@%i.service"
+SYSTEMD_AUTO_ENABLE = "disable"
+
meta/recipes-graphics/wayland/weston-init/71-weston-drm.rules new file +2 -0
new file mode 100644
index 0000000000..1a1b8bbda4
@@ -0,0 +1,2 @@
+ACTION=="add", SUBSYSTEM=="graphics", KERNEL=="fb0", TAG+="systemd", ENV{SYSTEMD_WANTS}+="[email protected]"
+ACTION=="add", SUBSYSTEM=="drm", KERNEL=="card0", TAG+="systemd", ENV{SYSTEMD_WANTS}+="[email protected]"
meta/recipes-graphics/wayland/weston-init/qemux86-64/weston.ini new file +2 -0
new file mode 100644
index 0000000000..17ebd7fdab
@@ -0,0 +1,2 @@
+[core]
+backend=fbdev-backend.so
meta/recipes-graphics/wayland/weston-init/qemux86/weston.ini new file +2 -0
new file mode 100644
index 0000000000..17ebd7fdab
@@ -0,0 +1,2 @@
+[core]
+backend=fbdev-backend.so
meta/recipes-graphics/wayland/weston-init/weston.ini new file +74 -0

74 lines not on this page · raw message

meta/recipes-graphics/wayland/weston-init/weston.service deleted +0 -13
deleted file mode 100644
index 18f72626e0..0000000000
@@ -1,13 +0,0 @@
-[Unit]
-Description=Weston Wayland Compositor
-RequiresMountsFor=/run
-
-[Service]
-User=root
-PAMName=login
-EnvironmentFile=-/etc/default/weston
-ExecStart=/usr/bin/weston-start -v -e -- $OPTARGS
-
-[Install]
-WantedBy=multi-user.target
-
meta/recipes-graphics/wayland/weston-init/[email protected] new file +37 -0
new file mode 100644
index 0000000000..9ecf2ab069
@@ -0,0 +1,37 @@
+[Unit]
+Description=Weston Wayland Compositor (on tty7)
+RequiresMountsFor=/run
[email protected] plymouth-quit.service
+After=systemd-user-sessions.service [email protected] plymouth-quit-wait.service
+
+[Service]
+User=%i
+PermissionsStartOnly=true
+
+# Log us in via PAM so we get our XDG & co. environment and
+# are treated as logged in so we can use the tty:
+PAMName=login
+
+# Grab tty7
+UtmpIdentifier=tty7
+TTYPath=/dev/tty7
+TTYReset=yes
+TTYVHangup=yes
+TTYVTDisallocate=yes
+
+# stderr to journal so our logging doesn't get thrown into /dev/null
+StandardOutput=tty
+StandardInput=tty
+StandardError=journal
+
+EnvironmentFile=-/etc/default/weston
+
+# Weston does not successfully change VT, nor does systemd place us on
+# the VT it just activated for us. Switch manually:
+ExecStartPre=/usr/bin/chvt 7
+ExecStart=/usr/bin/weston --log=${XDG_RUNTIME_DIR}/weston.log $OPTARGS
+
+IgnoreSIGPIPE=no
+
+#[Install]
+#Alias=multi-user.target.wants/weston.service
meta/recipes-graphics/wayland/weston_7.0.0.bb +1 -1
index 5d2a9336f3..583798368e 100644
@@ -104,7 +104,7 @@ FILES_${PN}-xwayland = "${libdir}/libweston-${WESTON_MAJOR_VERSION}/xwayland.so"
 RDEPENDS_${PN}-xwayland += "xserver-xorg-xwayland"
 
 RDEPENDS_${PN} += "xkeyboard-config"
-RRECOMMENDS_${PN} = "weston-conf liberation-fonts"
+RRECOMMENDS_${PN} = "weston-init liberation-fonts"
 RRECOMMENDS_${PN}-dev += "wayland-protocols"
 
 USERADD_PACKAGES = "${PN}"
Signature · 1 line
2.23.0
#1 lore raw
Quoted 11 lines · Khem Raj

These changes are from meta-96boards primarily
Launch the session via a udev rule based on what kind of display device
is available

delete weston-conf and move the fuctionality into weston-init other layers are doing same

weston-init installs machine specific weston.ini therefore mark is machine specific now

Quoted 8 lines

---
v2: Drop duplicate isntall rule and use systemd_system_unitdir
v3: Use systemd_system_unitdir in FILES section too
v4: Move weston-conf logic into weston-init and delete it
v5: Mark machine specific

You didn't actually retest this and v5 still fails the selftest. I've squashed the fix needed into the patch.

Cheers,

Richard

author
#2 lore raw
Quoted 22 lines · Richard Purdie
Quoted 11 lines · Khem Raj

These changes are from meta-96boards primarily
Launch the session via a udev rule based on what kind of display device
is available

delete weston-conf and move the fuctionality into weston-init other layers are doing same

weston-init installs machine specific weston.ini therefore mark is machine specific now

Quoted 8 lines

---
v2: Drop duplicate isntall rule and use systemd_system_unitdir
v3: Use systemd_system_unitdir in FILES section too
v4: Move weston-conf logic into weston-init and delete it
v5: Mark machine specific

Quoted 2 lines

You didn't actually retest this and v5 still fails the selftest. I've squashed the fix needed into the patch.

I tested that now the package was machine-specific instead of allarch but I did miss SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS
thanks for fixing it. We also need to remove weston-conf from this

Quoted 5 lines

Cheers,

Richard