summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephane Desneux <stephane.desneux@open.eurogiciel.org>2014-03-21 18:45:26 +0100
committerStephane Desneux <stephane.desneux@open.eurogiciel.org>2014-04-11 01:54:35 +0200
commit529d9eff7c79e3c9af13b874679d5db75c3ebb55 (patch)
tree38b9463772ccfc2b458f5e66d51c7957f46d166b
parenteb35717f522bba62f83eee1547383ed1094bcd43 (diff)
downloadweston-common-529d9eff7c79e3c9af13b874679d5db75c3ebb55.tar.gz
weston-common-529d9eff7c79e3c9af13b874679d5db75c3ebb55.tar.bz2
weston-common-529d9eff7c79e3c9af13b874679d5db75c3ebb55.zip
start weston as system daemon
Change-Id: Icc6255640f452a819c08f1a1abe693d652bd681c
-rw-r--r--display-manager-run.service11
-rw-r--r--display-manager.path7
-rw-r--r--display-manager.service8
-rw-r--r--packaging/weston-generic.spec59
-rw-r--r--weston-user.service8
-rw-r--r--weston.service11
-rw-r--r--weston.sh6
-rw-r--r--weston.sysconfig2
-rw-r--r--weston_tmpfiles.conf5
9 files changed, 101 insertions, 16 deletions
diff --git a/display-manager-run.service b/display-manager-run.service
new file mode 100644
index 0000000..30afa9e
--- /dev/null
+++ b/display-manager-run.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Weston display daemon
+
+[Service]
+ExecStart=/usr/bin/weston-launch -u display -- -i0
+StandardInput=tty
+TTYPath=/dev/tty1
+EnvironmentFile=/etc/sysconfig/weston
+
+[Install]
+WantedBy=graphical.target
diff --git a/display-manager.path b/display-manager.path
new file mode 100644
index 0000000..d1ae107
--- /dev/null
+++ b/display-manager.path
@@ -0,0 +1,7 @@
+[Unit]
+Description=Wait for wayland socket
+Requires=display-manager-run.service
+After=display-manager-run.service
+
+[Path]
+PathExists=/run/display/wayland-0
diff --git a/display-manager.service b/display-manager.service
new file mode 100644
index 0000000..dc6e1ab
--- /dev/null
+++ b/display-manager.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Display manager setup service
+
+[Service]
+ExecStart=/usr/bin/chmod g+w /run/display/wayland-0
+
+[Install]
+WantedBy=graphical.target
diff --git a/packaging/weston-generic.spec b/packaging/weston-generic.spec
index 4779377..2f2a36b 100644
--- a/packaging/weston-generic.spec
+++ b/packaging/weston-generic.spec
@@ -33,24 +33,73 @@ cp %{SOURCE1001} .
%install
-install -d %{buildroot}%{_unitdir_user}/weston.target.wants
-install -m 644 weston.service %{buildroot}%{_unitdir_user}/weston.service
-ln -sf ../weston.service %{buildroot}/%{_unitdir_user}/weston.target.wants/
+# install weston service as 'display-manager.service' as it's the one wanted by graphical.target
+mkdir -p %{buildroot}%{_unitdir}
+install -m 644 display-manager-run.service %{buildroot}%{_unitdir}/display-manager-run.service
+install -m 644 display-manager.service %{buildroot}%{_unitdir}/display-manager.service
+install -m 644 display-manager.path %{buildroot}%{_unitdir}/display-manager.path
+# install Environment file for weston service
+mkdir -p %{buildroot}%{_sysconfdir}/sysconfig
+install -m 0644 weston.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/weston
+
+# install tmpfiles.d(5) conf
+mkdir -p %{buildroot}%{_prefix}/lib/tmpfiles.d
+install -m 0644 weston_tmpfiles.conf %{buildroot}%{_prefix}/lib/tmpfiles.d/weston.conf
+
+# install weston-user service in user session
+mkdir -p %{buildroot}%{_unitdir_user}
+install -m 644 weston-user.service %{buildroot}%{_unitdir_user}/
+
+# install weston.sh
mkdir -p %{buildroot}%{_sysconfdir}/profile.d/
install -m 0644 weston.sh %{buildroot}%{_sysconfdir}/profile.d/
+# install weston.ini
%define weston_config_dir %{_sysconfdir}/xdg/weston
mkdir -p %{buildroot}%{weston_config_dir}
install -m 0644 weston.ini %{buildroot}%{weston_config_dir}
+# Add a rule to ensure the 'display' user has permissions to
+# open the graphics device
+mkdir -p %{buildroot}%{_sysconfdir}/udev/rules.d
+cat >%{buildroot}%{_sysconfdir}/udev/rules.d/99-dri.rules <<'EOF'
+SUBSYSTEM=="drm", MODE="0660", GROUP="display"
+EOF
+
+# user 'display' must own /dev/tty1 for weston to start correctly
+cat >%{buildroot}%{_sysconfdir}/udev/rules.d/99-tty.rules <<'EOF'
+SUBSYSTEM=="tty", KERNEL=="tty1", GROUP="display", OWNER="display"
+EOF
+
+%pre
+# create groups 'display' and 'weston-launch'
+getent group display >/dev/null || %{_sbindir}/groupadd -r -o display
+getent group weston-launch >/dev/null || %{_sbindir}/groupadd -r -o weston-launch
+
+# create user 'display'
+getent passwd display >/dev/null || %{_sbindir}/useradd -r -g display -G weston-launch -d /run/display -s /bin/false -c "Display daemon" display
+
+# setup display manager service
+mkdir -p %{_unitdir}/graphical.target.wants/
+ln -s ../display-manager.path %{_unitdir}/graphical.target.wants/
+
+# setup display manager access (inside user session)
+mkdir -p %{_unitdir_user}/default.target.wants/
+ln -s ../weston-user.service %{_unitdir_user}/default.target.wants/
+
%files
%manifest %{name}.manifest
%defattr(-,root,root)
%license COPYING
-%{_unitdir_user}/weston.service
-%{_unitdir_user}/weston.target.wants/weston.service
+%{_unitdir}/display-manager-run.service
+%{_unitdir}/display-manager.service
+%{_unitdir}/display-manager.path
+%config %{_sysconfdir}/sysconfig/weston
+%{_prefix}/lib/tmpfiles.d/weston.conf
+%{_unitdir_user}/weston-user.service
%config %{_sysconfdir}/profile.d/*
+%config %{_sysconfdir}/udev/rules.d/*
%files config
%manifest %{name}.manifest
diff --git a/weston-user.service b/weston-user.service
new file mode 100644
index 0000000..2fceb86
--- /dev/null
+++ b/weston-user.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Shared weston session
+
+[Service]
+ExecStart=/usr/bin/ln -s /run/display/wayland-0 /run/user/%U/
+
+[Install]
+WantedBy=default.target
diff --git a/weston.service b/weston.service
deleted file mode 100644
index 3f7e56a..0000000
--- a/weston.service
+++ /dev/null
@@ -1,11 +0,0 @@
-[Unit]
-Description=Weston
-Requires=dbus.socket
-
-[Service]
-ExecStart=/usr/bin/weston-launch -- -i0
-StandardInput=tty
-TTYPath=/dev/tty1
-
-[Install]
-WantedBy=weston.target
diff --git a/weston.sh b/weston.sh
index 6ef0db1..37c1831 100644
--- a/weston.sh
+++ b/weston.sh
@@ -8,4 +8,10 @@ export ECORE_IMF_MODULE=wayland
# also export dbus session address for dbus clients (details on bug TIVI-1686 [https://bugs.tizen.org/jira/browse/TIVI-1686])
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID/dbus/user_bus_socket
+# workaround systemd bug in pam_systemd module
+if [ "$USER" == "display" ]; then
+ export XDG_RUNTIME_DIR=/run/display
+else
+ export XDG_RUNTIME_DIR=/run/user/$UID
+fi
diff --git a/weston.sysconfig b/weston.sysconfig
new file mode 100644
index 0000000..9fc91b2
--- /dev/null
+++ b/weston.sysconfig
@@ -0,0 +1,2 @@
+# path to display manager runtime dir
+XDG_RUNTIME_DIR=/run/display
diff --git a/weston_tmpfiles.conf b/weston_tmpfiles.conf
new file mode 100644
index 0000000..cbe80e8
--- /dev/null
+++ b/weston_tmpfiles.conf
@@ -0,0 +1,5 @@
+# This file is distributed to create weston XDG_RUNTIME_DIR (/run/display)
+#
+# See tmpfiles.d(5) for details
+
+d /run/display 0770 display display -