Skip to content

Commit 5a05e31

Browse files
committed
Add python_group_libalternatives to excludes-bracketing
Fix #331
1 parent e369e29 commit 5a05e31

3 files changed

Lines changed: 261 additions & 0 deletions

File tree

data/excludes-bracketing.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ py2_compile
130130
py3_compile
131131
py_req_cleanup
132132
python_alternative
133+
python_group_libalternatives
133134
python_install_alternative
134135
python_libalternatives_reset_alternative
135136
python_uninstall_alternative

tests/in/python-spf-engine.spec

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#
2+
# spec file for package python-spf-engine
3+
#
4+
# Copyright (c) 2025 Ákos Szőts <szotsaki@gmail.com>
5+
# Copyright (c) 2020 SUSE LLC
6+
#
7+
# All modifications and additions to the file contributed by third parties
8+
# remain the property of their copyright owners, unless otherwise agreed
9+
# upon. The license for this file, and modifications and additions to the
10+
# file, is the same license as for the pristine package itself (unless the
11+
# license for the pristine package is not an Open Source License, in which
12+
# case the license is the MIT License). An "Open Source License" is a
13+
# license that conforms to the Open Source Definition (Version 1.9)
14+
# published by the Open Source Initiative.
15+
16+
# Please submit bugfixes or comments via https://bugs.opensuse.org/
17+
#
18+
19+
# Trick python_subpackages not to change it to python3 string
20+
%define policyd_spf python-policyd-spf
21+
%define oname python
22+
%if 0%{?suse_version} > 1500
23+
%bcond_without libalternatives
24+
%else
25+
%bcond_with libalternatives
26+
%endif
27+
Name: python-spf-engine
28+
Version: 3.1.0
29+
Release: 0
30+
Summary: SPF (Sender Policy Framework) processing engine for Postfix
31+
License: Apache-2.0 AND GPL-2.0-only
32+
Group: Development/Languages/Python
33+
URL: https://launchpad.net/spf-engine
34+
Source: https://files.pythonhosted.org/packages/source/s/spf-engine/spf-engine-%{version}.tar.gz
35+
BuildRequires: %{python_module flit-core >= 3.8}
36+
BuildRequires: %{python_module pip}
37+
BuildRequires: fdupes
38+
BuildRequires: python-rpm-macros
39+
Requires: python-authres
40+
Requires: python-pyspf
41+
Suggests: python-pymilter
42+
Conflicts: %{policyd_spf}
43+
Obsoletes: %{policyd_spf} < 2
44+
Provides: %{policyd_spf} = %{version}
45+
Provides: %{oname}-spf-engine = %{version}
46+
BuildArch: noarch
47+
%if %{with libalternatives}
48+
BuildRequires: alts
49+
Requires: alts
50+
%else
51+
Requires(post): update-alternatives
52+
Requires(postun): update-alternatives
53+
%endif
54+
%python_subpackages
55+
56+
%description
57+
SPF (Sender Policy Framework) backend for pypolicyd-spf.
58+
59+
Provides a back-end to support SPF integration with Postfix and Sendmail using both the Postfix policy service and the Sendmail milter protocol.
60+
61+
%prep
62+
%autosetup -p1 -n spf-engine-%{version}
63+
64+
# Remove shebang from Python library
65+
sed -i '/^#!/d' spf_engine/*.py
66+
67+
%build
68+
%pyproject_wheel
69+
70+
%install
71+
%pyproject_install
72+
%python_clone -a %{buildroot}%{_bindir}/policyd-spf
73+
%python_clone -a %{buildroot}%{_bindir}/pyspf-milter
74+
%python_group_libalternatives policyd-spf pyspf-milter
75+
76+
cp -r --no-dereference --link %{buildroot}%{_prefix}%{_sysconfdir} %{buildroot}
77+
rm -r %{buildroot}%{_prefix}%{_sysconfdir}
78+
79+
mkdir -p %{buildroot}%{_docdir}/%{policyd_spf}
80+
mv -v %{buildroot}%{_datadir}/doc/%{policyd_spf}/* %{buildroot}%{_docdir}/%{policyd_spf}/
81+
82+
rm %{buildroot}%{_initddir}/pyspf-milter
83+
84+
mkdir -p %{buildroot}%{_sbindir}
85+
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcpyspf-milter
86+
87+
%python_expand %fdupes %{buildroot}%{$python_sitelib}
88+
89+
%pre
90+
%python_libalternatives_reset_alternative policyd-spf
91+
%python_libalternatives_reset_alternative pyspf-milter
92+
%service_add_pre pyspf-milter.service
93+
94+
%post
95+
%python_install_alternative policyd-spf
96+
%python_install_alternative pyspf-milter
97+
%service_add_post pyspf-milter.service
98+
99+
%preun
100+
%service_del_preun pyspf-milter.service
101+
102+
%postun
103+
%python_uninstall_alternative policyd-spf
104+
%python_uninstall_alternative pyspf-milter
105+
%service_del_postun pyspf-milter.service
106+
107+
%files %{python_files}
108+
%doc CHANGES README.txt
109+
%dir %{_docdir}/%{policyd_spf}
110+
%doc %{_docdir}/%{policyd_spf}/README.per_user_whitelisting
111+
%{_mandir}/*/*
112+
%license COPYING
113+
114+
%python_alternative %{_bindir}/policyd-spf
115+
%python_alternative %{_bindir}/pyspf-milter
116+
117+
%{python_sitelib}/spf_engine
118+
%{python_sitelib}/spf_engine-%{version}.dist-info
119+
120+
%dir %{_sysconfdir}/%{policyd_spf}
121+
%config(noreplace) %{_sysconfdir}/%{policyd_spf}/policyd-spf.conf
122+
%config %{_sysconfdir}/%{policyd_spf}/policyd-spf.conf.commented
123+
124+
%dir %{_sysconfdir}/pyspf-milter
125+
%config(noreplace) %{_sysconfdir}/pyspf-milter/pyspf-milter.conf
126+
127+
%{_prefix}/lib/systemd/system/pyspf-milter.service
128+
%{_sbindir}/rcpyspf-milter
129+
130+
%changelog

tests/out/python-spf-engine.spec

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#
2+
# spec file for package python-spf-engine
3+
#
4+
# Copyright (c) 2025 Ákos Szőts <szotsaki@gmail.com>
5+
# Copyright (c) 2020 SUSE LLC
6+
#
7+
# All modifications and additions to the file contributed by third parties
8+
# remain the property of their copyright owners, unless otherwise agreed
9+
# upon. The license for this file, and modifications and additions to the
10+
# file, is the same license as for the pristine package itself (unless the
11+
# license for the pristine package is not an Open Source License, in which
12+
# case the license is the MIT License). An "Open Source License" is a
13+
# license that conforms to the Open Source Definition (Version 1.9)
14+
# published by the Open Source Initiative.
15+
16+
# Please submit bugfixes or comments via https://bugs.opensuse.org/
17+
#
18+
19+
# Trick python_subpackages not to change it to python3 string
20+
%define policyd_spf python-policyd-spf
21+
%define oname python
22+
%if 0%{?suse_version} > 1500
23+
%bcond_without libalternatives
24+
%else
25+
%bcond_with libalternatives
26+
%endif
27+
Name: python-spf-engine
28+
Version: 3.1.0
29+
Release: 0
30+
Summary: SPF (Sender Policy Framework) processing engine for Postfix
31+
License: Apache-2.0 AND GPL-2.0-only
32+
Group: Development/Languages/Python
33+
URL: https://launchpad.net/spf-engine
34+
Source: https://files.pythonhosted.org/packages/source/s/spf-engine/spf-engine-%{version}.tar.gz
35+
BuildRequires: %{python_module flit-core >= 3.8}
36+
BuildRequires: %{python_module pip}
37+
BuildRequires: fdupes
38+
BuildRequires: python-rpm-macros
39+
Requires: python-authres
40+
Requires: python-pyspf
41+
Suggests: python-pymilter
42+
Conflicts: %{policyd_spf}
43+
Obsoletes: %{policyd_spf} < 2
44+
Provides: %{policyd_spf} = %{version}
45+
Provides: %{oname}-spf-engine = %{version}
46+
BuildArch: noarch
47+
%if %{with libalternatives}
48+
BuildRequires: alts
49+
Requires: alts
50+
%else
51+
Requires(post): update-alternatives
52+
Requires(postun): update-alternatives
53+
%endif
54+
%python_subpackages
55+
56+
%description
57+
SPF (Sender Policy Framework) backend for pypolicyd-spf.
58+
59+
Provides a back-end to support SPF integration with Postfix and Sendmail using both the Postfix policy service and the Sendmail milter protocol.
60+
61+
%prep
62+
%autosetup -p1 -n spf-engine-%{version}
63+
64+
# Remove shebang from Python library
65+
sed -i '/^#!/d' spf_engine/*.py
66+
67+
%build
68+
%pyproject_wheel
69+
70+
%install
71+
%pyproject_install
72+
%python_clone -a %{buildroot}%{_bindir}/policyd-spf
73+
%python_clone -a %{buildroot}%{_bindir}/pyspf-milter
74+
%python_group_libalternatives policyd-spf pyspf-milter
75+
76+
cp -r --no-dereference --link %{buildroot}%{_prefix}%{_sysconfdir} %{buildroot}
77+
rm -r %{buildroot}%{_prefix}%{_sysconfdir}
78+
79+
mkdir -p %{buildroot}%{_docdir}/%{policyd_spf}
80+
mv -v %{buildroot}%{_datadir}/doc/%{policyd_spf}/* %{buildroot}%{_docdir}/%{policyd_spf}/
81+
82+
rm %{buildroot}%{_initddir}/pyspf-milter
83+
84+
mkdir -p %{buildroot}%{_sbindir}
85+
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcpyspf-milter
86+
87+
%python_expand %fdupes %{buildroot}%{$python_sitelib}
88+
89+
%pre
90+
%python_libalternatives_reset_alternative policyd-spf
91+
%python_libalternatives_reset_alternative pyspf-milter
92+
%service_add_pre pyspf-milter.service
93+
94+
%post
95+
%python_install_alternative policyd-spf
96+
%python_install_alternative pyspf-milter
97+
%service_add_post pyspf-milter.service
98+
99+
%preun
100+
%service_del_preun pyspf-milter.service
101+
102+
%postun
103+
%python_uninstall_alternative policyd-spf
104+
%python_uninstall_alternative pyspf-milter
105+
%service_del_postun pyspf-milter.service
106+
107+
%files %{python_files}
108+
%doc CHANGES README.txt
109+
%dir %{_docdir}/%{policyd_spf}
110+
%doc %{_docdir}/%{policyd_spf}/README.per_user_whitelisting
111+
%{_mandir}/*/*
112+
%license COPYING
113+
114+
%python_alternative %{_bindir}/policyd-spf
115+
%python_alternative %{_bindir}/pyspf-milter
116+
117+
%{python_sitelib}/spf_engine
118+
%{python_sitelib}/spf_engine-%{version}.dist-info
119+
120+
%dir %{_sysconfdir}/%{policyd_spf}
121+
%config(noreplace) %{_sysconfdir}/%{policyd_spf}/policyd-spf.conf
122+
%config %{_sysconfdir}/%{policyd_spf}/policyd-spf.conf.commented
123+
124+
%dir %{_sysconfdir}/pyspf-milter
125+
%config(noreplace) %{_sysconfdir}/pyspf-milter/pyspf-milter.conf
126+
127+
%{_prefix}/lib/systemd/system/pyspf-milter.service
128+
%{_sbindir}/rcpyspf-milter
129+
130+
%changelog

0 commit comments

Comments
 (0)