From c2a760efcdcd6c7cb8a067b90f57f7cf4fa7a940 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Feb 14 2022 13:01:44 +0000 Subject: 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. --- diff --git a/data/macros.cargo b/data/macros.cargo index 07fcb56..edc2f56 100644 --- a/data/macros.cargo +++ b/data/macros.cargo @@ -10,6 +10,8 @@ %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_bin() %__cargo_inspector --target-kinds Cargo.toml | grep -q -F -x bin diff --git a/rust2rpm/templates/main.spec b/rust2rpm/templates/main.spec index 77e61a4..68d8309 100644 --- a/rust2rpm/templates/main.spec +++ b/rust2rpm/templates/main.spec @@ -43,7 +43,7 @@ Patch0: {{ patch_file }} ExclusiveArch: %{rust_arches} -BuildRequires: rust-packaging +BuildRequires: rust-packaging >= 21 {% if all_features %} {% set cargo_args = " -a" %} {% endif %} @@ -160,9 +160,9 @@ use {% if feature is not none %}the "{{ feature }}" feature of {% endif %}the "% {% if license_files|length > 0 %} %license {{ license_files|join(' ') }} {% endif %} -%{cargo_registry}/%{crate}-%{version_no_tilde}/ +%{crate_instdir}/ {% else %} -%ghost %{cargo_registry}/%{crate}-%{version_no_tilde}/Cargo.toml +%ghost %{crate_instdir}/Cargo.toml {% endif %} {% endfor %}