From 4b4c0f15d1d2a52e636aa22e56cf864d1a8a656b Mon Sep 17 00:00:00 2001
From: Scott Murray <scott.murray@konsulko.com>
Date: Mon, 5 Jun 2023 10:07:24 -0400
Subject: [PATCH] Remove systemd user session and clean up packagegroups and
 images

Remove the use of a systemd user session to align with how upstream
runs Weston, and to allow using all systemd sandboxing features with
the compositor and homescreen, launcher, etc. applications.  The
changes for this touched enough packagegroups and images that further
rework was done to address some of the cleanup described in SPEC-4813,
see below for details.

Changes:
- Remove agl-session and update various recipes that were manually
  adding dependencies to the user session it created.  The compositor
  (be it weston or agl-compositor) and Wayland clients now run in the
  system session as non-root users.
- Revive agl-users recipe, this time living in meta-agl-core, with
  the purpose of creating the agl-driver user.  For simplicity,
  agl-compositor is always run as the agl-driver user, as opposed to
  trying to wrangle running it as different users depending on build
  configuration.  This can potentially be made more configurable if a
  downstream user has a usecase to be able to specify another user.
- Fully split agl-compositor's systemd unit with a tweaked fork of the
  weston-init recipe and unit which lives in meta-agl-core.  This will
  be easier to maintain than the attempt to reuse weston-init for
  builds without meta-app-framework that was done previously.
- Create packagegroup-agl-graphical-compositor, distinct from the
  weston packagegroup.  This should make it more straightforward for
  downstreams that want agl-compositor or weston.
- Rename agl-image-agl-compositor to agl-image-compositor to remove
  redundancy.
- Tweak the logic for the inclusion of a few debug packages (e.g.
  agl-shell-activator) to ensure they only show up in images when
  agl-devel is enabled.
- Split weston-terminal and the required icon resources into separate
  packages in our weston bbappend to avoid pulling in weston just to
  get the terminal for testing.
- Add a agl-core-image.bbclass to use as a base for images.
- Move our cross-SDK configuration to a agl-crosssdk.bbclass to ease
  reuse.
- Remove various empty packagegroups.
- Unify image .inc files with their .bb files as a simplification,
  and to move towards more how upstream Yocto Project does things.
- Split pipewire tools into their own -devel packagegroup.
- Remove rcar3 additions to packagegroup-agl-graphical-multimedia, as
  that packagegroup is not machine-specific.  They will be added back
  in via a change in meta-agl-demo.  If a downstream user desires a
  platform-specific packagegroup for such packages in meta-agl-core,
  this can be revisited, though a different implementation should be
  used.
- Replace some :append usage with += to avoid creating problems
  for downstream users.

Bug-AGL: SPEC-4714, SPEC-4813

Change-Id: I55b29bf749f0d5d50993a362c665bce62b785f67
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Reviewed-on: https://gerrit.automotivelinux.org/gerrit/c/AGL/meta-agl/+/28996
Tested-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org>
Reviewed-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org>
---
 .../packagegroup-agl-graphical-multimedia.bbappend |  5 --
 meta-agl-core/classes/agl-core-image.bbclass       | 32 ++++++++++
 meta-agl-core/classes/agl-crosssdk.bbclass         |  9 +++
 .../recipes-config/agl-users/agl-users_1.0.bb      | 20 +++++++
 .../images/core-image-weston.bbappend              |  0
 .../images/core-image-weston_aglcore.inc}          |  7 +--
 .../wayland/agl-compositor-init.bb                 | 42 +++++++++----
 .../agl-compositor-init/agl-compositor-autologin   | 11 ++++
 .../agl-compositor-init/agl-compositor.service     | 68 ++++++++++++++++++++++
 .../agl-compositor-init/agl-compositor.socket      |  0
 .../recipes-graphics/wayland/weston-ini-conf.bb    |  6 --
 .../wayland/weston_10.0_aglcore.inc                | 23 +++++++-
 .../images/agl-image-agl-compositor.bb             | 10 ----
 .../recipes-platform/images/agl-image-boot.bb      | 10 +---
 .../recipes-platform/images/agl-image-boot.inc     | 16 -----
 .../images/agl-image-compositor.bb                 | 15 +++++
 .../images/agl-image-core-autobuilder.bb           | 10 ++--
 .../images/agl-image-minimal-crosssdk.bb           | 19 ++----
 .../images/agl-image-minimal-crosssdk.inc          |  2 -
 .../recipes-platform/images/agl-image-minimal.bb   | 10 ++--
 .../recipes-platform/images/agl-image-minimal.inc  |  1 -
 .../recipes-platform/images/agl-image-weston.bb    | 16 +++--
 .../images/core-image-weston_aglcore.inc           |  3 -
 .../packagegroups/packagegroup-agl-core-boot.bb    |  1 +
 .../packagegroups/packagegroup-agl-core-devel.bb   |  9 +--
 .../packagegroup-agl-core-os-commonlibs.bb         | 14 -----
 .../packagegroup-agl-core-security.bb              | 14 -----
 .../packagegroup-agl-graphical-compositor.bb       | 13 +++++
 .../packagegroup-agl-graphical-multimedia.bb       | 16 -----
 .../packagegroup-agl-graphical-weston.bb           | 20 +++----
 .../packagegroups/packagegroup-agl-image-boot.bb   | 18 ------
 .../packagegroup-agl-image-minimal.bb              |  6 --
 .../packagegroup-agl-profile-graphical.bb          |  9 +--
 .../recipes-config/agl-session/agl-session_0.1.bb  | 49 ----------------
 .../agl-session/files/50-xdg-data-dirs.sh          |  7 ---
 .../agl-session/files/agl-session.target           |  5 --
 .../agl-session/files/agl-session@.service         | 24 --------
 .../recipes-core/applaunchd/applaunchd_git.bb      | 11 +++-
 .../wayland/agl-compositor-init.bbappend           |  1 -
 .../agl-compositor-init/agl-compositor.conf        | 11 ----
 .../agl-compositor-init/agl-compositor.service.in  | 29 ---------
 .../wayland/agl-compositor-init_agl-app-fw.inc     | 47 ---------------
 .../wayland/weston-ini-conf.bbappend               |  1 -
 .../wayland/weston-ini-conf_agl-app-fw.inc         |  5 --
 .../packagegroups/packagegroup-pipewire.bb         |  7 ++-
 45 files changed, 278 insertions(+), 374 deletions(-)
 delete mode 100644 meta-agl-bsp/meta-rcar-gen3/recipes-platform/packagegroups/packagegroup-agl-graphical-multimedia.bbappend
 create mode 100644 meta-agl-core/classes/agl-core-image.bbclass
 create mode 100644 meta-agl-core/classes/agl-crosssdk.bbclass
 create mode 100644 meta-agl-core/recipes-config/agl-users/agl-users_1.0.bb
 rename meta-agl-core/{recipes-platform => recipes-core}/images/core-image-weston.bbappend (100%)
 rename meta-agl-core/{recipes-platform/images/agl-image-weston.inc => recipes-core/images/core-image-weston_aglcore.inc} (51%)
 create mode 100644 meta-agl-core/recipes-graphics/wayland/agl-compositor-init/agl-compositor-autologin
 create mode 100644 meta-agl-core/recipes-graphics/wayland/agl-compositor-init/agl-compositor.service
 rename {meta-app-framework => meta-agl-core}/recipes-graphics/wayland/agl-compositor-init/agl-compositor.socket (100%)
 delete mode 100644 meta-agl-core/recipes-platform/images/agl-image-agl-compositor.bb
 delete mode 100644 meta-agl-core/recipes-platform/images/agl-image-boot.inc
 create mode 100644 meta-agl-core/recipes-platform/images/agl-image-compositor.bb
 delete mode 100644 meta-agl-core/recipes-platform/images/agl-image-minimal-crosssdk.inc
 delete mode 100644 meta-agl-core/recipes-platform/images/agl-image-minimal.inc
 delete mode 100644 meta-agl-core/recipes-platform/images/core-image-weston_aglcore.inc
 delete mode 100644 meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-core-os-commonlibs.bb
 delete mode 100644 meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-core-security.bb
 create mode 100644 meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-graphical-compositor.bb
 delete mode 100644 meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-graphical-multimedia.bb
 delete mode 100644 meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-image-boot.bb
 delete mode 100644 meta-app-framework/recipes-config/agl-session/agl-session_0.1.bb
 delete mode 100644 meta-app-framework/recipes-config/agl-session/files/50-xdg-data-dirs.sh
 delete mode 100644 meta-app-framework/recipes-config/agl-session/files/agl-session.target
 delete mode 100644 meta-app-framework/recipes-config/agl-session/files/agl-session@.service
 delete mode 100644 meta-app-framework/recipes-graphics/wayland/agl-compositor-init.bbappend
 delete mode 100644 meta-app-framework/recipes-graphics/wayland/agl-compositor-init/agl-compositor.conf
 delete mode 100644 meta-app-framework/recipes-graphics/wayland/agl-compositor-init/agl-compositor.service.in
 delete mode 100644 meta-app-framework/recipes-graphics/wayland/agl-compositor-init_agl-app-fw.inc
 delete mode 100644 meta-app-framework/recipes-graphics/wayland/weston-ini-conf.bbappend
 delete mode 100644 meta-app-framework/recipes-graphics/wayland/weston-ini-conf_agl-app-fw.inc

diff --git a/meta-agl-bsp/meta-rcar-gen3/recipes-platform/packagegroups/packagegroup-agl-graphical-multimedia.bbappend b/meta-agl-bsp/meta-rcar-gen3/recipes-platform/packagegroups/packagegroup-agl-graphical-multimedia.bbappend
deleted file mode 100644
index 53eb1c540..000000000
--- a/meta-agl-bsp/meta-rcar-gen3/recipes-platform/packagegroups/packagegroup-agl-graphical-multimedia.bbappend
+++ /dev/null
@@ -1,5 +0,0 @@
-RDEPENDS:${PN}:append:rcar-gen3 = "\
-    ${@bb.utils.contains('MACHINE_FEATURES','multimedia','packagegroup-multimedia-kernel-modules','',d)} \
-    ${@bb.utils.contains('MACHINE_FEATURES','multimedia','packagegroup-multimedia-libs','',d)} \
-    ${@bb.utils.contains('MACHINE_FEATURES','multimedia','packagegroup-gstreamer1.0-plugins','',d)} \
-    "
diff --git a/meta-agl-core/classes/agl-core-image.bbclass b/meta-agl-core/classes/agl-core-image.bbclass
new file mode 100644
index 000000000..bb5580391
--- /dev/null
+++ b/meta-agl-core/classes/agl-core-image.bbclass
@@ -0,0 +1,32 @@
+# AGL base image class
+#
+# As opposed to using core-image directly, this class:
+# - does not pull in packagegroup-base-extended by default to minimize images.
+#   This does mean that many of the oe-core / poky MACHINE and DISTRO features
+#   (e.g. 3g, nfs, etc.) will not result in packages being automatically pulled
+#   into images since that is driven via packagegroup-base.
+# - includes hooks for integrating SELinux via meta-selinux
+# - disables locale installation by default
+#
+
+# Disable locales
+IMAGE_LINGUAS = ""
+
+# Hook to allow inheriting e.g. selinux-image by default.
+# Any bbclass used as a value should ultimately inherit core-image
+AGL_BASE_IMAGE ?= "core-image"
+
+inherit ${AGL_BASE_IMAGE}
+
+FEATURE_PACKAGES_selinux = " \
+    packagegroup-agl-core-selinux \
+    ${@bb.utils.contains('DISTRO_FEATURES', 'agl-devel', 'packagegroup-agl-core-selinux-devel', '', d)} \
+"
+
+IMAGE_FEATURES:append = " ${@bb.utils.filter('DISTRO_FEATURES', 'selinux', d)}"
+
+CORE_IMAGE_BASE_INSTALL = " \
+    packagegroup-agl-core-boot \
+    \
+    ${CORE_IMAGE_EXTRA_INSTALL} \
+"
diff --git a/meta-agl-core/classes/agl-crosssdk.bbclass b/meta-agl-core/classes/agl-crosssdk.bbclass
new file mode 100644
index 000000000..5f6dbf303
--- /dev/null
+++ b/meta-agl-core/classes/agl-crosssdk.bbclass
@@ -0,0 +1,9 @@
+IMAGE_FEATURES += "dev-pkgs"
+IMAGE_INSTALL += "kernel-dev kernel-devsrc"
+
+inherit populate_sdk
+
+# Task do_populate_sdk and do_rootfs can't be exec simultaneously.
+# Both exec "createrepo" on the same directory, and so one of them
+# can failed (randomly).
+addtask do_populate_sdk after do_rootfs
diff --git a/meta-agl-core/recipes-config/agl-users/agl-users_1.0.bb b/meta-agl-core/recipes-config/agl-users/agl-users_1.0.bb
new file mode 100644
index 000000000..eda477f7a
--- /dev/null
+++ b/meta-agl-core/recipes-config/agl-users/agl-users_1.0.bb
@@ -0,0 +1,20 @@
+SUMMARY = "AGL Users"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
+
+inherit allarch useradd
+
+USERADD_PACKAGES = "${PN}"
+USERADDEXTENSION = "useradd-staticids"
+
+GROUPADD_PARAM:${PN} = "\
+    --system video ; \
+    --system pipewire ; \
+    -g 1001 agl-driver ; \
+"
+
+USERADD_PARAM:${PN} = "\
+    -g 1001 -u 1001 -G video,pipewire -o -d /home/agl-driver -m -K PASS_MAX_DAYS=-1 agl-driver ; \
+"
+
+ALLOW_EMPTY:${PN} = "1"
diff --git a/meta-agl-core/recipes-platform/images/core-image-weston.bbappend b/meta-agl-core/recipes-core/images/core-image-weston.bbappend
similarity index 100%
rename from meta-agl-core/recipes-platform/images/core-image-weston.bbappend
rename to meta-agl-core/recipes-core/images/core-image-weston.bbappend
diff --git a/meta-agl-core/recipes-platform/images/agl-image-weston.inc b/meta-agl-core/recipes-core/images/core-image-weston_aglcore.inc
similarity index 51%
rename from meta-agl-core/recipes-platform/images/agl-image-weston.inc
rename to meta-agl-core/recipes-core/images/core-image-weston_aglcore.inc
index 00e36bc4e..7f0711ef9 100644
--- a/meta-agl-core/recipes-platform/images/agl-image-weston.inc
+++ b/meta-agl-core/recipes-core/images/core-image-weston_aglcore.inc
@@ -1,9 +1,6 @@
-require recipes-platform/images/agl-image-minimal.inc
+# Required for weston startup with polkit in DISTRO_FEATURES
+IMAGE_INSTALL += "${@bb.utils.filter('DISTRO_FEATURES', 'polkit', d)}"
 
 # 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-graphics/wayland/agl-compositor-init.bb b/meta-agl-core/recipes-graphics/wayland/agl-compositor-init.bb
index 0cdf4d5d6..a3127a3e5 100644
--- a/meta-agl-core/recipes-graphics/wayland/agl-compositor-init.bb
+++ b/meta-agl-core/recipes-graphics/wayland/agl-compositor-init.bb
@@ -1,10 +1,16 @@
-SUMMARY = "Startup systemd unit drop-in file for the AGL Wayland compositor"
+SUMMARY = "Startup systemd unit for the AGL Wayland compositor"
 LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
 
+inherit systemd
+
 PACKAGE_ARCH = "${MACHINE_ARCH}"
 
-SRC_URI = "file://agl-compositor.conf.in"
+SRC_URI = "file://agl-compositor.service \
+           file://agl-compositor.socket \
+           file://agl-compositor-autologin \
+           file://agl-compositor.conf.in \
+"
 
 S = "${WORKDIR}"
 
@@ -15,7 +21,14 @@ AGL_COMPOSITOR_ARGS:append = " ${@bb.utils.contains("DISTRO_FEATURES", "agl-deve
 AGL_COMPOSITOR_ARGS:append = " ${@bb.utils.contains("WESTON_USE_PIXMAN", "1", " --use-pixman", "",d)}"
 
 do_install() {
-    # Process ".in" files
+    # Install systemd service
+    install -D -p -m0644 ${WORKDIR}/agl-compositor.service ${D}${systemd_system_unitdir}/agl-compositor.service
+    install -D -p -m0644 ${WORKDIR}/agl-compositor.socket ${D}${systemd_system_unitdir}/agl-compositor.socket
+    if [ "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)}" ]; then
+        install -D -p -m0644 ${WORKDIR}/agl-compositor-autologin ${D}${sysconfdir}/pam.d/agl-compositor-autologin
+    fi
+
+    # Install systemd service drop-in with extra configuration
     files=agl-compositor.conf.in
     for f in ${files}; do
         g=${f%.in}
@@ -24,17 +37,22 @@ do_install() {
                 ${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
+    install -d ${D}${systemd_system_unitdir}/agl-compositor.service.d
+    install -m644 ${WORKDIR}/agl-compositor.conf ${D}/${systemd_system_unitdir}/agl-compositor.service.d/agl-compositor.conf
 }
 
 FILES:${PN} += "\
-    ${systemd_system_unitdir}/weston.service.d \
+    ${systemd_system_unitdir}/agl-compositor.service \
+    ${systemd_system_unitdir}/agl-compositor.socket \
+    ${systemd_system_unitdir}/agl-compositor.service.d \
+    ${sysconfdir}/default/agl-compositor \
+    ${sysconfdir}/pam.d/ \
     "
 
-RDEPENDS:${PN} = " \
-    agl-compositor \
-    weston-init \
-"
+CONFFILES:${PN} += "${sysconfdir}/default/agl-compositor"
+
+RDEPENDS:${PN} = "agl-users agl-compositor weston-ini"
+
+RCONFLICTS:${PN} = "weston-init"
+
+SYSTEMD_SERVICE:${PN} = "agl-compositor.service agl-compositor.socket"
diff --git a/meta-agl-core/recipes-graphics/wayland/agl-compositor-init/agl-compositor-autologin b/meta-agl-core/recipes-graphics/wayland/agl-compositor-init/agl-compositor-autologin
new file mode 100644
index 000000000..f6e6d106d
--- /dev/null
+++ b/meta-agl-core/recipes-graphics/wayland/agl-compositor-init/agl-compositor-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/agl-compositor-init/agl-compositor.service b/meta-agl-core/recipes-graphics/wayland/agl-compositor-init/agl-compositor.service
new file mode 100644
index 000000000..b064b1ef3
--- /dev/null
+++ b/meta-agl-core/recipes-graphics/wayland/agl-compositor-init/agl-compositor.service
@@ -0,0 +1,68 @@
+# This is a system unit for launching AGL compositor with auto-login as the
+# user configured here.
+#
+# AGL compositor and Weston must be built with systemd support, and your
+# weston.ini must load the plugin systemd-notify.so.
+[Unit]
+Description=AGL compositor
+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
+
+# D-Bus is necessary for contacting logind. Logind is required.
+Wants=dbus.socket
+After=dbus.socket
+
+# Ensure the socket is present
+Requires=agl-compositor.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/agl-compositor
+ExecStart=/usr/bin/agl-compositor --modules=systemd-notify.so
+
+# Watchdog setup
+TimeoutStartSec=60
+WatchdogSec=20
+
+# The user to run as.
+User=agl-driver
+Group=agl-driver
+
+# Make sure the working directory is the users home directory
+WorkingDirectory=/home/agl-driver
+
+# Set up a full user session for the user
+PAMName=agl-compositor-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-app-framework/recipes-graphics/wayland/agl-compositor-init/agl-compositor.socket b/meta-agl-core/recipes-graphics/wayland/agl-compositor-init/agl-compositor.socket
similarity index 100%
rename from meta-app-framework/recipes-graphics/wayland/agl-compositor-init/agl-compositor.socket
rename to meta-agl-core/recipes-graphics/wayland/agl-compositor-init/agl-compositor.socket
diff --git a/meta-agl-core/recipes-graphics/wayland/weston-ini-conf.bb b/meta-agl-core/recipes-graphics/wayland/weston-ini-conf.bb
index 2f5185dd4..4c4748eec 100644
--- a/meta-agl-core/recipes-graphics/wayland/weston-ini-conf.bb
+++ b/meta-agl-core/recipes-graphics/wayland/weston-ini-conf.bb
@@ -117,7 +117,6 @@ PACKAGE_ARCH = "${MACHINE_ARCH}"
 
 ALTERNATIVE_LINK_NAME[weston.ini] = "${weston_ini_dir}/weston.ini"
 
-RDEPENDS:${PN} = "weston-init"
 RPROVIDES:${PN} = "weston-ini"
 RCONFLICTS:${PN} = "${PN}-landscape"
 ALTERNATIVE:${PN} = "weston.ini"
@@ -127,7 +126,6 @@ PACKAGE_BEFORE_PN += "${PN}-landscape"
 
 FILES:${PN}-landscape = "${weston_ini_dir}/weston.ini.landscape"
 
-RDEPENDS:${PN}-landscape = "weston-init"
 RPROVIDES:${PN}-landscape = "weston-ini"
 RCONFLICTS:${PN}-landscape = "${PN}"
 ALTERNATIVE:${PN}-landscape = "weston.ini"
@@ -137,7 +135,6 @@ PACKAGE_BEFORE_PN += "${PN}-landscape-inverted"
 
 FILES:${PN}-landscape-inverted = "${weston_ini_dir}/weston.ini.landscape-inverted"
 
-RDEPENDS:${PN}-landscape-inverted = "weston-init"
 RPROVIDES:${PN}-landscape-inverted = "weston-ini"
 RCONFLICTS:${PN}-landscape-inverted = "${PN}"
 ALTERNATIVE:${PN}-landscape-inverted = "weston.ini"
@@ -148,7 +145,6 @@ PACKAGE_BEFORE_PN += "${PN}-no-activate"
 
 FILES:${PN}-no-activate = "${weston_ini_dir}/weston.ini.default-no-activate"
 
-RDEPENDS:${PN}-no-activate = "weston-init"
 RPROVIDES:${PN}-no-activate = "weston-ini"
 RCONFLICTS:${PN}-no-activate = "${PN}"
 ALTERNATIVE:${PN}-no-activate = "weston.ini"
@@ -159,13 +155,11 @@ PACKAGE_BEFORE_PN += "${PN}-landscape-no-activate"
 
 FILES:${PN}-landscape-no-activate = "${weston_ini_dir}/weston.ini.landscape-no-activate"
 
-RDEPENDS:${PN}-landscape-no-activate = "weston-init"
 RPROVIDES:${PN}-landscape-no-activate = "weston-ini"
 RCONFLICTS:${PN}-landscape-no-activate = "${PN}"
 ALTERNATIVE:${PN}-landscape-no-activate = "weston.ini"
 ALTERNATIVE_TARGET_${PN}-landscape-no-activate = "${weston_ini_dir}/weston.ini.landscape-no-activate"
 
-
 # This is a settings-only package, we do not need a development package
 # (and its fixed dependency to ${PN} being installed)
 PACKAGES:remove = "${PN}-dev ${PN}-staticdev"
diff --git a/meta-agl-core/recipes-graphics/wayland/weston_10.0_aglcore.inc b/meta-agl-core/recipes-graphics/wayland/weston_10.0_aglcore.inc
index 41ec612ee..648d17b2f 100644
--- a/meta-agl-core/recipes-graphics/wayland/weston_10.0_aglcore.inc
+++ b/meta-agl-core/recipes-graphics/wayland/weston_10.0_aglcore.inc
@@ -9,4 +9,25 @@ SRC_URI:append = "file://0001-libweston-Send-name-description-update-wl_output-t
 		  file://0001-libweston-desktop-xdg-shell-Add-tiled-orientation-st.patch \
 		  file://0001-simple-touch-Add-maximized-fullscreen-states.patch \
 		  file://0001-libweston-weston-log-Add-an-iterator-for-going-over-.patch \
-		  file://0001-backend-drm-make-sure-all-buffers-are-released-when-.patch "
+		  file://0001-backend-drm-make-sure-all-buffers-are-released-when-.patch \
+"
+
+# Split weston-terminal out of the main package to allow installing it
+# separately for use with other compositors.  The icons, etc. that end
+# up in /usr/share/weston are also split out into a separate package
+# since they are required for weston-terminal and some of the programs
+# packaged in weston-examples in addition to ivi-shell in the main
+# package.
+
+PACKAGE_BEFORE_PN += "${PN}-data ${PN}-terminal"
+
+FILES:${PN}-data = "${datadir}/weston"
+
+FILES:${PN}-terminal = "${bindir}/weston-terminal"
+RDEPENDS:${PN}-terminal += "weston-data liberation-fonts"
+
+RDEPENDS:${PN}-examples += "weston-data"
+
+FILES:${PN}:remove = "weston-terminal"
+RDEPENDS:${PN}:remove = "liberation-fonts"
+RDEPENDS:${PN} += "weston-data weston-terminal"
diff --git a/meta-agl-core/recipes-platform/images/agl-image-agl-compositor.bb b/meta-agl-core/recipes-platform/images/agl-image-agl-compositor.bb
deleted file mode 100644
index 9ca70e041..000000000
--- a/meta-agl-core/recipes-platform/images/agl-image-agl-compositor.bb
+++ /dev/null
@@ -1,10 +0,0 @@
-SUMMARY = "A very basic Wayland image with agl-compositor"
-
-require agl-image-weston.inc
-
-LICENSE = "MIT"
-
-IMAGE_INSTALL:append = "\
-    agl-compositor \
-    packagegroup-agl-profile-graphical \
-    "
diff --git a/meta-agl-core/recipes-platform/images/agl-image-boot.bb b/meta-agl-core/recipes-platform/images/agl-image-boot.bb
index 6e2b89324..dde6a18db 100644
--- a/meta-agl-core/recipes-platform/images/agl-image-boot.bb
+++ b/meta-agl-core/recipes-platform/images/agl-image-boot.bb
@@ -1,9 +1,5 @@
-SUMMARY = "An AGL small image just capable of allowing a device to boot."
-
-require agl-image-boot.inc
-
+SUMMARY = "A small image just capable of allowing a device to boot."
 LICENSE = "MIT"
 
-IMAGE_INSTALL:append = "\
-    packagegroup-agl-image-boot \
-    "
+inherit agl-core-image
+
diff --git a/meta-agl-core/recipes-platform/images/agl-image-boot.inc b/meta-agl-core/recipes-platform/images/agl-image-boot.inc
deleted file mode 100644
index b7cb19496..000000000
--- a/meta-agl-core/recipes-platform/images/agl-image-boot.inc
+++ /dev/null
@@ -1,16 +0,0 @@
-IMAGE_LINGUAS = " "
-
-AGL_BASE_IMAGE ?= "core-image"
-
-inherit ${AGL_BASE_IMAGE}
-
-FEATURE_PACKAGES_selinux = " \
-    packagegroup-agl-core-selinux \
-    ${@bb.utils.contains('DISTRO_FEATURES', 'agl-devel', 'packagegroup-agl-core-selinux-devel', '', d)} \
-"
-
-IMAGE_FEATURES:append = " ${@bb.utils.filter('DISTRO_FEATURES', 'selinux', d)}"
-
-IMAGE_INSTALL = "packagegroup-agl-core-boot ${CORE_IMAGE_EXTRA_INSTALL}"
-
-IMAGE_ROOTFS_SIZE ?= "8192"
diff --git a/meta-agl-core/recipes-platform/images/agl-image-compositor.bb b/meta-agl-core/recipes-platform/images/agl-image-compositor.bb
new file mode 100644
index 000000000..ea48f474f
--- /dev/null
+++ b/meta-agl-core/recipes-platform/images/agl-image-compositor.bb
@@ -0,0 +1,15 @@
+SUMMARY = "A very basic Wayland image with agl-compositor"
+LICENSE = "MIT"
+
+require agl-image-minimal.bb
+
+inherit features_check
+
+REQUIRED_DISTRO_FEATURES = "wayland"
+
+SYSTEMD_DEFAULT_TARGET = "graphical.target"
+
+IMAGE_INSTALL += " \
+    packagegroup-agl-graphical-compositor \
+    ${@bb.utils.contains('DISTRO_FEATURES', 'agl-devel', 'agl-shell-activator weston-examples', '', d)} \
+"
diff --git a/meta-agl-core/recipes-platform/images/agl-image-core-autobuilder.bb b/meta-agl-core/recipes-platform/images/agl-image-core-autobuilder.bb
index 3a887a5c0..eec1cf54c 100644
--- a/meta-agl-core/recipes-platform/images/agl-image-core-autobuilder.bb
+++ b/meta-agl-core/recipes-platform/images/agl-image-core-autobuilder.bb
@@ -1,16 +1,14 @@
 SUMMARY = "A very basic Wayland image with a terminal"
+LICENSE = "MIT"
 
-require agl-image-weston.inc
+require agl-image-weston.bb
 
-LICENSE = "MIT"
+IMAGE_FEATURES += "splash"
 
-IMAGE_INSTALL:append = "\
-    packagegroup-agl-profile-graphical \
+IMAGE_INSTALL += " \
     busybox \
-    psplash \
     gdb \
     gperf \
-    weston \
     weston-examples \
     curl \
     ptest-runner \
diff --git a/meta-agl-core/recipes-platform/images/agl-image-minimal-crosssdk.bb b/meta-agl-core/recipes-platform/images/agl-image-minimal-crosssdk.bb
index 8c5aae1bf..6aa308273 100644
--- a/meta-agl-core/recipes-platform/images/agl-image-minimal-crosssdk.bb
+++ b/meta-agl-core/recipes-platform/images/agl-image-minimal-crosssdk.bb
@@ -1,18 +1,9 @@
-SUMMARY = "Cross SDK of Full AGL Distribution for core profile"
-
-DESCRIPTION = "SDK image for full AGL Distribution for IVI profile. \
-It includes the full meta-toolchain, plus developement headers and libraries \
-to form a standalone cross SDK."
-
 require agl-image-minimal.bb
 
+SUMMARY = "Cross SDK of minimal AGL Distribution for core profile"
+DESCRIPTION = "SDK image for AGL core distribution. \
+It includes the full toolchain, plus developement headers and libraries \
+to form a standalone cross SDK."
 LICENSE = "MIT"
 
-require agl-image-minimal-crosssdk.inc
-
-inherit populate_sdk
-
-# Task do_populate_sdk and do_rootfs can't be exec simultaneously.
-# Both exec "createrepo" on the same directory, and so one of them
-# can failed (randomly).
-addtask do_populate_sdk after do_rootfs
+inherit agl-crosssdk
diff --git a/meta-agl-core/recipes-platform/images/agl-image-minimal-crosssdk.inc b/meta-agl-core/recipes-platform/images/agl-image-minimal-crosssdk.inc
deleted file mode 100644
index bab27eb98..000000000
--- a/meta-agl-core/recipes-platform/images/agl-image-minimal-crosssdk.inc
+++ /dev/null
@@ -1,2 +0,0 @@
-IMAGE_FEATURES:append = " dev-pkgs"
-IMAGE_INSTALL:append = " kernel-dev kernel-devsrc"
diff --git a/meta-agl-core/recipes-platform/images/agl-image-minimal.bb b/meta-agl-core/recipes-platform/images/agl-image-minimal.bb
index 52cc06aeb..4e54e93ed 100644
--- a/meta-agl-core/recipes-platform/images/agl-image-minimal.bb
+++ b/meta-agl-core/recipes-platform/images/agl-image-minimal.bb
@@ -1,9 +1,9 @@
 SUMMARY = "An AGL small image just capable of allowing a device to boot."
+LICENSE = "MIT"
 
-require agl-image-minimal.inc
+inherit agl-core-image
 
-LICENSE = "MIT"
+IMAGE_INSTALL = "packagegroup-agl-image-minimal ${CORE_IMAGE_EXTRA_INSTALL}"
 
-IMAGE_INSTALL:append = "\
-    packagegroup-agl-image-minimal \
-    "
+IMAGE_ROOTFS_SIZE ?= "8192"
+IMAGE_ROOTFS_EXTRA_SPACE:append = "${@bb.utils.contains("DISTRO_FEATURES", "systemd", " + 4096", "", d)}"
diff --git a/meta-agl-core/recipes-platform/images/agl-image-minimal.inc b/meta-agl-core/recipes-platform/images/agl-image-minimal.inc
deleted file mode 100644
index 50b6336de..000000000
--- a/meta-agl-core/recipes-platform/images/agl-image-minimal.inc
+++ /dev/null
@@ -1 +0,0 @@
-require agl-image-boot.inc
diff --git a/meta-agl-core/recipes-platform/images/agl-image-weston.bb b/meta-agl-core/recipes-platform/images/agl-image-weston.bb
index 7e9f8814e..d902020cc 100644
--- a/meta-agl-core/recipes-platform/images/agl-image-weston.bb
+++ b/meta-agl-core/recipes-platform/images/agl-image-weston.bb
@@ -1,9 +1,15 @@
 SUMMARY = "A very basic Wayland image with a terminal"
+LICENSE = "MIT"
 
-require agl-image-weston.inc
+require agl-image-minimal.bb
 
-LICENSE = "MIT"
+inherit features_check
+
+REQUIRED_DISTRO_FEATURES = "wayland"
+
+SYSTEMD_DEFAULT_TARGET = "graphical.target"
 
-IMAGE_INSTALL:append = "\
-    packagegroup-agl-profile-graphical \
-    "
+IMAGE_INSTALL += " \
+    packagegroup-agl-graphical-weston \
+    ${@bb.utils.contains('DISTRO_FEATURES', 'agl-devel', 'weston-examples', '', 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
deleted file mode 100644
index 82e348587..000000000
--- a/meta-agl-core/recipes-platform/images/core-image-weston_aglcore.inc
+++ /dev/null
@@ -1,3 +0,0 @@
-# NOTE: In hardknott or later this can be replaced by adding "weston"
-#       to IMAGE_FEATURES.
-SYSTEMD_DEFAULT_TARGET = "graphical.target"
diff --git a/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-core-boot.bb b/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-core-boot.bb
index fe1ee7b8c..28a734548 100644
--- a/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-core-boot.bb
+++ b/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-core-boot.bb
@@ -16,6 +16,7 @@ VIRTUAL-RUNTIME_rngd ?= "rng-tools"
 
 RDEPENDS:${PN} = "\
     packagegroup-core-boot \
+    packagegroup-machine-base \
     ${VIRTUAL-RUNTIME_rngd} \
 "
 
diff --git a/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-core-devel.bb b/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-core-devel.bb
index eca4f5222..fc72d11cd 100644
--- a/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-core-devel.bb
+++ b/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-core-devel.bb
@@ -21,11 +21,4 @@ RDEPENDS:${PN} = "\
         pciutils \
         openssh-sftp-server \
         zstd \
-        "
-
-# needs meta-oe present
-#RRECOMMENDS:${PN} = "\
-#        jq \
-#        htop \
-#        tree \
-#"
+"
diff --git a/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-core-os-commonlibs.bb b/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-core-os-commonlibs.bb
deleted file mode 100644
index 0ee63e82a..000000000
--- a/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-core-os-commonlibs.bb
+++ /dev/null
@@ -1,14 +0,0 @@
-SUMMARY = "The packages of middlewares for AGL IVI profile"
-DESCRIPTION = "The set of packages required by Operating System and Common libraries Subsystem"
-LICENSE = "MIT"
-
-inherit packagegroup
-
-PACKAGES = "\
-    packagegroup-agl-core-os-commonlibs \
-    "
-
-ALLOW_EMPTY:${PN} = "1"
-
-RDEPENDS:${PN} += "\
-    "
diff --git a/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-core-security.bb b/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-core-security.bb
deleted file mode 100644
index 7532f4cd7..000000000
--- a/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-core-security.bb
+++ /dev/null
@@ -1,14 +0,0 @@
-SUMMARY = "The packages of middlewares for AGL IVI profile"
-DESCRIPTION = "The set of packages required by Operating System and Common libraries Subsystem"
-LICENSE = "MIT"
-
-inherit packagegroup
-
-PACKAGES = "\
-    packagegroup-agl-core-security \
-    "
-
-ALLOW_EMPTY:${PN} = "1"
-
-RDEPENDS:${PN} += "\
-    "
diff --git a/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-graphical-compositor.bb b/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-graphical-compositor.bb
new file mode 100644
index 000000000..be124925f
--- /dev/null
+++ b/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-graphical-compositor.bb
@@ -0,0 +1,13 @@
+DESCRIPTION = "The minimal set of packages required for the AGL compositor"
+LICENSE = "MIT"
+
+inherit packagegroup features_check
+
+# agl-compositor-init requires pam enabled if started via systemd
+REQUIRED_DISTRO_FEATURES = "wayland ${@oe.utils.conditional('VIRTUAL-RUNTIME_init_manager', 'systemd', 'pam', '', d)}"
+
+RDEPENDS:${PN} += " \
+    agl-compositor \
+    agl-compositor-init \
+    ${@bb.utils.filter('DISTRO_FEATURES', 'polkit', d)} \
+"
diff --git a/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-graphical-multimedia.bb b/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-graphical-multimedia.bb
deleted file mode 100644
index f9903d942..000000000
--- a/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-graphical-multimedia.bb
+++ /dev/null
@@ -1,16 +0,0 @@
-SUMMARY = "The software for application framework of AGL IVI profile"
-DESCRIPTION = "A set of packages belong to AGL application framework which required by \
-Multimedia Subsystem"
-
-LICENSE = "MIT"
-
-inherit packagegroup
-
-PACKAGES = "\
-    packagegroup-agl-graphical-multimedia \
-    "
-
-RDEPENDS:${PN} += "\
-    alsa-utils \
-    gstreamer1.0-meta-base \
-    "
diff --git a/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-graphical-weston.bb b/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-graphical-weston.bb
index 859303049..af4d90c49 100644
--- a/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-graphical-weston.bb
+++ b/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-graphical-weston.bb
@@ -1,17 +1,13 @@
-DESCRIPTION = "The minimal set of packages required for Wayland support"
+DESCRIPTION = "The minimal set of packages required for the Weston compositor"
 LICENSE = "MIT"
 
-inherit packagegroup
+inherit packagegroup features_check
 
-PACKAGES = "\
-    packagegroup-agl-graphical-weston \
-    "
-
-ALLOW_EMPTY:${PN} = "1"
+# weston-init requires pam enabled if started via systemd
+REQUIRED_DISTRO_FEATURES = "wayland ${@oe.utils.conditional('VIRTUAL-RUNTIME_init_manager', 'systemd', 'pam', '', d)}"
 
 RDEPENDS:${PN} += " \
-                  weston \
-                  weston-init \
-                  weston-examples \
-                  "
-
+    weston \
+    weston-init \
+    ${@bb.utils.filter('DISTRO_FEATURES', 'polkit', d)} \
+"
diff --git a/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-image-boot.bb b/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-image-boot.bb
deleted file mode 100644
index 8b2cfbb31..000000000
--- a/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-image-boot.bb
+++ /dev/null
@@ -1,18 +0,0 @@
-DESCRIPTION = "The minimal set of packages required by AGL"
-LICENSE = "MIT"
-
-inherit packagegroup
-
-PACKAGES = "\
-    packagegroup-agl-image-boot \
-    "
-
-ALLOW_EMPTY:${PN} = "1"
-
-RDEPENDS:${PN} += "\
-    packagegroup-agl-core-boot \
-    packagegroup-machine-base \
-    "
-
-RDEPENDS:${PN} += "\
-    "
diff --git a/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-image-minimal.bb b/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-image-minimal.bb
index 1a51a9bf1..a60cbab21 100644
--- a/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-image-minimal.bb
+++ b/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-image-minimal.bb
@@ -12,13 +12,7 @@ ALLOW_EMPTY:${PN} = "1"
 
 RDEPENDS:${PN} += "\
     packagegroup-agl-core-boot \
-    packagegroup-machine-base \
-    "
-
-RDEPENDS:${PN} += "\
     packagegroup-agl-core-connectivity \
-    packagegroup-agl-core-os-commonlibs \
-    packagegroup-agl-core-security \
     "
 
 RDEPENDS:profile-agl-minimal = "${PN}"
diff --git a/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-profile-graphical.bb b/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-profile-graphical.bb
index 13b5fdc41..b92e760ae 100644
--- a/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-profile-graphical.bb
+++ b/meta-agl-core/recipes-platform/packagegroups/packagegroup-agl-profile-graphical.bb
@@ -1,5 +1,5 @@
 SUMMARY = "The middleware for AGL IVI profile"
-DESCRIPTION = "The set of packages required for AGL IVI Distribution"
+DESCRIPTION = "The base set of packages required for a AGL IVI Distribution"
 LICENSE = "MIT"
 
 inherit packagegroup
@@ -7,14 +7,11 @@ inherit packagegroup
 PACKAGES = "\
     packagegroup-agl-profile-graphical \
     profile-graphical \
-    "
-
-ALLOW_EMPTY:${PN} = "1"
+"
 
 RDEPENDS:${PN} += "\
     packagegroup-agl-image-minimal \
-    packagegroup-agl-graphical-weston \
-    packagegroup-agl-graphical-multimedia \
+    packagegroup-agl-graphical-compositor \
 "
 
 RDEPENDS:profile-graphical = "${PN}"
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
deleted file mode 100644
index de31f999a..000000000
--- a/meta-app-framework/recipes-config/agl-session/agl-session_0.1.bb
+++ /dev/null
@@ -1,49 +0,0 @@
-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 \
-    file://50-xdg-data-dirs.sh \
-"
-
-inherit systemd allarch useradd
-
-USERADD_PACKAGES = "${PN}"
-USERADDEXTENSION = "useradd-staticids"
-GROUPADD_PARAM:${PN} = "\
-	--system display ; \
-	--system video ; \
-	--system pipewire ; \
-	-g 1001 agl-driver ; \
-	-g 1003 applaunchd ; \
-"
-
-USERADD_PARAM:${PN} = "\
-  -g 1001 -u 1001 -G video,display,pipewire -o -d /home/agl-driver -m -K PASS_MAX_DAYS=-1 agl-driver ; \
-  -g 1003 -u 1003 -o -d / -K PASS_MAX_DAYS=-1 applaunchd ; \
-"
-
-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}
-
-    install -d ${D}${libdir}/systemd/user-environment-generators
-    install -m 0755 ${WORKDIR}/50-xdg-data-dirs.sh ${D}${libdir}/systemd/user-environment-generators/
-}
-
-FILES:${PN} += " \
-    ${systemd_system_unitdir} \
-    ${systemd_user_unitdir} \
-    ${libdir}/systemd/user-environment-generators/ \
-"
diff --git a/meta-app-framework/recipes-config/agl-session/files/50-xdg-data-dirs.sh b/meta-app-framework/recipes-config/agl-session/files/50-xdg-data-dirs.sh
deleted file mode 100644
index 15ec3744a..000000000
--- a/meta-app-framework/recipes-config/agl-session/files/50-xdg-data-dirs.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-# use a default value if not already set
-XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share/:/usr/share}"
-
-# write our output
-echo "XDG_DATA_DIRS=${XDG_DATA_DIRS}"
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
deleted file mode 100644
index 84d9daa5b..000000000
--- a/meta-app-framework/recipes-config/agl-session/files/agl-session.target
+++ /dev/null
@@ -1,5 +0,0 @@
-[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
deleted file mode 100644
index 61afa4141..000000000
--- a/meta-app-framework/recipes-config/agl-session/files/agl-session@.service
+++ /dev/null
@@ -1,24 +0,0 @@
-[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
diff --git a/meta-app-framework/recipes-core/applaunchd/applaunchd_git.bb b/meta-app-framework/recipes-core/applaunchd/applaunchd_git.bb
index 3b2265df0..767c8bcc5 100644
--- a/meta-app-framework/recipes-core/applaunchd/applaunchd_git.bb
+++ b/meta-app-framework/recipes-core/applaunchd/applaunchd_git.bb
@@ -29,7 +29,14 @@ SRCREV = "7a3e870a8349d43a4838604db2c28140c2f76c9f"
 
 S = "${WORKDIR}/git"
 
-inherit meson pkgconfig systemd
+inherit meson pkgconfig systemd useradd
+
+USERADD_PACKAGES = "${PN}"
+USERADDEXTENSION = "useradd-staticids"
+GROUPADD_PARAM:${PN} = "-g 1003 applaunchd ; "
+USERADD_PARAM:${PN} = "\
+    -g 1003 -u 1003 -o -d / -K PASS_MAX_DAYS=-1 applaunchd ; \
+"
 
 SYSTEMD_SERVICE:${PN} = "applaunchd.service"
 
@@ -58,7 +65,7 @@ FILES:${PN}-template-agl-app-web = "${systemd_system_unitdir}/agl-app-web@.servi
 FILES:${PN}-template-agl-app-flutter = "${systemd_system_unitdir}/agl-app-flutter@.service"
 
 RDEPENDS:${PN} += " \
-    agl-session \
+    agl-users \
     polkit-rule-agl-app \
 "
 
diff --git a/meta-app-framework/recipes-graphics/wayland/agl-compositor-init.bbappend b/meta-app-framework/recipes-graphics/wayland/agl-compositor-init.bbappend
deleted file mode 100644
index 70cbaabe2..000000000
--- a/meta-app-framework/recipes-graphics/wayland/agl-compositor-init.bbappend
+++ /dev/null
@@ -1 +0,0 @@
-require ${@bb.utils.contains('AGL_FEATURES', 'agl-app-fw', 'agl-compositor-init_agl-app-fw.inc', '', d)}
diff --git a/meta-app-framework/recipes-graphics/wayland/agl-compositor-init/agl-compositor.conf b/meta-app-framework/recipes-graphics/wayland/agl-compositor-init/agl-compositor.conf
deleted file mode 100644
index 66778a91b..000000000
--- a/meta-app-framework/recipes-graphics/wayland/agl-compositor-init/agl-compositor.conf
+++ /dev/null
@@ -1,11 +0,0 @@
-[Unit]
-ConditionPathExists=/dev/tty7
-
-[Service]
-Environment=XDG_SESSION_TYPE=wayland
-TTYPath=/dev/tty7
-TTYReset=yes
-TTYVHangup=yes
-TTYVTDisallocate=yes
-UtmpIdentifier=tty7
-UtmpMode=user
diff --git a/meta-app-framework/recipes-graphics/wayland/agl-compositor-init/agl-compositor.service.in b/meta-app-framework/recipes-graphics/wayland/agl-compositor-init/agl-compositor.service.in
deleted file mode 100644
index fd56c7c3e..000000000
--- a/meta-app-framework/recipes-graphics/wayland/agl-compositor-init/agl-compositor.service.in
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Weston must be built with systemd support, and your weston.ini must load
-# the plugin systemd-notify.so.
-
-[Unit]
-Description=agl-compositor, a Wayland compositor, as a systemd user service
-Documentation=https://docs.automotivelinux.org/en/master/#5_Component_Documentation/1_agl-compositor/
-
-# Activate using a systemd socket
-Requires=agl-compositor.socket
-After=agl-compositor.socket
-
-# Since we are part of the agl session, make sure we are started before
-# it is complete.
-Before=agl-session.target
-
-[Service]
-Type=notify
-EnvironmentFile=-/etc/default/agl-compositor
-ExecStart=/usr/bin/agl-compositor @AGL_COMPOSITOR_ARGS@
-
-TimeoutStartSec=60
-WatchdogSec=20
-
-StandardOutput=journal
-StandardError=journal
-
-[Install]
-WantedBy=agl-session.target
diff --git a/meta-app-framework/recipes-graphics/wayland/agl-compositor-init_agl-app-fw.inc b/meta-app-framework/recipes-graphics/wayland/agl-compositor-init_agl-app-fw.inc
deleted file mode 100644
index b97a537d5..000000000
--- a/meta-app-framework/recipes-graphics/wayland/agl-compositor-init_agl-app-fw.inc
+++ /dev/null
@@ -1,47 +0,0 @@
-FILESEXTRAPATHS:prepend := "${THISDIR}/agl-compositor-init:"
-
-SRC_URI = " \
-    file://agl-compositor.conf \
-    file://agl-compositor.service.in \
-    file://agl-compositor.socket \
-    "
-
-# Reset systemd services list
-SYSTEMD_SERVICE:${PN} = ""
-
-do_install() {
-    # Process ".in" files
-    files=agl-compositor.service.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 -d ${D}${systemd_system_unitdir}/agl-session@agl-driver.service.d
-    install -m 0644 ${WORKDIR}/agl-compositor.conf \
-        ${D}${systemd_system_unitdir}/agl-session@agl-driver.service.d/agl-compositor.conf
-
-    install -D -p -m0644 ${WORKDIR}/agl-compositor.service ${D}${systemd_user_unitdir}/agl-compositor.service
-    install -D -p -m0644 ${WORKDIR}/agl-compositor.socket ${D}${systemd_user_unitdir}/agl-compositor.socket
-
-    # Enable the compositor as part of the user session
-    install -d ${D}${systemd_user_unitdir}/agl-session.target.wants
-    ln -s ../agl-compositor.service ${D}${systemd_user_unitdir}/agl-session.target.wants/agl-compositor.service
-}
-
-FILES:${PN} = "\
-    ${systemd_system_unitdir} \
-    ${systemd_user_unitdir} \
-"
-
-RDEPENDS:${PN} = " \
-    agl-compositor \
-    agl-shell-activator \
-    agl-session \
-    weston-ini \
-"
-
-RCONFLICTS:${PN} = "weston-init"
diff --git a/meta-app-framework/recipes-graphics/wayland/weston-ini-conf.bbappend b/meta-app-framework/recipes-graphics/wayland/weston-ini-conf.bbappend
deleted file mode 100644
index 699275fe8..000000000
--- a/meta-app-framework/recipes-graphics/wayland/weston-ini-conf.bbappend
+++ /dev/null
@@ -1 +0,0 @@
-require ${@bb.utils.contains('AGL_FEATURES', 'agl-app-fw', 'weston-ini-conf_agl-app-fw.inc', '', d)}
diff --git a/meta-app-framework/recipes-graphics/wayland/weston-ini-conf_agl-app-fw.inc b/meta-app-framework/recipes-graphics/wayland/weston-ini-conf_agl-app-fw.inc
deleted file mode 100644
index 48af1968c..000000000
--- a/meta-app-framework/recipes-graphics/wayland/weston-ini-conf_agl-app-fw.inc
+++ /dev/null
@@ -1,5 +0,0 @@
-RDEPENDS:${PN} = ""
-RDEPENDS:${PN}-landscape = ""
-RDEPENDS:${PN}-landscape-inverted = ""
-RDEPENDS:${PN}-no-activate = ""
-RDEPENDS:${PN}-landscape-no-activate = ""
diff --git a/meta-pipewire/recipes-core/packagegroups/packagegroup-pipewire.bb b/meta-pipewire/recipes-core/packagegroups/packagegroup-pipewire.bb
index b56723b2b..e7ad14258 100644
--- a/meta-pipewire/recipes-core/packagegroups/packagegroup-pipewire.bb
+++ b/meta-pipewire/recipes-core/packagegroups/packagegroup-pipewire.bb
@@ -6,6 +6,7 @@ inherit packagegroup
 
 PACKAGES = "\
     packagegroup-pipewire \
+    packagegroup-pipewire-tools \
     "
 
 RDEPENDS:${PN} += "\
@@ -15,5 +16,9 @@ RDEPENDS:${PN} += "\
     pipewire-alsa \
     gstreamer1.0-pipewire \
     wireplumber \
-    ${@bb.utils.contains('DISTRO_FEATURES', 'agl-devel', 'pipewire-tools pipewire-spa-tools', '', d)} \
 "
+
+RDEPENDS:${PN}-tools += "\
+    pipewire-tools \
+    pipewire-spa-tools \
+"
\ No newline at end of file
-- 
2.16.6