-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change introduces logic to generate a CDI definition for the Weston display created at boot. With CDI enabled in a container runtime like Docker, you could run Wayland apps with a command like: running: ``` docker run --rm -it --device=org.wayland/display=wayland-1 ubuntu ``` Signed-off-by: Andy Doan <[email protected]>
- Loading branch information
Showing
3 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
meta-lmp-base/recipes-containers/wayland-cdi/files/wayland-cdi-generate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/sh | ||
|
||
cditmp="/run/cdi/.wayland.yaml.tmp" | ||
|
||
mkdir -p /run/cdi | ||
cat >${cditmp} <<EOF | ||
cdiVersion: "0.6.0" | ||
kind: org.wayland/display | ||
devices: | ||
EOF | ||
|
||
mounts="" | ||
for x in `find /run/user -mindepth 2 -maxdepth 2 -type s -name wayland-\*` ; do | ||
echo Found Wayland instance: $x | ||
found=1 | ||
xdg_dir="$(dirname $x)" | ||
display_name="$(basename $x)" | ||
mounts="${mounts} ${xdg_dir}" | ||
cat >>${cditmp} <<EOF | ||
- name: ${display_name} | ||
containerEdits: | ||
env: | ||
- WAYLAND_DISPLAY=${display_name} | ||
- XDG_RUNTIME_DIR=${xdg_dir} | ||
EOF | ||
done | ||
|
||
if [ -n "${mounts}" ] ; then | ||
cat >>${cditmp} <<EOF | ||
containerEdits: | ||
mounts: | ||
EOF | ||
|
||
for x in ${mounts} ; do | ||
cat >>${cditmp} <<EOF | ||
- type: bind | ||
hostPath: ${x} | ||
containerPath: ${x} | ||
options: | ||
- rbind | ||
- rprivate | ||
EOF | ||
done | ||
mv ${cditmp} /run/cdi/wayland.yaml | ||
else | ||
rm ${cditmp} | ||
fi |
13 changes: 13 additions & 0 deletions
13
meta-lmp-base/recipes-containers/wayland-cdi/files/wayland-cdi.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[Unit] | ||
Description=CDI device entry generator for Wayland | ||
After=weston.service | ||
Before=docker.service | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/bin/wayland-cdi-generate | ||
RemainAfterExit=yes | ||
|
||
[Install] | ||
WantedBy=weston.service | ||
RequiredBy=docker.service |
24 changes: 24 additions & 0 deletions
24
meta-lmp-base/recipes-containers/wayland-cdi/wayland-cdi_0.1.bb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
SUMMARY = "Sets up a CDI device entry for the Wayland display" | ||
LICENSE = "MIT" | ||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" | ||
|
||
inherit allarch systemd | ||
|
||
RDEPENDS:${PN} = "systemd" | ||
|
||
SRC_URI = "file://wayland-cdi.service \ | ||
file://wayland-cdi-generate \ | ||
" | ||
|
||
PACKAGE_ARCH = "${MACHINE_ARCH}" | ||
|
||
SYSTEMD_SERVICE:${PN} = "wayland-cdi.service" | ||
SYSTEMD_AUTO_ENABLE:${PN} = "enable" | ||
|
||
do_install() { | ||
install -d ${D}${bindir} | ||
install -m 0755 ${WORKDIR}/wayland-cdi-generate ${D}${bindir}/wayland-cdi-generate | ||
|
||
install -d ${D}${systemd_system_unitdir} | ||
install -m 0644 ${WORKDIR}/wayland-cdi.service ${D}${systemd_system_unitdir} | ||
} |