Blob Blame History Raw
%bcond_without check
# https://pagure.io/koji/issue/659
%global debug_package %{nil}

Name:           rust-packaging
Version:        21
Release:        %autorelease
Summary:        RPM macros for building Rust packages

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

Patch:          0001-Add-comment-about-unused-macro.patch
Patch:          0002-Allow-easy-overriding-of-the-opt-level-debuginfo-cod.patch
Patch:        	0003-Fix-autodetection-of-rpmautospec.patch
Patch:        	0004-Print-information-about-written-files.patch
Patch:          0005-macros.cargo-vacuum-up-Cargo.toml.orig-in-addition-t.patch

ExclusiveArch:  %{rust_arches}

# gawk is needed for stripping dev-deps in macro
Requires:       gawk
Requires:       rust-srpm-macros = %{version}
Requires:       rust
Requires:       cargo >= 1.41

Recommends:     python3-rust2rpm

%description
The package provides RPM macros for building Rust projects.

Note that rust-srpm-macros is a seperate arch-independent package that
is also required to build Rust packages.

%package     -n python3-rust2rpm
Summary:        Generate RPM spec files for Rust packages
BuildRequires:  python3-devel
%if %{with check}
BuildRequires:  python3-pytest
BuildRequires:  cargo
%endif
Requires:       cargo
Provides:       rust2rpm = %{version}-%{release}
Requires:       (rust-packaging = %{?epoch:%{epoch}:}%{version}-%{release} if rust-packaging)

%description -n python3-rust2rpm
%{summary}.

%prep
%autosetup -n rust2rpm-v%{version} -p1

%generate_buildrequires
%pyproject_buildrequires

%build
%pyproject_wheel

%install
%pyproject_install
%pyproject_save_files rust2rpm
install -D -p -m 0644 -t %{buildroot}%{_rpmmacrodir} data/macros.rust data/macros.cargo
install -D -p -m 0644 -t %{buildroot}%{_fileattrsdir} data/cargo.attr

%if %{with check}
%check
%pytest -vv test.py
%endif

%files
%license LICENSE
%{_rpmmacrodir}/macros.rust
%{_rpmmacrodir}/macros.cargo
%{_fileattrsdir}/cargo.attr
# the following Python files are co-owned with the full-blown python3-rust2rpm package
# they are needed for cargo.attr
%{_bindir}/cargo-inspector
%dir %{python3_sitelib}/rust2rpm
%pycached %{python3_sitelib}/rust2rpm/__init__.py
%pycached %{python3_sitelib}/rust2rpm/inspector.py
%pycached %{python3_sitelib}/rust2rpm/licensing.py
%pycached %{python3_sitelib}/rust2rpm/metadata.py
%{python3_sitelib}/rust2rpm/spdx_to_fedora.csv


%files -n python3-rust2rpm -f %{pyproject_files}
%doc NEWS
%{_bindir}/rust2rpm
%{_bindir}/cargo-inspector


%changelog
%autochangelog