Proper %post and %postun scripts in spec file
authorMariusz Domanski <m.domanski@samsung.com>
Wed, 20 Feb 2013 14:43:36 +0000 (15:43 +0100)
committerMariusz Domanski <m.domanski@samsung.com>
Wed, 20 Feb 2013 16:07:23 +0000 (17:07 +0100)
[Issue#]   N/A
[Bug]      errors when upgrading rpm package via rpm -U command
[Cause]    bugged %post and %postun scripts in spec file
[Solution] fixed %post and %postun scripts to handle upgrades properly

[Verification] Build and install rpm files, then increment version
               number in spec file and build and install with rpm -U.
               No security-server related errors should appear after
               second installation, S10security-server symlinks in
               /etc/rc.d/rc3.d/ and /etc/rc.d/rc5.d/ should exist.
               After package uninstallation symlinks should be gone.

Change-Id: I5f0ec6e640f14c12335de0338d3e75d883d1a79e

packaging/security-server.spec

index 07684c3..224ff5b 100644 (file)
@@ -121,13 +121,15 @@ if [ $1 == 1 ]; then
 fi
 mkdir -p /etc/rc.d/rc3.d
 mkdir -p /etc/rc.d/rc5.d
-ln -s /etc/rc.d/init.d/security-serverd /etc/rc.d/rc3.d/S10security-server
-ln -s /etc/rc.d/init.d/security-serverd /etc/rc.d/rc5.d/S10security-server
+ln -sf /etc/rc.d/init.d/security-serverd /etc/rc.d/rc3.d/S10security-server
+ln -sf /etc/rc.d/init.d/security-serverd /etc/rc.d/rc5.d/S10security-server
 
 %postun
 systemctl daemon-reload
-rm -f /etc/rc.d/rc3.d/S10security-server
-rm -f /etc/rc.d/rc5.d/S10security-server
+if [ "$1" = 0 ]; then
+    rm -f /etc/rc.d/rc3.d/S10security-server
+    rm -f /etc/rc.d/rc5.d/S10security-server
+fi
 
 %post -n libsecurity-server-client -p /sbin/ldconfig