From 2c9257ea1223fa871a2bdbd80a29eefde7b5fe5b Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Sat, 26 Jan 2019 10:36:39 +0100 Subject: [PATCH] Trivial fixes for pre-release versions Signed-off-by: Igor Gnatenko --- ...-Add-support-for-prerelease-versions.patch | 56 +++++++++++++++++-- rust-packaging.spec | 5 +- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/0014-Add-support-for-prerelease-versions.patch b/0014-Add-support-for-prerelease-versions.patch index cf16439..d4c48ef 100644 --- a/0014-Add-support-for-prerelease-versions.patch +++ b/0014-Add-support-for-prerelease-versions.patch @@ -1,14 +1,45 @@ -From 29a3c1b84e0971fc0c2edf483ae3b04139c19b32 Mon Sep 17 00:00:00 2001 +From 769506caf08edb5ea2342d9add22e4db1b347375 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Sat, 26 Jan 2019 08:33:37 +0100 Subject: [PATCH 14/14] Add support for prerelease versions Signed-off-by: Igor Gnatenko --- - rust2rpm/metadata.py | 18 ++++++++++++------ - test.py | 8 ++++++++ - 2 files changed, 20 insertions(+), 6 deletions(-) + data/macros.rust-srpm | 23 +++++++++++++++++++++++ + rust2rpm/metadata.py | 18 ++++++++++++------ + rust2rpm/templates/main.spec | 6 +----- + test.py | 8 ++++++++ + 4 files changed, 44 insertions(+), 11 deletions(-) +diff --git a/data/macros.rust-srpm b/data/macros.rust-srpm +index f2bae9d..bd21cb5 100644 +--- a/data/macros.rust-srpm ++++ b/data/macros.rust-srpm +@@ -1 +1,24 @@ + %rust_arches x86_64 i686 armv7hl aarch64 ppc64 ppc64le s390x ++%__crates_url https://crates.io/api/v1/crates/ ++%crates_source %{lua: ++ local crate = rpm.expand('%1') ++ local version = rpm.expand('%2') ++ local url = rpm.expand('%__crates_url') ++\ ++ if crate == '%1' then ++ crate = rpm.expand('%real_crate') ++ end ++ if crate == '%real_crate' then ++ crate = rpm.expand('%crate') ++ end ++ if crate == '%crate' then ++ crate = rpm.expand('%name') ++ end ++\ ++ if version == '%2' then ++ version = rpm.expand('%version') ++ end ++ version = version:gsub('~', '-') ++\ ++ print(url .. crate .. '/' .. version .. '/download#/' .. crate .. '-' .. version .. '.crate') ++} diff --git a/rust2rpm/metadata.py b/rust2rpm/metadata.py index 328b67a..f0718d5 100644 --- a/rust2rpm/metadata.py @@ -61,6 +92,23 @@ index 328b67a..f0718d5 100644 for feature in features) return fdeps | deps +diff --git a/rust2rpm/templates/main.spec b/rust2rpm/templates/main.spec +index 84bd97d..f67e023 100644 +--- a/rust2rpm/templates/main.spec ++++ b/rust2rpm/templates/main.spec +@@ -31,11 +31,7 @@ License: {{ license|default("# FIXME") }} + {{ license_comments }} + {% endif %} + URL: https://crates.io/crates/{{ crate }} +-{% if md.name != crate %} +-Source0: https://crates.io/api/v1/crates/%{real_crate}/%{version}/download#/%{crate}-%{version}.crate +-{% else %} +-Source0: https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{crate}-%{version}.crate +-{% endif %} ++Source: %{crates_source} + {% if patch_file is not none %} + {% if target == "opensuse" %} + # PATCH-FIX-OPENSUSE {{ patch_file }} -- Initial patched metadata diff --git a/test.py b/test.py index 30263b4..035df79 100644 --- a/test.py diff --git a/rust-packaging.spec b/rust-packaging.spec index 0d97e56..2162d19 100644 --- a/rust-packaging.spec +++ b/rust-packaging.spec @@ -5,7 +5,7 @@ Name: rust-packaging Version: 6 -Release: 19%{?dist} +Release: 20%{?dist} Summary: RPM macros for building Rust packages on various architectures License: MIT @@ -85,6 +85,9 @@ py.test-%{python3_version} -vv test.py %{python3_sitelib}/rust2rpm/ %changelog +* Sat Jan 26 2019 Igor Gnatenko - 6-20 +- Trivial fixes for pre-release versions + * Sat Jan 26 2019 Igor Gnatenko - 6-19 - Add support for pre-release versions