1616#
1717%global debug_package %{nil }
1818
19+ %if 0%{?suse_version } > 1500
20+ %bcond_without libalternatives
21+ %else
22+ %bcond_with libalternatives
23+ %endif
24+ %if 0%{?sle_version } >= 150400
25+ %define _alternatives 1
26+ %endif
27+
1928%global flavor @BUILD_FLAVOR@%{nil }
2029%if "%{flavor }" == "testsuite"
2130%define psuffix -test
4251
4352%{?sle15allpythons }
4453%define skip_python2 1
54+ %if 0%{?rhel } == 8 || (0%{?suse_version } == 1500 && 0%{?sle_version } < 150400)
55+ %define __python3_bin_suffix 3.6
56+ %if 0%{?rhel } == 8
57+ %define __python3 /usr/libexec/platform-python
58+ %else
59+ %define __python3 /usr/bin/python3
60+ %endif
61+ %define python_module() python3-%**
62+ %define python_files() -n python3-%1
63+ %define python_subpackages %{nil }
64+ %define python_sitelib %python3_sitelib
65+ %define python_expand(+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-= ) %{lua: \
66+ local args = rpm.expand("%**")\
67+ local python_bin = rpm.expand("%__python3")\
68+ local python_bin_suffix = rpm.expand("%__python3_bin_suffix")\
69+ args = args:gsub("$python_bin_suffix", python_bin_suffix)\
70+ args = args:gsub("$python_sitelib", "python3_sitelib")\
71+ args = args:gsub("$python", python_bin)\
72+ print(rpm.expand(args .. "\\n"))\
73+ }
74+ %define _nosinglespec 1
75+ %endif
4576Name: salt%{psuffix }
4677Version: 3006.0
4778Release: 0
@@ -469,7 +500,11 @@ BuildRequires: logrotate
469500BuildRequires: fdupes
470501%endif
471502
472- Requires: python-%{name } = %{version }-%{release }
503+ %if 0%{?_alternatives }
504+ Requires: %{name }-call = %{version }-%{release }
505+ %else
506+ Requires: python3-%{name } = %{version }-%{release }
507+ %endif
473508Obsoletes: python2-%{name }
474509
475510Requires(pre): %{_sbindir }/groupadd
@@ -544,7 +579,11 @@ servers, handle them quickly and through a simple and manageable interface.
544579
545580%if "%{flavor }" != "testsuite"
546581
582+ %if 0%{?_nosinglespec }
583+ %package -n python3-salt
584+ %else
547585%package -n python-salt
586+ %endif
548587Summary: python3 library for salt
549588Group: System/Management
550589Requires: %{name } = %{version }-%{release }
@@ -554,7 +593,6 @@ BuildRequires: platform-python
554593%else
555594BuildRequires: %{python_module base}
556595%endif
557- BuildRequires: %{python_module devel}
558596BuildRequires: %{python_module setuptools}
559597# requirements/base.txt
560598%if 0%{?rhel } || 0%{?fedora }
@@ -598,8 +636,23 @@ BuildRequires: %{python_module sphinx}
598636%if 0%{?rhel } == 8
599637Requires: platform-python
600638%else
639+ %if 0%{?_nosinglespec }
640+ Requires: %{python_module base}
641+ %else
601642Requires: python-base
602643%endif
644+ %endif
645+
646+ %if 0%{?_alternatives }
647+ %if %{with libalternatives }
648+ Requires: alts
649+ BuildRequires: alts
650+ %else
651+ Requires(post): update-alternatives
652+ Requires(postun): update-alternatives
653+ %endif
654+ %endif
655+
603656# requirements/base.txt
604657%if 0%{?rhel } || 0%{?fedora }
605658Requires: python3-jinja2
@@ -616,6 +669,17 @@ Requires: dnf
616669Requires: yum-plugin-security
617670%endif
618671%else # SUSE
672+ %if 0%{?_nosinglespec }
673+ Requires: %{python_module Jinja2}
674+ Requires: %{python_module MarkupSafe}
675+ Requires: %{python_module msgpack-python > 0.3}
676+ %if 0%{?suse_version } >= 1500
677+ Requires: %{python_module M2Crypto}
678+ %else
679+ Requires: %{python_module pycrypto >= 2.6.1}
680+ %endif
681+ Requires: %{python_module pyzmq >= 2.2.0}
682+ %else
619683Requires: python-Jinja2
620684Requires: python-MarkupSafe
621685Requires: python-msgpack-python > 0.3
@@ -625,8 +689,27 @@ Requires: python-M2Crypto
625689Requires: python-pycrypto >= 2.6.1
626690%endif
627691Requires: python-pyzmq >= 2.2.0
692+ %endif
628693%endif # end of RHEL / SUSE specific section
629- Requires: python-jmespath
694+ %if 0%{?_nosinglespec }
695+ Recommends: %{python_module jmespath}
696+ Requires: %{python_module PyYAML}
697+ Requires: %{python_module psutil}
698+ Requires: %{python_module requests >= 1.0.0}
699+ Requires: %{python_module distro}
700+ Requires: %{python_module looseversion}
701+ Requires: %{python_module packaging}
702+ Requires: %{python_module contextvars}
703+ %if 0%{?suse_version }
704+ # required for zypper.py
705+ Requires: %{python_module rpm}
706+ # requirements/opt.txt (not all)
707+ # Suggests: python-MySQL-python ## Disabled for now, originally Recommended
708+ Suggests: %{python_module timelib}
709+ Suggests: %{python_module gnupg}
710+ %endif
711+ %else
712+ Recommends: python-jmespath
630713Requires: python-PyYAML
631714Requires: python-psutil
632715Requires: python-requests >= 1.0.0
@@ -637,22 +720,28 @@ Requires: python-contextvars
637720%if 0%{?suse_version }
638721# required for zypper.py
639722Requires: python-rpm
640- Requires(pre): libzypp(plugin:system) >= 0
641- Requires: python-zypp-plugin
642723# requirements/opt.txt (not all)
643724# Suggests: python-MySQL-python ## Disabled for now, originally Recommended
644725Suggests: python-timelib
645726Suggests: python-gnupg
646727# requirements/zeromq.txt
647728%endif
729+ %endif
648730#
649731%if 0%{?suse_version }
650732# python-xml is part of python-base in all rhel versions
733+ %if 0%{?_nosinglespec }
734+ Requires: %{python_module xml}
735+ Suggests: %{python_module Mako}
736+ Recommends: %{python_module netaddr}
737+ Recommends: %{python_module pyinotify}
738+ %else
651739Requires: python-xml
652740Suggests: python-Mako
653741Recommends: python-netaddr
654742Recommends: python-pyinotify
655743%endif
744+ %endif
656745
657746# Required by Salt modules
658747Requires: iputils
@@ -661,9 +750,19 @@ Requires: file
661750Recommends: man
662751Recommends: python3-passlib
663752
753+ %if 0%{?_nosinglespec }
754+ Provides: bundled(%{python_module tornado}) = 4.5.3
755+ %else
664756Provides: bundled(python-tornado) = 4.5.3
757+ %endif
758+
759+ Provides: %{name }-call = %{version }-%{release }
665760
761+ %if 0%{?_nosinglespec }
762+ %description -n python3-salt
763+ %else
666764%description -n python-salt
765+ %endif
667766Python3 specific files for salt
668767
669768%package api
@@ -672,9 +771,9 @@ Group: System/Management
672771Requires: %{name } = %{version }-%{release }
673772Requires: %{name }-master = %{version }-%{release }
674773%if 0%{?suse_version }
675- Requires: python -CherryPy >= 3.2.2
774+ Requires: python3 -CherryPy >= 3.2.2
676775%else
677- Requires: python -cherrypy >= 3.2.2
776+ Requires: python3 -cherrypy >= 3.2.2
678777%endif
679778
680779%description api
@@ -685,10 +784,10 @@ Summary: Generic cloud provisioning tool for Saltstack
685784Group: System/Management
686785Requires: %{name } = %{version }-%{release }
687786Requires: %{name }-master = %{version }-%{release }
688- Requires: python -apache-libcloud
787+ Requires: python3 -apache-libcloud
689788%if 0%{?suse_version }
690- Recommends: python -botocore
691- Recommends: python -netaddr
789+ Recommends: python3 -botocore
790+ Recommends: python3 -netaddr
692791%endif
693792
694793%description cloud
@@ -711,7 +810,7 @@ Summary: The management component of Saltstack with zmq protocol supporte
711810Group: System/Management
712811Requires: %{name } = %{version }-%{release }
713812%if 0%{?suse_version }
714- Recommends: python -pygit2 >= 0.20.3
813+ Recommends: python3 -pygit2 >= 0.20.3
715814%endif
716815%ifarch %{ix86 } x86_64
717816%if 0%{?suse_version }
@@ -746,6 +845,10 @@ Requires: %{name} = %{version}-%{release}
746845%if 0%{?suse_version } > 1500 || 0%{?sle_version } > 150000
747846Requires: (%{name }-transactional-update = %{version }-%{release } if read-only-root-fs)
748847%endif
848+ %if 0%{?suse_version }
849+ Requires: python3-zypp-plugin
850+ Requires(pre): libzypp(plugin:system) >= 0
851+ %endif
749852
750853%if %{with systemd }
751854%{?systemd_requires }
@@ -899,18 +1002,42 @@ list of active executors. This package add the configuration file.
8991002
9001003%if "%{flavor }" == "testsuite"
9011004
1005+ %if 0%{?_nosinglespec }
1006+ %package -n %{python_module salt-testsuite}
1007+ %else
9021008%package -n python-salt-testsuite
1009+ %endif
9031010Summary: Unit and integration tests for Salt
9041011
9051012%if 0%{?rhel } == 8
9061013BuildRequires: platform-python
9071014%else
9081015BuildRequires: %{python_module base}
9091016%endif
910- BuildRequires: %{python_module devel}
9111017BuildRequires: %{python_module setuptools}
9121018
9131019Requires: salt = %{version }
1020+ %if 0%{?_nosinglespec }
1021+ Recommends: %{python_module CherryPy}
1022+ Requires: %{python_module Genshi}
1023+ Requires: %{python_module Mako}
1024+ %if ! 0%{?suse_version } > 1600 || 0%{?centos }
1025+ Requires: %{python_module boto}
1026+ %endif
1027+ Requires: %{python_module boto3}
1028+ Requires: %{python_module docker}
1029+ %if 0%{?suse_version } < 1600
1030+ Requires: %{python_module mock}
1031+ %endif
1032+ Requires: %{python_module pygit2}
1033+ Requires: %{python_module pytest >= 7.0.1}
1034+ Requires: %{python_module pytest-httpserver}
1035+ Requires: %{python_module pytest-salt-factories >= 1.0.0~rc21}
1036+ Requires: %{python_module pytest-subtests}
1037+ Requires: %{python_module testinfra}
1038+ Requires: %{python_module yamllint}
1039+ Requires: %{python_module pip}
1040+ %else
9141041Recommends: python-CherryPy
9151042Requires: python-Genshi
9161043Requires: python-Mako
@@ -930,13 +1057,18 @@ Requires: python-pytest-subtests
9301057Requires: python-testinfra
9311058Requires: python-yamllint
9321059Requires: python-pip
1060+ %endif
9331061Requires: docker
9341062Requires: openssh
9351063Requires: git
9361064
9371065Obsoletes: %{name }-tests
9381066
1067+ %if 0%{?_nosinglespec }
1068+ %description -n python3-salt-testsuite
1069+ %else
9391070%description -n python-salt-testsuite
1071+ %endif
9401072Collection of unit, functional, and integration tests for %{name }.
9411073
9421074%endif
@@ -1106,7 +1238,7 @@ ln -sf %{_initddir}/salt-api %{buildroot}%{_sbindir}/rcsalt-api
11061238## Install sysV salt-minion watchdog for SLES11 and RHEL6
11071239%if 0%{?rhel } == 6 || 0%{?suse_version } == 1110
11081240install -Dpm 0755 scripts/suse/watchdog/salt-daemon-watcher %{buildroot }%{_bindir }/salt-daemon-watcher
1109- %endif
1241+ %endif
11101242
11111243#
11121244## install config files
@@ -1156,6 +1288,10 @@ install -Dpm 0640 conf/suse/standalone-formulas-configuration.conf %{buildroot}%
11561288%python_expand %fdupes %{buildroot }%{$python_sitelib}
11571289%endif
11581290
1291+ %if 0%{?_alternatives }
1292+ %python_clone -a %{buildroot }%{_bindir }/salt-call
1293+ %endif
1294+
11591295%endif
11601296
11611297%check
@@ -1176,6 +1312,10 @@ getent passwd salt >/dev/null || %{_sbindir}/useradd -r -g salt -d $S_HOME -s /b
11761312if [[ -d " $S_PHOME /.ssh" ]]; then
11771313 mv $S_PHOME /.ssh $S_HOME
11781314fi
1315+ %if 0%{?_alternatives }
1316+ [ -h %{_bindir}/salt-call ] || rm -f %{_bindir }/salt-call
1317+ %python_libalternatives_reset_alternative salt-call
1318+ %endif
11791319
11801320%post
11811321%if %{with systemd }
@@ -1470,7 +1610,23 @@ fi
14701610%endif
14711611%endif
14721612
1613+ %if 0%{?_alternatives }
1614+ %pre -n python-salt
1615+ [ -h %{_bindir}/salt-call ] || rm -f %{_bindir }/salt-call
1616+ %python_libalternatives_reset_alternative salt-call
1617+
1618+ %post -n python-salt
1619+ %python_install_alternative salt-call
1620+
1621+ %postun -n python-salt
1622+ %python_uninstall_alternative salt-call
1623+ %endif
1624+
1625+ %if 0%{?_nosinglespec }
1626+ %posttrans -n %{python_module salt}
1627+ %else
14731628%posttrans -n python-salt
1629+ %endif
14741630# force re-generate a new thin.tgz
14751631rm -f %{_localstatedir }/cache/salt/master/thin/version
14761632rm -f %{_localstatedir }/cache/salt/minion/thin/version
@@ -1607,7 +1763,9 @@ rm -f %{_localstatedir}/cache/salt/minion/thin/version
16071763%files
16081764%defattr(-,root,root,-)
16091765%{_bindir }/spm
1766+ %if ! 0%{?_alternatives }
16101767%{_bindir }/salt-call
1768+ %endif
16111769%{_bindir }/salt-support
16121770%{_mandir }/man1/salt-call.1.gz
16131771%{_mandir }/man1/spm.1.gz
@@ -1628,6 +1786,9 @@ rm -f %{_localstatedir}/cache/salt/minion/thin/version
16281786
16291787%files %{python_files salt}
16301788%defattr(-,root,root,-)
1789+ %if 0%{?_alternatives }
1790+ %python_alternative %{_bindir }/salt-call
1791+ %endif
16311792%dir %{python_sitelib }/salt
16321793%dir %{python_sitelib }/salt-* .egg-info
16331794%{python_sitelib }/salt/*
@@ -1684,5 +1845,3 @@ rm -f %{_localstatedir}/cache/salt/minion/thin/version
16841845%endif
16851846
16861847%changelog
1687-
1688-
0 commit comments