From 896fb4a918e533dbc97b12c0ca5ae120727072b5 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Wed, 23 May 2018 12:14:34 +0200 Subject: [PATCH] dbus: make use of [Install] unit sections Rather than installing symlinks during the installation manually, put in [Install] sections into the units. This has the same effect, but allows changing the installation conditions via systemd-presets, which are provided by the 'fedora-release' package. Signed-off-by: David Herrmann --- dbus-daemon.service | 4 ++++ dbus-daemon.user.service | 3 +++ dbus.socket | 3 +++ dbus.spec | 23 +++++++++-------------- dbus.user.socket | 3 +++ 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/dbus-daemon.service b/dbus-daemon.service index 7a1df87..c63456e 100644 --- a/dbus-daemon.service +++ b/dbus-daemon.service @@ -7,3 +7,7 @@ Requires=dbus.socket ExecStart=/usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only ExecReload=/usr/bin/dbus-send --print-reply --system --type=method_call --dest=org.freedesktop.DBus / org.freedesktop.DBus.ReloadConfig OOMScoreAdjust=-900 + +[Install] +Alias=dbus.service +WantedBy=multi-user.target diff --git a/dbus-daemon.user.service b/dbus-daemon.user.service index ce7cabf..2d96f62 100644 --- a/dbus-daemon.user.service +++ b/dbus-daemon.user.service @@ -6,3 +6,6 @@ Requires=dbus.socket [Service] ExecStart=/usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only ExecReload=/usr/bin/dbus-send --print-reply --session --type=method_call --dest=org.freedesktop.DBus / org.freedesktop.DBus.ReloadConfig + +[Install] +Alias=dbus.service diff --git a/dbus.socket b/dbus.socket index 5c373cf..e1e4a65 100644 --- a/dbus.socket +++ b/dbus.socket @@ -3,3 +3,6 @@ Description=D-Bus System Message Bus Socket [Socket] ListenStream=/run/dbus/system_bus_socket + +[Install] +WantedBy=sockets.target diff --git a/dbus.spec b/dbus.spec index 4b2e139..3f87012 100644 --- a/dbus.spec +++ b/dbus.spec @@ -5,6 +5,9 @@ %global libselinux_version 2.0.86 +# fedora-release-30-0.2 added required presets to enable systemd-unit symlinks +%global system_release_version 30-0.2 + %global dbus_user_uid 81 %global dbus_common_config_opts --enable-libaudit --enable-selinux=yes --with-system-socket=/run/dbus/system_bus_socket --with-dbus-user=dbus --libexecdir=/%{_libexecdir}/dbus-1 --enable-user-session --docdir=%{_pkgdocdir} --enable-installed-tests @@ -84,6 +87,7 @@ Summary: D-BUS message bus configuration Group: System Environment/Libraries BuildArch: noarch Requires(pre): /usr/sbin/useradd +Requires: system-release >= %{system_release_version} %description common The %{name}-common package provides the configuration and setup files for D-Bus @@ -220,15 +224,6 @@ install -Dp -m644 %{SOURCE3} %{buildroot}%{_unitdir}/dbus-daemon.service install -Dp -m644 %{SOURCE4} %{buildroot}%{_userunitdir}/dbus.socket install -Dp -m644 %{SOURCE5} %{buildroot}%{_userunitdir}/dbus-daemon.service -# dbus-daemon is the default D-Bus implementation on Fedora -ln -f -s dbus-daemon.service %{buildroot}%{_unitdir}/dbus.service -ln -f -s dbus-daemon.service %{buildroot}%{_userunitdir}/dbus.service - -# D-Bus is unconditionally enabled on all systems -ln -f -s ../dbus.service %{buildroot}%{_unitdir}/multi-user.target.wants/dbus.service -ln -f -s ../dbus.socket %{buildroot}%{_unitdir}/sockets.target.wants/dbus.socket -ln -f -s ../dbus.socket %{buildroot}%{_userunitdir}/sockets.target.wants/dbus.socket - # Make sure that when somebody asks for D-Bus under the name of the # old SysV script, that he ends up with the standard dbus.service name # now. @@ -383,15 +378,10 @@ popd %exclude %{_libexecdir}/dbus-1/dbus-run-installed-tests %{_tmpfilesdir}/dbus.conf %{_unitdir}/dbus-daemon.service -%{_unitdir}/dbus.service %{_unitdir}/dbus.socket %{_unitdir}/messagebus.service -%{_unitdir}/multi-user.target.wants/dbus.service -%{_unitdir}/sockets.target.wants/dbus.socket %{_userunitdir}/dbus-daemon.service -%{_userunitdir}/dbus.service %{_userunitdir}/dbus.socket -%{_userunitdir}/sockets.target.wants/dbus.socket %files tools %{!?_licensedir:%global license %%doc} @@ -442,6 +432,11 @@ popd %changelog +* Fri Aug 10 2018 David Herrmann - 1:1.12.10-1 +- Add [Install] sections to unit files, rather than creating the symlinks + manually during the installation. This will pick up the systemd-presets + global to Fedora from the 'fedora-release' package. + * Fri Aug 10 2018 David Herrmann - 1:1.12.10-1 - Provide custom systemd unit files to replace the upstream units. Also rename the service to 'dbus-daemon.service', but provide an alias to 'dbus.service'. diff --git a/dbus.user.socket b/dbus.user.socket index dc5ed89..ad38e34 100644 --- a/dbus.user.socket +++ b/dbus.user.socket @@ -4,3 +4,6 @@ Description=D-Bus User Message Bus Socket [Socket] ListenStream=%t/bus ExecStartPost=-/usr/bin/systemctl --user set-environment DBUS_SESSION_BUS_ADDRESS=unix:path=%t/bus + +[Install] +WantedBy=sockets.target