From 9f811ff92167ce6465f2b2d9e90594c181faf057 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Oct 11 2024 14:07:39 +0000 Subject: Run commands in %posttrans script unconditionally Because https://github.com/rpm-software-management/rpm/commit/3848c97cb227e7c018781aa7d5e1e46990ce1ffb is not in c9s, we can't detect upgrades in %posttrans. Luckily, the stuff we run in %posttrans is a noop in chroots and we never expect to install systemd on a live system in the first place so this shouldn't be a problem. Even if systemd was installed on a live system, all errors from commands in scriptlets are ignored so at worst there will be some errors but nothing that will actually prevent installation of the rpm. --- diff --git a/systemd.spec b/systemd.spec index 9b38272..8fd4327 100644 --- a/systemd.spec +++ b/systemd.spec @@ -1062,11 +1062,12 @@ meson test -C %{_vpath_builddir} -t 6 --print-errorlogs %include %{SOURCE1} # This macro is newly added upstream so we can't rely on it being always being available -# in the systemd-rpm-macros yet so we define it ourselves. +# in the systemd-rpm-macros yet so we define it ourselves. Also, we can't detect upgrades +# on c9s because https://github.com/rpm-software-management/rpm/commit/3848c97cb227e7c018781aa7d5e1e46990ce1ffb +# is not in c9s so we remove the upgrade check and unconditionally try to restart the units. %global systemd_posttrans_with_restart() \ %{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# systemd_posttrans_with_restart}} \ -if [ $1 -ge 2 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then \ - # Package upgrade, not install \ +if [ -x "/usr/lib/systemd/systemd-update-helper" ]; then \ /usr/lib/systemd/systemd-update-helper mark-restart-system-units %* || : \ fi \ %{nil} @@ -1095,13 +1096,13 @@ systemctl preset-all &>/dev/null || : systemctl --global preset-all &>/dev/null || : %posttrans -if [ $1 -ge 1 ]; then - [ -w %{_localstatedir} ] && journalctl --update-catalog || : +# We can't check for upgrades on c9s as https://github.com/rpm-software-management/rpm/commit/3848c97cb227e7c018781aa7d5e1e46990ce1ffb +# is missing so we run this stuff unconditionally on installs and upgrades. +[ -w %{_localstatedir} ] && journalctl --update-catalog || : - systemctl daemon-reexec || : +systemctl daemon-reexec || : - systemd-tmpfiles --create &>/dev/null || : -fi +systemd-tmpfiles --create &>/dev/null || : # systemd-logind restart is disabled because of DRM fds getting closed which breaks # graphical sessions. However, every release we encounter breakage because something @@ -1117,8 +1118,7 @@ fi # This is the expanded form of %%systemd_user_daemon_reexec. We # can't use the macro because we define it ourselves. -if [ $1 -ge 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then - # Package upgrade, not uninstall +if [ -x "/usr/lib/systemd/systemd-update-helper" ]; then /usr/lib/systemd/systemd-update-helper user-reexec || : fi