Make spec file more distro-agnostic

This allows the same Fedora srpm to be rebuild on the ELN, CentOS
Stream and RHEL distributions.

Change the test runner to tox since the user of pytest3-test-runner
was dropped upstream.
This commit is contained in:
Alexander Scheel 2021-03-02 10:50:46 -05:00 committed by Rob Crittenden
parent 3b3b15fade
commit 3c619c78d4

View File

@ -1,16 +1,25 @@
%if 0%{?rhel}
%global project ipa
%global projectname IPA
%global alt_project freeipa
%else
# Fedora
%global project freeipa
%global projectname FreeIPA
%global alt_project ipa
%endif
%global shortname healthcheck
%global longname ipa%{shortname}
%global debug_package %{nil}
%global python3dir %{_builddir}/python3-%{name}-%{version}-%{release}
%{!?python3_sitelib: %global python3_sitelib %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%global alt_name %{alt_project}-%{shortname}
%bcond_without tests
Name: %{project}-%{shortname}
Version: 0.8
Release: 4%{?dist}
Release: 5%{?dist}
Summary: Health check tool for %{projectname}
BuildArch: noarch
License: GPLv3
@ -37,14 +46,19 @@ BuildRequires: python3-setuptools
BuildRequires: systemd-devel
%{?systemd_requires}
# packages for make check
BuildRequires: python3-pytest-runner
%if %{with tests}
BuildRequires: python3-tox
BuildRequires: python3-pytest
BuildRequires: python3-ipalib
BuildRequires: python3-ipaserver
%endif
BuildRequires: python3-lib389
BuildRequires: python3-libsss_nss_idmap
# Cross-provides for sibling OS
Provides: %{alt_name} = %{version}
Conflicts: %{alt_name}
Obsoletes: %{alt_name} < %{version}
%description
The FreeIPA health check tool provides a set of checks to
@ -54,14 +68,18 @@ proactively detect defects in a FreeIPA cluster.
%package -n %{name}-core
Summary: Core plugin system for healthcheck
# Cross-provides for sibling OS
Provides: %{alt_name}-core = %{version}
Conflicts: %{alt_name}-core
Obsoletes: %{alt_name}-core < %{version}
%description -n %{name}-core
Core files
%prep
%setup -n %{project}-%{shortname}-%{version}
%autosetup -p1
%autosetup -p1 -n freeipa-%{shortname}-%{version}
%build
@ -75,21 +93,21 @@ mkdir -p %{buildroot}%{_sysconfdir}/%{longname}
install -m644 %{SOURCE1} %{buildroot}%{_sysconfdir}/%{longname}
mkdir -p %{buildroot}/%{_unitdir}
install -p -m644 %{_builddir}/%{project}-%{shortname}-%{version}/systemd/ipa-%{shortname}.service %{buildroot}%{_unitdir}
install -p -m644 %{_builddir}/%{project}-%{shortname}-%{version}/systemd/ipa-%{shortname}.timer %{buildroot}%{_unitdir}
install -p -m644 %{_builddir}/freeipa-%{shortname}-%{version}/systemd/ipa-%{shortname}.service %{buildroot}%{_unitdir}
install -p -m644 %{_builddir}/freeipa-%{shortname}-%{version}/systemd/ipa-%{shortname}.timer %{buildroot}%{_unitdir}
mkdir -p %{buildroot}/%{_libexecdir}/ipa
install -p -m755 %{_builddir}/%{project}-%{shortname}-%{version}/systemd/ipa-%{shortname}.sh %{buildroot}%{_libexecdir}/ipa/
install -p -m755 %{_builddir}/freeipa-%{shortname}-%{version}/systemd/ipa-%{shortname}.sh %{buildroot}%{_libexecdir}/ipa/
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d
install -p -m644 %{_builddir}/%{project}-%{shortname}-%{version}/logrotate/%{longname} %{buildroot}%{_sysconfdir}/logrotate.d
install -p -m644 %{_builddir}/freeipa-%{shortname}-%{version}/logrotate/%{longname} %{buildroot}%{_sysconfdir}/logrotate.d
mkdir -p %{buildroot}/%{_localstatedir}/log/ipa/%{shortname}
mkdir -p %{buildroot}/%{_mandir}/man8
mkdir -p %{buildroot}/%{_mandir}/man5
install -p -m644 %{_builddir}/%{project}-%{shortname}-%{version}/man/man8/ipa-%{shortname}.8 %{buildroot}%{_mandir}/man8/
install -p -m644 %{_builddir}/%{project}-%{shortname}-%{version}/man/man5/%{longname}.conf.5 %{buildroot}%{_mandir}/man5/
install -p -m644 %{_builddir}/freeipa-%{shortname}-%{version}/man/man8/ipa-%{shortname}.8 %{buildroot}%{_mandir}/man8/
install -p -m644 %{_builddir}/freeipa-%{shortname}-%{version}/man/man5/%{longname}.conf.5 %{buildroot}%{_mandir}/man5/
(cd %{buildroot}/%{python3_sitelib}/ipahealthcheck && find . -type f | \
grep -v '^./core' | \
@ -100,7 +118,7 @@ install -p -m644 %{_builddir}/%{project}-%{shortname}-%{version}/man/man5/%{long
%if %{with tests}
%check
%{__python3} setup.py test
tox -epy3
%endif
@ -141,6 +159,10 @@ install -p -m644 %{_builddir}/%{project}-%{shortname}-%{version}/man/man5/%{long
%changelog
* Tue Mar 2 2021 Alexander Scheel <ascheel@redhat.com> - 0.8-5
- Make the spec file more distribution-agnostic
- Use tox as the test runner when tests are enabled
* Tue Mar 02 2021 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 0.8-4
- Rebuilt for updated systemd-rpm-macros
See https://pagure.io/fesco/issue/2583.