diff --git a/macros.systemd b/macros.systemd index 6c3c760..dc94356 100644 --- a/macros.systemd +++ b/macros.systemd @@ -172,10 +172,24 @@ fi \ %systemd_postun() %{expand::%%service_del_postun_without_restart %{?**}} %systemd_postun_with_restart() %{expand::%%service_del_postun %{?**}} -%systemd_user_post() \ -if [ -x /usr/bin/systemctl ] && [ $1 -eq 1 ]; then \ +%systemd_user_pre() \ +if [ -x /usr/bin/systemctl ]; then \ for service in %{?*} ; do \ - /usr/bin/systemctl --global preset "$service" || : \ + 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 -f /run/systemd/rpm/needs-user-preset/$service \ + fi \ done \ fi \ %{nil} diff --git a/systemd-rpm-macros.changes b/systemd-rpm-macros.changes index 7c947f0..4b12242 100644 --- a/systemd-rpm-macros.changes +++ b/systemd-rpm-macros.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +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