Add %crate_instdir convenience macro

Fixes #41.

The template is adjusted to use the new macro. This will only work
if the macro is defined, thus the required version of rust-packaging
is bumped.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-02-14 11:55:18 +01:00
parent 9d72601698
commit c2a760efcd
2 changed files with 5 additions and 3 deletions

View file

@ -10,6 +10,8 @@
%cargo_registry %{_datadir}/cargo/registry %cargo_registry %{_datadir}/cargo/registry
%crate_instdir %{cargo_registry}/%{crate}-%{version_no_tilde}
%__cargo_is_lib() %__cargo_inspector --target-kinds Cargo.toml | grep -q -F -x "$(printf 'lib\\\nrlib\\\nproc-macro')" %__cargo_is_lib() %__cargo_inspector --target-kinds Cargo.toml | grep -q -F -x "$(printf 'lib\\\nrlib\\\nproc-macro')"
%__cargo_is_bin() %__cargo_inspector --target-kinds Cargo.toml | grep -q -F -x bin %__cargo_is_bin() %__cargo_inspector --target-kinds Cargo.toml | grep -q -F -x bin

View file

@ -43,7 +43,7 @@ Patch0: {{ patch_file }}
ExclusiveArch: %{rust_arches} ExclusiveArch: %{rust_arches}
BuildRequires: rust-packaging BuildRequires: rust-packaging >= 21
{% if all_features %} {% if all_features %}
{% set cargo_args = " -a" %} {% set cargo_args = " -a" %}
{% endif %} {% endif %}
@ -160,9 +160,9 @@ use {% if feature is not none %}the "{{ feature }}" feature of {% endif %}the "%
{% if license_files|length > 0 %} {% if license_files|length > 0 %}
%license {{ license_files|join(' ') }} %license {{ license_files|join(' ') }}
{% endif %} {% endif %}
%{cargo_registry}/%{crate}-%{version_no_tilde}/ %{crate_instdir}/
{% else %} {% else %}
%ghost %{cargo_registry}/%{crate}-%{version_no_tilde}/Cargo.toml %ghost %{crate_instdir}/Cargo.toml
{% endif %} {% endif %}
{% endfor %} {% endfor %}