diff --git a/macros.systemd b/macros.systemd index 3d756b5..7a4bfb9 100644 --- a/macros.systemd +++ b/macros.systemd @@ -101,7 +101,7 @@ if [ -x /usr/bin/systemctl ]; then \ for service in %{?*} ; do \ if [ -e "/run/systemd/rpm/needs-preset/$service" ]; then \ /usr/bin/systemctl preset "$service" || : \ - rm -f /run/systemd/rpm/needs-preset/$service \ + rm "/run/systemd/rpm/needs-preset/$service" || : \ else \ /usr/lib/systemd/systemd-sysv-convert --apply %{?*} || : \ fi \ @@ -172,7 +172,27 @@ fi \ %systemd_postun() %{expand::%%service_del_postun_without_restart %{?**}} %systemd_postun_with_restart() %{expand::%%service_del_postun %{?**}} -%systemd_user_post() %{expand:%systemd_post \\--global %%{?*}} +%systemd_user_pre() \ +if [ -x /usr/bin/systemctl ]; then \ + for service in %{?*} ; do \ + if [ ! -e "/usr/lib/systemd/user/$service" ]; then \ + mkdir -p /run/systemd/rpm/needs-user-preset \ + touch "/run/systemd/rpm/needs-user-preset/$service" \ + fi \ + done \ +fi \ +%{nil} + +%systemd_user_post() \ +if [ -x /usr/bin/systemctl ]; then \ + for service in %{?*} ; do \ + if [ -e "/run/systemd/rpm/needs-user-preset/$service" ]; then \ + /usr/bin/systemctl --global preset "$service" || : \ + rm "/run/systemd/rpm/needs-user-preset/$service" || : \ + fi \ + done \ +fi \ +%{nil} %systemd_user_preun() \ if [ $1 -eq 0 -a -x /usr/bin/systemctl ]; then \ diff --git a/systemd-rpm-macros.changes b/systemd-rpm-macros.changes index 5019101..a4fb85c 100644 --- a/systemd-rpm-macros.changes +++ b/systemd-rpm-macros.changes @@ -1,3 +1,31 @@ +------------------------------------------------------------------- +Fri Mar 5 12:27:14 UTC 2021 - Franck Bui + +- Bump to version 11 + +------------------------------------------------------------------- +Fri Mar 5 11:10:16 UTC 2021 - Antonio Larrosa + +- Don't pass -f to rm in %service_add_post nor %systemd_user_post + +------------------------------------------------------------------- +Fri Mar 5 11:03:49 UTC 2021 - Antonio Larrosa + +- Add a %systemd_user_pre macro that creates a + /run/systemd/rpm/needs-user-preset/$service file for each new + service being installed so %systemd_user_post can call + `systemctl --global preset $service` properly for newly + installed user services (boo#1183051, boo#1183012). + +------------------------------------------------------------------- +Thu Mar 4 13:11:15 UTC 2021 - Antonio Larrosa + +- Fix %systemd_user_post. The --global parameter was handled as if + it was another service name so %systemd_user_post wasn't working + properly. Replace %systemd_user_post with the code from + %service_add_post it was being expanded to but correctly passing + --global to systemctl (boo#1183051, boo#1182661). + ------------------------------------------------------------------- Fri Feb 12 11:46:17 UTC 2021 - Franck Bui diff --git a/systemd-rpm-macros.spec b/systemd-rpm-macros.spec index a20a604..13f3195 100644 --- a/systemd-rpm-macros.spec +++ b/systemd-rpm-macros.spec @@ -17,7 +17,7 @@ Name: systemd-rpm-macros -Version: 10 +Version: 11 Release: 0 Summary: RPM macros for systemd License: LGPL-2.1-or-later