Fix the spec file for RPMs

Looked up the actual code for the macros being replaced
Made sure we're doing the proper if statements
Cleaned up the tests a little
This commit is contained in:
Shane Lee 2024-02-12 15:00:45 -07:00 committed by Daniel Wozniak
parent 0917a5abf7
commit 0021cb870d
2 changed files with 49 additions and 19 deletions

View file

@ -437,20 +437,28 @@ find /etc/salt /opt/saltstack/salt /var/log/salt /var/cache/salt /var/run/salt \
%preun master
# RHEL 9 is giving warning msg if syndic is not installed, supress it
# %systemd_preun salt-syndic.service > /dev/null 2>&1
systemctl --no-reload disable salt-syndic.service > /dev/null 2>&1 || :
systemctl stop salt-syndic.service > /dev/null 2>&1 || :
if [ $1 -eq 0 ] ; then
# Package removal, not upgrade
systemctl --no-reload disable salt-syndic.service > /dev/null 2>&1 || :
systemctl stop salt-syndic.service > /dev/null 2>&1 || :
fi
%preun minion
# %systemd_preun salt-minion.service
systemctl --no-reload disable salt-minion.service > /dev/null 2>&1 || :
systemctl stop salt-minion.service > /dev/null 2>&1 || :
if [ $1 -eq 0 ] ; then
# Package removal, not upgrade
systemctl --no-reload disable salt-minion.service > /dev/null 2>&1 || :
systemctl stop salt-minion.service > /dev/null 2>&1 || :
fi
%preun api
# %systemd_preun salt-api.service
systemctl --no-reload disable salt-api.service > /dev/null 2>&1 || :
systemctl stop salt-api.service > /dev/null 2>&1 || :
if [ $1 -eq 0 ] ; then
# Package removal, not upgrade
systemctl --no-reload disable salt-api.service > /dev/null 2>&1 || :
systemctl stop salt-api.service > /dev/null 2>&1 || :
fi
%post
@ -465,7 +473,10 @@ ln -s -f /opt/saltstack/salt/salt-cloud %{_bindir}/salt-cloud
%post master
# %systemd_post salt-master.service
systemctl preset salt-master.service >/dev/null 2>&1 || :
if [ $1 -eq 1 ] ; then
# Initial installation
systemctl preset salt-master.service >/dev/null 2>&1 || :
fi
ln -s -f /opt/saltstack/salt/salt %{_bindir}/salt
ln -s -f /opt/saltstack/salt/salt-cp %{_bindir}/salt-cp
ln -s -f /opt/saltstack/salt/salt-key %{_bindir}/salt-key
@ -487,12 +498,18 @@ fi
%post syndic
# %systemd_post salt-syndic.service
systemctl preset salt-syndic.service >/dev/null 2>&1 || :
if [ $1 -eq 1 ] ; then
# Initial installation
systemctl preset salt-syndic.service >/dev/null 2>&1 || :
fi
ln -s -f /opt/saltstack/salt/salt-syndic %{_bindir}/salt-syndic
%post minion
# %systemd_post salt-minion.service
systemctl preset salt-minion.service >/dev/null 2>&1 || :
if [ $1 -eq 1 ] ; then
# Initial installation
systemctl preset salt-minion.service >/dev/null 2>&1 || :
fi
ln -s -f /opt/saltstack/salt/salt-minion %{_bindir}/salt-minion
ln -s -f /opt/saltstack/salt/salt-call %{_bindir}/salt-call
ln -s -f /opt/saltstack/salt/salt-proxy %{_bindir}/salt-proxy
@ -515,7 +532,10 @@ ln -s -f /opt/saltstack/salt/salt-ssh %{_bindir}/salt-ssh
%post api
# %systemd_post salt-api.service
systemctl preset salt-api.service >/dev/null 2>&1 || :
if [ $1 -eq 1 ] ; then
# Initial installation
systemctl preset salt-api.service >/dev/null 2>&1 || :
fi
ln -s -f /opt/saltstack/salt/salt-api %{_bindir}/salt-api
@ -558,7 +578,10 @@ fi
%postun master
# %systemd_postun_with_restart salt-master.service
systemctl daemon-reload >/dev/null 2>&1 || :
systemctl try-restart salt-master.service >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
# Package upgrade, not uninstall
systemctl try-restart salt-master.service >/dev/null 2>&1 || :
fi
if [ $1 -eq 0 ]; then
if [ $(cat /etc/os-release | grep VERSION_ID | cut -d '=' -f 2 | sed 's/\"//g' | cut -d '.' -f 1) = "8" ]; then
if [ -z "$(rpm -qi salt-minion | grep Name | grep salt-minion)" ]; then
@ -576,12 +599,18 @@ fi
%postun syndic
# %systemd_postun_with_restart salt-syndic.service
systemctl daemon-reload >/dev/null 2>&1 || :
systemctl try-restart salt-syndic.service >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
# Package upgrade, not uninstall
systemctl try-restart salt-syndic.service >/dev/null 2>&1 || :
fi
%postun minion
# %systemd_postun_with_restart salt-minion.service
systemctl daemon-reload >/dev/null 2>&1 || :
systemctl try-restart salt-minion.service >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
# Package upgrade, not uninstall
systemctl try-restart salt-minion.service >/dev/null 2>&1 || :
fi
if [ $1 -eq 0 ]; then
if [ $(cat /etc/os-release | grep VERSION_ID | cut -d '=' -f 2 | sed 's/\"//g' | cut -d '.' -f 1) = "8" ]; then
if [ -z "$(rpm -qi salt-master | grep Name | grep salt-master)" ]; then
@ -599,7 +628,10 @@ fi
%postun api
# %systemd_postun_with_restart salt-api.service
systemctl daemon-reload >/dev/null 2>&1 || :
systemctl try-restart salt-api.service >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
# Package upgrade, not uninstall
systemctl try-restart salt-api.service >/dev/null 2>&1 || :
fi
%changelog
* Fri Jan 26 2024 Salt Project Packaging <saltproject-packaging@vmware.com> - 3006.6

View file

@ -7,15 +7,14 @@ def test_services(install_salt, salt_cli, salt_minion):
"""
Check if Services are enabled/disabled
"""
services_disabled = []
services_enabled = []
if install_salt.distro_id in ("ubuntu", "debian"):
services_enabled = ["salt-master", "salt-minion", "salt-syndic", "salt-api"]
services_disabled = []
elif install_salt.distro_id in ("centos", "redhat", "amzn", "fedora"):
services_enabled = []
services_disabled = ["salt-master", "salt-minion", "salt-syndic", "salt-api"]
elif install_salt.distro_id == "photon":
if float(install_salt.distro_version) < 5:
services_enabled = []
services_disabled = [
"salt-master",
"salt-minion",
@ -24,7 +23,6 @@ def test_services(install_salt, salt_cli, salt_minion):
]
else:
services_enabled = ["salt-master", "salt-minion", "salt-syndic", "salt-api"]
services_disabled = []
elif platform.is_darwin():
services_enabled = ["salt-minion"]
services_disabled = []