#%%bcond_without check
%bcond_with check

Name:           rust2rpm
Version:        27.1.1
Release:        1
Summary:        Generate RPM spec files for Rust crates
License:        MIT

URL:            https://pagure.io/fedora-rust/rust2rpm
Source:         %{url}/archive/v%{version}/rust2rpm-%{version}.tar.gz

BuildArch:      noarch

BuildRequires:  python3-devel
BuildRequires:  python3-wheel
BuildRequires:  python3-pip
BuildRequires:  python3-setuptools
BuildRequires:  /usr/bin/asciidoctor

%if %{with check}
BuildRequires:  cargo
BuildRequires:  rust2rpm-helper >= 0.1.2
%endif

Requires:       cargo
Requires:       cargo-rpm-macros
Recommends:     rust2rpm-helper >= 0.1.2

# obsolete old provides (removed in Fedora 38)
Obsoletes:      cargo-inspector < 24

# obsolete and / or provide removed Python subpackages (removed in Fedora 38)
Provides:       python3-rust2rpm = %{name}-%{version}
Obsoletes:      python3-rust2rpm < 24
Obsoletes:      python3-rust2rpm-core < 24

%description
rust2rpm is a tool that automates the generation of RPM spec files for
Rust crates.

%prep
%autosetup -p1


%build
%pyproject_build
# build man pages
pushd docs
asciidoctor -b manpage rust2rpm.1.asciidoc
asciidoctor -b manpage rust2rpm.conf.5.asciidoc
asciidoctor -b manpage rust2rpm.toml.5.asciidoc
popd

%install
%pyproject_install
# install man pages
install -Dpm 644 docs/rust2rpm.1 -t %{buildroot}/%{_mandir}/man1/
install -Dpm 644 docs/rust2rpm.conf.5 -t %{buildroot}/%{_mandir}/man5/
install -Dpm 644 docs/rust2rpm.toml.5 -t %{buildroot}/%{_mandir}/man5/

%check
%if %{with check}
%tox
%endif

%files
%doc README.md
%doc CHANGELOG.md
%{_bindir}/rust2rpm
%{python3_sitelib}/%{name}/
%{python3_sitelib}/%{name}-*.dist-info/
%{_mandir}/man1/rust2rpm.1*
%{_mandir}/man5/rust2rpm.{conf,toml}.5*

%changelog
* Fri Nov 07 2025 liweigang <liweiganga@gmail.com> - 27.1.1-1
- update to version 27.1.1

* Mon Oct 27 2025 liweigang <liweiganga@gmail.com> - 27.1.0-1
- Initial import