Enable bootstrapping macros

Since rpmautospec has a circular dependency chain with several other
packages, this patch adds the ability to build with `--with bootstrap` to
temporarily disable some functionality (pytest-xdist, manpage
generation).

On RHEL, it will skip pytest-xdist entirely, since that dependency
provides no value beyond quicker test runs.

For good measure, it also adds a `--without tests` option to speed up
packaging attempts.

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
epel9
Stephen Gallagher 1 month ago
parent e8793b0ab2
commit d0c93ba765

@ -6,12 +6,16 @@
] ]
%endif %endif
# The pytest-xdist package is not available when bootstrapping or for EL builds other than EPEL # Set this to 1 when bootstrapping
%if ! 0%{?rhel} || 0%{?epel} %bcond bootstrap 0
%bcond xdist 1
%else %bcond tests 1
%bcond xdist 0
%endif # While bootstrapping, ignore manpages
%bcond manpages %{without bootstrap}
# The pytest-xdist package is not available when bootstrapping or on RHEL
%bcond xdist %[%{without bootstrap} && %{undefined rhel}]
# Package the placeholder rpm-macros (moved to redhat-rpm-config in F40) # Package the placeholder rpm-macros (moved to redhat-rpm-config in F40)
%if ! (0%{?fedora} >= 40 || 0%{?rhel} >= 10) %if ! (0%{?fedora} >= 40 || 0%{?rhel} >= 10)
@ -20,6 +24,9 @@
%bcond rpmmacropkg 0 %bcond rpmmacropkg 0
%endif %endif
%if %{with bootstrap}
%bcond poetry 0
%else
%if ! 0%{?fedora}%{?rhel} || 0%{?fedora} || 0%{?epel} >= 9 %if ! 0%{?fedora}%{?rhel} || 0%{?fedora} || 0%{?epel} >= 9
%bcond poetry 1 %bcond poetry 1
# Appease old Poetry versions (<1.2.0a2) # Appease old Poetry versions (<1.2.0a2)
@ -31,12 +38,18 @@
%else %else
%bcond poetry 0 %bcond poetry 0
%endif %endif
%endif
%global srcname rpmautospec %global srcname rpmautospec
Name: python-%{srcname} Name: python-%{srcname}
Version: 0.7.1 Version: 0.7.1
%if %{with bootstrap}
Release: 0%{?dist}
%else
Release: %autorelease Release: %autorelease
%endif
Summary: Package and CLI tool to generate release fields and changelogs Summary: Package and CLI tool to generate release fields and changelogs
License: MIT License: MIT
URL: https://github.com/fedora-infra/%{srcname} URL: https://github.com/fedora-infra/%{srcname}
@ -53,17 +66,25 @@ BuildRequires: glibc-langpack-de
BuildRequires: glibc-langpack-en BuildRequires: glibc-langpack-en
BuildRequires: python3-devel >= 3.9.0 BuildRequires: python3-devel >= 3.9.0
# Needed to build man pages # Needed to build man pages
%if %{with manpages}
BuildRequires: python3dist(click-man) BuildRequires: python3dist(click-man)
%endif
%if %{with tests}
# The dependencies needed for testing dont get auto-generated. # The dependencies needed for testing dont get auto-generated.
BuildRequires: python3dist(pytest) BuildRequires: python3dist(pytest)
%if %{with xdist} %if %{with xdist}
BuildRequires: python3dist(pytest-xdist) BuildRequires: python3dist(pytest-xdist)
%endif %endif
%endif
BuildRequires: python3dist(pyyaml) BuildRequires: python3dist(pyyaml)
BuildRequires: sed BuildRequires: sed
%if %{without poetry} %if %{without poetry}
BuildRequires: python3dist(babel) BuildRequires: python3dist(babel)
BuildRequires: python3dist(click)
BuildRequires: python3dist(click-plugins)
BuildRequires: python3dist(pygit2) BuildRequires: python3dist(pygit2)
BuildRequires: python3dist(rpm) BuildRequires: python3dist(rpm)
BuildRequires: python3dist(rpmautospec-core) BuildRequires: python3dist(rpmautospec-core)
@ -136,10 +157,12 @@ cat << EOF > %{pyproject_files}
EOF EOF
%endif %endif
%if %{with manpages}
# Man pages # Man pages
PYTHONPATH=%{buildroot}%{python3_sitelib} click-man rpmautospec PYTHONPATH=%{buildroot}%{python3_sitelib} click-man rpmautospec
install -m755 -d %{buildroot}%{_mandir}/man1 install -m755 -d %{buildroot}%{_mandir}/man1
install -m644 man/*.1 %{buildroot}%{_mandir}/man1 install -m644 man/*.1 %{buildroot}%{_mandir}/man1
%endif
# RPM macros # RPM macros
%if %{with rpmmacropkg} %if %{with rpmmacropkg}
@ -166,17 +189,28 @@ for shell_path in \
done done
%check %check
# Always run the import checks, even when other tests are disabled
%if %{with poetry}
%pyproject_check_import
%else
%py3_check_import rpmautospec rpmautospec.cli
%endif
%if %{with tests}
%pytest -v \ %pytest -v \
%if %{with xdist} %if %{with xdist}
--numprocesses=auto --numprocesses=auto
%endif %endif
%endif
%files -n python3-%{srcname} -f %{pyproject_files} %files -n python3-%{srcname} -f %{pyproject_files}
%doc README.rst %doc README.rst
%files -n %{srcname} %files -n %{srcname}
%{_bindir}/rpmautospec %{_bindir}/rpmautospec
%if %{with manpages}
%{_mandir}/man1/rpmautospec*.1* %{_mandir}/man1/rpmautospec*.1*
%endif
%dir %{bash_completions_dir} %dir %{bash_completions_dir}
%{bash_completions_dir}/rpmautospec %{bash_completions_dir}/rpmautospec
%dir %{fish_completions_dir} %dir %{fish_completions_dir}
@ -190,4 +224,10 @@ done
%endif %endif
%changelog %changelog
%if %{undefined autochangelog}
* Thu Jan 01 1970 Anonymous Fedora Packager <devel@lists.fedoraproject.org> - %{version}-%{release}
- Bootstrap build of rpmautospec
%else
%autochangelog %autochangelog
%endif

Loading…
Cancel
Save