359cb76e5061f1dbc62f0c3e74101193dbe1978b
[AGL/meta-agl.git] / meta-agl / recipes-graphics / wayland / weston-init.bbappend
1 FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
2
3 inherit agl-graphical
4
5 WESTONSTART ??= "/usr/bin/weston --idle-time=4294967 --tty=${WESTONTTY}"
6 WESTONSTART_append = " ${@bb.utils.contains("IMAGE_FEATURES", "debug-tweaks", " --log=${DISPLAY_XDG_RUNTIME_DIR}/weston.log", "",d)}"
7
8 SRC_URI += " \
9     file://weston_tmpfiles.conf \
10     file://weston.service.add \
11 "
12
13 do_install_append() {
14     sed -i "/\[Unit\]/aConflicts=getty@tty${WESTONTTY}.service" \
15            ${D}${systemd_system_unitdir}/weston.service
16
17     sed -i "/\[Service\]/r ${S}/weston.service.add" \
18            ${D}${systemd_system_unitdir}/weston.service
19
20     sed -e 's,User=root,User=${WESTONUSER},g' \
21         -e 's,ExecStart=.*,ExecStart=${WESTONSTART},g' \
22         -e 's,@WESTONTTY@,${WESTONTTY},g' \
23         -e 's,@XDG_RUNTIME_DIR@,${DISPLAY_XDG_RUNTIME_DIR},g' \
24         -i ${D}${systemd_system_unitdir}/weston.service
25
26     # Add a rule to ensure the 'display' user has permissions to
27     # open the graphics device
28     install -d ${D}${sysconfdir}/init.d
29     install -d ${D}${sysconfdir}/udev/rules.d
30     cat >${D}${sysconfdir}/udev/rules.d/zz-dri.rules <<'EOF'
31 SUBSYSTEM=="drm", MODE="0660", GROUP="${WESTONGROUP}", SECLABEL{smack}="*"
32 EOF
33
34     # user 'display' must own /dev/tty${WESTONTTY} for weston to start correctly
35     cat >${D}${sysconfdir}/udev/rules.d/zz-tty.rules <<'EOF'
36 SUBSYSTEM=="tty", KERNEL=="tty${WESTONTTY}", OWNER="${WESTONUSER}", SECLABEL{smack}="^"
37 EOF
38
39     # user 'display' must also be able to access /dev/input/*
40     cat >${D}${sysconfdir}/udev/rules.d/zz-input.rules <<'EOF'
41 SUBSYSTEM=="input", MODE="0660", GROUP="input", SECLABEL{smack}="^"
42 EOF
43
44     install -d ${D}${sysconfdir}/tmpfiles.d
45     install -Dm755 ${WORKDIR}/weston_tmpfiles.conf ${D}/${libdir}/tmpfiles.d/weston.conf
46
47     sed -e 's,@WESTONUSER@,${WESTONUSER},g' \
48         -e 's,@WESTONGROUP@,${WESTONGROUP},g' \
49         -i ${D}/${libdir}/tmpfiles.d/weston.conf
50 }
51
52 FILES_${PN} += "${libdir}/tmpfiles.d/*.conf"
53
54