From bfd926d22d95c8c7c3be32cc0f66c3ac18411571 Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Sep 24 2023 19:50:54 +0000 Subject: [PATCH 1/2] %crate_instdir: stop depending on the version_no_tilde macro --- diff --git a/macros.d/macros.cargo b/macros.d/macros.cargo index 2a23efc..07e4c07 100644 --- a/macros.d/macros.cargo +++ b/macros.d/macros.cargo @@ -28,10 +28,12 @@ # with replaces the "crates.io" source %cargo_registry /usr/share/cargo/registry -# crate_instdir: path to the directory where library crates are installed, -# with version_no_tilde being the upstream version of the crate -# (i.e. with "~" characters from the RPM version replaced by "-") -%crate_instdir %{cargo_registry}/%{crate}-%{version_no_tilde} +# crate_instdir: path to the directory where library crates are installed +# +# Installed crates are namespaces by both their name and version to ensure +# parallel installability. If the "crate_version" macro is not defined, the +# macro falls back to the package "version". +%crate_instdir %{cargo_registry}/%{crate}-%{?crate_version:%{crate_version}}%{!?crate_version:%{version}} # __cargo_is_lib: function-like macro that returns successfully if the crate in # the current working directory is a "library" crate From c3127262807098bbbcf071ad1cc45017fc17027a Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Sep 25 2023 09:56:40 +0000 Subject: [PATCH 2/2] %crates_source: respect %crate_version if defined and simplify lua code --- diff --git a/macros.d/macros.rust-srpm b/macros.d/macros.rust-srpm index ab93333..45287a8 100644 --- a/macros.d/macros.rust-srpm +++ b/macros.d/macros.rust-srpm @@ -33,19 +33,25 @@ local version = rpm.expand('%2') local url = rpm.expand('%__crates_url') \ + -- first argument missing: fall back to %crate if crate == '%1' then - crate = rpm.expand('%real_crate') - end - if crate == '%real_crate' then crate = rpm.expand('%crate') end + -- %crate macro not defined: fall back to %name if crate == '%crate' then crate = rpm.expand('%name') end \ + -- second argument missing: fall back to %crate_version if version == '%2' then + version = rpm.expand('%crate_version') + end + -- %crate_version macro not defined: fall back to %version + if version == '%crate_version' then version = rpm.expand('%version') end + -- replace '~' with '-' for backwards compatibility + -- can be removed in the future version = version:gsub('~', '-') \ print(url .. crate .. '/' .. version .. '/download#/' .. crate .. '-' .. version .. '.crate')