packaging: Align alternatives setup with fedora-recommended scheme 95/246195/3 accepted/tizen/unified/20201106.130134 submit/tizen/20201103.015640 submit/tizen/20201104.011652
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Mon, 26 Oct 2020 14:37:15 +0000 (15:37 +0100)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Tue, 3 Nov 2020 02:19:45 +0000 (02:19 +0000)
Change-Id: I5ff9241180d32fb936a19dadfea9fa7d174a1dee

packaging/systemd.spec

index 13a6328..78ee2ad 100644 (file)
@@ -442,11 +442,24 @@ chsmack %{_prefix}/lib/systemd/* -a "System::Tools"
 chsmack %{_bindir}/systemd-detect-virt -a "System::Tools"
 %endif
 
+update-alternatives --install %{_prefix}/lib/systemd/systemd-shutdown systemd-shutdown %{_prefix}/lib/systemd/systemd-shutdown-original 100 || :
+update-alternatives --install %{_sbindir}/reboot reboot %{_sbindir}/reboot-original 100 || :
+update-alternatives --install %{_sbindir}/halt halt %{_sbindir}/halt-original 100 || :
+update-alternatives --install %{_sbindir}/poweroff poweroff %{_sbindir}/poweroff-original 100 || :
+update-alternatives --install %{_sbindir}/shutdown shutdown %{_sbindir}/shutdown-original 100 || :
+
 %postun
 if [ $1 -ge 1 ] ; then
        /usr/bin/systemctl daemon-reload > /dev/null 2>&1 || :
        /usr/bin/systemctl try-restart systemd-logind.service >/dev/null 2>&1 || :
 fi
+if [$1 -eq 0 ] ; then
+       update-alternatives --remove systemd-shutdown %{_prefix}/lib/systemd/systemd-shutdown-original
+       update-alternatives --remove reboot %{_sbindir}/reboot-original
+       update-alternatives --remove halt %{_sbindir}/halt-original
+       update-alternatives --remove poweroff %{_sbindir}/poweroff-original
+       update-alternatives --remove shutdown %{_sbindir}/shutdown-original
+fi
 
 %preun
 if [ $1 -eq 0 ] ; then
@@ -455,26 +468,6 @@ if [ $1 -eq 0 ] ; then
                remote-fs.target \
                systemd-readahead-replay.service \
                systemd-readahead-collect.service >/dev/null 2>&1 || :
-
-       update-alternatives --remove systemd-shutdown %{_prefix}/lib/systemd/systemd-shutdown-original
-       update-alternatives --remove reboot %{_sbindir}/reboot-original
-       update-alternatives --remove halt %{_sbindir}/halt-original
-       update-alternatives --remove poweroff %{_sbindir}/poweroff-original
-       update-alternatives --remove shutdown %{_sbindir}/shutdown-original
-fi
-
-%posttrans
-# Update alternatives after the whole transaction is completed - this is
-# necessary due to RPM ordering, which removes files from old package not
-# provided by new package after regular post scripts are run.  Please refer
-# to following guideliness for explanation:
-#   https://fedoraproject.org/wiki/Packaging:Scriptlets#Ordering
-if [ $1 -eq 0 ]; then
-       update-alternatives --install %{_prefix}/lib/systemd/systemd-shutdown systemd-shutdown %{_prefix}/lib/systemd/systemd-shutdown-original 100 || :
-       update-alternatives --install %{_sbindir}/reboot reboot %{_sbindir}/reboot-original 100 || :
-       update-alternatives --install %{_sbindir}/halt halt %{_sbindir}/halt-original 100 || :
-       update-alternatives --install %{_sbindir}/poweroff poweroff %{_sbindir}/poweroff-original 100 || :
-       update-alternatives --install %{_sbindir}/shutdown shutdown %{_sbindir}/shutdown-original 100 || :
 fi
 
 %post -n libsystemd -p /sbin/ldconfig