Clean up only after package removal, not during upgrades.
[cascardo/ipsilon.git] / contrib / fedora / ipsilon.spec
index 79922d9..73b1aca 100644 (file)
@@ -20,6 +20,8 @@ Requires:       python-jinja2
 Requires:       python-lxml
 Requires:       python-pam
 Requires(pre):  shadow-utils
+Requires(post): %_sbindir/semanage, %_sbindir/restorecon
+Requires(postun): %_sbindir/semanage
 
 %description
 Ipsilon is a multi-protocol Identiy Provider service. Its function is to
@@ -65,13 +67,16 @@ getent passwd ipsilon >/dev/null || \
 exit 0
 
 %post
-semanage fcontext -a -t httpd_var_lib_t '%{_sharedstatedir}/ipsilon(/.*)?' 2>/dev/null || :
-semanage fcontext -a -t var_lib_t '%{_sharedstatedir}/ipsilon(/.*)/*.conf' 2>/dev/null || :
+semanage fcontext -a -t httpd_var_lib_t '%{_sharedstatedir}/ipsilon(/.*)?' || :
+semanage fcontext -a -t var_lib_t '%{_sharedstatedir}/ipsilon(/.*)/*.conf' || :
 restorecon -R %{_sharedstatedir}/ipsilon || :
 
 %postun
-semanage fcontext -d -t var_lib_t '%{_sharedstatedir}/ipsilon(/.*)/*.conf' 2>/dev/null || :
-semanage fcontext -d -t httpd_var_lib_t '%{_sharedstatedir}/ipsilon(/.*)?' 2>/dev/null || :
+# Clean up after package removal
+if [ $1 -eq 0 ]; then
+    semanage fcontext -d -t var_lib_t '%{_sharedstatedir}/ipsilon(/.*)/*.conf' || :
+    semanage fcontext -d -t httpd_var_lib_t '%{_sharedstatedir}/ipsilon(/.*)?' || :
+fi
 
 %files
 %{_defaultdocdir}/%{name}-%{version}