meta-app-framework: add new agl-session recipe 74/26974/3
authorArnaud Ferraris <arnaud.ferraris@collabora.com>
Tue, 7 Dec 2021 17:31:37 +0000 (18:31 +0100)
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>
Fri, 17 Dec 2021 21:15:26 +0000 (21:15 +0000)
For the new App FW, we want to create a systemd user session, to be
started on boot, which will be used to start the compositor and all user
background services.

This commit adds the corresponding target and service file (enabled by
default) so the session is started on boot.

Bug-AGL: SPEC-4161
Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Change-Id: I51ca7e0c1a994c6798b20b2592bec56a07f41c98
Reviewed-on: https://gerrit.automotivelinux.org/gerrit/c/AGL/meta-agl/+/26974
ci-image-build: Jenkins Job builder account
Tested-by: Jenkins Job builder account
ci-image-boot-test: Jenkins Job builder account
Reviewed-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org>
meta-app-framework/recipes-config/agl-session/agl-session_0.1.bb [new file with mode: 0644]
meta-app-framework/recipes-config/agl-session/files/agl-session.target [new file with mode: 0644]
meta-app-framework/recipes-config/agl-session/files/agl-session@.service [new file with mode: 0644]

diff --git a/meta-app-framework/recipes-config/agl-session/agl-session_0.1.bb b/meta-app-framework/recipes-config/agl-session/agl-session_0.1.bb
new file mode 100644 (file)
index 0000000..abde287
--- /dev/null
@@ -0,0 +1,35 @@
+SUMMARY = "AGL user session"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+SRC_URI = "\
+    file://agl-session@.service \
+    file://agl-session.target \
+"
+
+inherit systemd allarch useradd
+
+USERADD_PACKAGES = "${PN}"
+USERADDEXTENSION = "useradd-staticids"
+GROUPADD_PARAM:${PN} = "\
+       -g 1001 agl-driver ; \
+"
+USERADD_PARAM:${PN} = "\
+  -g 1001 -u 1001 -o -d /home/agl-driver -m -K PASS_MAX_DAYS=-1 agl-driver ; \
+"
+
+SYSTEMD_PACKAGES = "${PN}"
+# Instantiate session for the 'agl-driver' user, so we don't have to hardcode
+# the user name/ID in the service file itself
+SYSTEMD_SERVICE:${PN} = "agl-session@agl-driver.service"
+SYSTEMD_AUTO_ENABLE:${PN} = "enable"
+
+do_install() {
+    install -d ${D}${systemd_system_unitdir}
+    install -m 0644 ${WORKDIR}/agl-session@.service ${D}${systemd_system_unitdir}
+
+    install -d ${D}${systemd_user_unitdir}
+    install -m 0644 ${WORKDIR}/agl-session.target ${D}${systemd_user_unitdir}
+}
+
+FILES:${PN} += "${systemd_system_unitdir} ${systemd_user_unitdir}"
diff --git a/meta-app-framework/recipes-config/agl-session/files/agl-session.target b/meta-app-framework/recipes-config/agl-session/files/agl-session.target
new file mode 100644 (file)
index 0000000..84d9daa
--- /dev/null
@@ -0,0 +1,5 @@
+[Unit]
+Description=AGL user session
+
+BindsTo=graphical-session.target
+Before=graphical-session.target
diff --git a/meta-app-framework/recipes-config/agl-session/files/agl-session@.service b/meta-app-framework/recipes-config/agl-session/files/agl-session@.service
new file mode 100644 (file)
index 0000000..61afa41
--- /dev/null
@@ -0,0 +1,24 @@
+[Unit]
+Description=AGL user session
+After=systemd-user-sessions.service
+Wants=dbus.socket
+After=dbus.socket
+After=session-c1.scope
+Before=multi-user.target
+
+[Service]
+Environment=XDG_SESSION_TYPE=wayland
+ExecStart=/bin/systemctl --wait --user start agl-session.target
+TimeoutStartSec=30
+# This is a template service, instantiate for desired user's name or uid
+User=%i
+PAMName=login
+WorkingDirectory=~
+StandardInput=tty-fail
+StandardOutput=journal
+StandardError=journal
+Restart=always
+RestartSec=3s
+
+[Install]
+WantedBy=multi-user.target