#227 RFE: macro-ize feature subpackages
Opened 2 years ago by decathorpe. Modified 5 months ago

Subpackages for features and optional dependencies are 99% boilerplate, it would be great to reduce them to simple macro calls, something like:

%cargo_feature_subpackage foo

Which would get expanded to:

%package     -n %{name}+foo-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+foo-devel %{_description}

This package contains library source intended for building other packages which
use the "foo" feature of the "%{crate}" crate.

%files       -n %{name}+foo-devel
%ghost %{crate_instdir}/Cargo.toml

This would make spec files for Rust packages much smaller and much less noisy.

The macro could even accept arguments like -r requirement for adding Requires tags to the subpackage (which is often the case for -sys bindings that support different versions of the system library).

I'm not a wizard with implementing RPM macros, but would something like this work (minus RPM macro syntax errors, of course - not sure how to specify that "n" is a mandatory positional argument and "-r" is an optional flag that takes a value ...):

%cargo_feature_subpackage(n:r) %{expand:\
%package     -n %{name}+%{-n}-devel
Summary:        %{summary}
BuildArch:      noarch
%{-r:Requires:       %{-r*}}

%description -n %{name}+%{-n}-devel %{_description}

This package contains library source intended for building other packages which
use the "%{-n}" feature of the "%{crate}" crate.

%files       -n %{name}+%{-n}-devel
%ghost %{crate_instdir}/Cargo.toml}

Metadata Update from @decathorpe:
- Issue set to the milestone: v26.0

2 years ago

Metadata Update from @decathorpe:
- Issue set to the milestone: v27.0 (was: v26.0)

a year ago

Metadata Update from @decathorpe:
- Issue tagged with: feature

a year ago

This will require changes to the RPM macros that I don't plan to make before the rust2rpm v27 release.

Metadata Update from @decathorpe:
- Issue set to the milestone: None (was: v27.0)

5 months ago

Log in to comment on this ticket.

Metadata