Various improvements for %%cargo_* macros

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
epel9
Igor Gnatenko 7 years ago
parent fe7dc1b94a
commit fb6d2b0217
No known key found for this signature in database
GPG Key ID: 695714BD1BBC5F4C

@ -1,7 +1,7 @@
From 5313b352712486b4001827b04d906bdb91be2314 Mon Sep 17 00:00:00 2001 From 5313b352712486b4001827b04d906bdb91be2314 Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <ignatenkobrain@fedoraproject.org> From: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
Date: Mon, 8 Jan 2018 23:57:03 +0100 Date: Mon, 8 Jan 2018 23:57:03 +0100
Subject: [PATCH 1/3] macros: remove Cargo.lock Subject: [PATCH 1/5] macros: remove Cargo.lock
cargo-package automatically strips it out, but we package also some cargo-package automatically strips it out, but we package also some
things directly from git. things directly from git.
@ -27,5 +27,5 @@ index ebf3edb..288554c 100644
# https://github.com/rust-lang/cargo/issues/3732 \ # https://github.com/rust-lang/cargo/issues/3732 \
%{__awk} -i inplace -v INPLACE_SUFFIX=.orig '/^\\\[dev-dependencies/{f=1;next} /^\\\[/{f=0}; !f' Cargo.toml \ %{__awk} -i inplace -v INPLACE_SUFFIX=.orig '/^\\\[dev-dependencies/{f=1;next} /^\\\[/{f=0}; !f' Cargo.toml \
-- --
2.16.2 2.18.0.rc2

@ -1,7 +1,7 @@
From cd6329635329fc7742a18f7ed0933298a0c56cf7 Mon Sep 17 00:00:00 2001 From cd6329635329fc7742a18f7ed0933298a0c56cf7 Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <ignatenkobrain@fedoraproject.org> From: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
Date: Tue, 9 Jan 2018 06:52:36 +0100 Date: Tue, 9 Jan 2018 06:52:36 +0100
Subject: [PATCH 2/3] macros: remove spurious whitespace Subject: [PATCH 2/5] macros: remove spurious whitespace
Fixes: https://pagure.io/fedora-rust/rust2rpm/issue/48 Fixes: https://pagure.io/fedora-rust/rust2rpm/issue/48
Reported-by: Josh Stone <jistone@redhat.com> Reported-by: Josh Stone <jistone@redhat.com>
@ -24,5 +24,5 @@ index 288554c..67b1950 100644
%if ! %{with check} \ %if ! %{with check} \
# https://github.com/rust-lang/cargo/issues/3732 \ # https://github.com/rust-lang/cargo/issues/3732 \
-- --
2.16.2 2.18.0.rc2

@ -1,7 +1,7 @@
From c5bab762f56bf07cd0f4a2e2d58b7c295cddedd8 Mon Sep 17 00:00:00 2001 From c5bab762f56bf07cd0f4a2e2d58b7c295cddedd8 Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <ignatenkobrain@fedoraproject.org> From: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
Date: Tue, 20 Feb 2018 22:04:35 +0100 Date: Tue, 20 Feb 2018 22:04:35 +0100
Subject: [PATCH 3/3] macros: pass %__cargo_common_opts to %cargo_install Subject: [PATCH 3/5] macros: pass %__cargo_common_opts to %cargo_install
Reason this has not been done before is that cargo-install doesn't Reason this has not been done before is that cargo-install doesn't
understand --release. Let's just add it to other commands and be done understand --release. Let's just add it to other commands and be done
@ -46,5 +46,5 @@ index 67b1950..22721e9 100644
fi \ fi \
) )
-- --
2.16.2 2.18.0.rc2

@ -0,0 +1,96 @@
From c9ce952e260ec0adb166bd6e1de652a0277d2437 Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
Date: Fri, 22 Jun 2018 21:04:59 +0200
Subject: [PATCH 4/5] macros: make %cargo_* macros parametric
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Unfortunately cargo-install doesn't accept --target-dir, so have to pass
setting through envvar.
Also %{shrink:…} them so it looks nicer in build log.
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
---
data/macros.cargo | 62 ++++++++++++++++++++++++++++++++++-------------
1 file changed, 45 insertions(+), 17 deletions(-)
diff --git a/data/macros.cargo b/data/macros.cargo
index 22721e9..96a2931 100644
--- a/data/macros.cargo
+++ b/data/macros.cargo
@@ -35,25 +35,53 @@ EOF\
%endif \
)
-%cargo_build %__cargo build --release %{__cargo_common_opts}
+%__cargo_parse_opts(t:naf:) %{shrink:\
+%{-f:%{-a:%{error:Can't specify both -f(%{-f*}) and -a}}} \
+ %{-t:--target-dir %{-t*}} \
+ %{-n:--no-default-features} \
+ %{-a:--all-features} \
+ %{-f:--features %{-f*}} \
+ %{nil}
+}
-%cargo_test %__cargo test --release %{__cargo_common_opts} --no-fail-fast
+%cargo_build(t:naf:) %{shrink:\
+%{__cargo} build \
+ %{__cargo_common_opts} \
+ --release \
+ %{__cargo_parse_opts %{-t:-t%{-t*}} %{-n} %{-a} %{-f:-f%{-f*}}} \
+ %* \
+}
-%cargo_install (\
-set -eu \
-if %__cargo_is_lib; then \
- CRATE_NAME=$(%__cargo_inspector --name Cargo.toml) \
- CRATE_VERSION=$(%__cargo_inspector --version Cargo.toml) \
- REG_DIR=%{buildroot}%{cargo_registry}/$CRATE_NAME-$CRATE_VERSION \
- %{__mkdir} -p $REG_DIR \
- %__cargo package -l | xargs %{__cp} --parents -a -t $REG_DIR \
-%if ! %{with check} \
- %{__cp} -a Cargo.toml.orig $REG_DIR/Cargo.toml \
-%endif \
- echo '{"files":{},"package":""}' > $REG_DIR/.cargo-checksum.json \
+%cargo_test(t:naf:) %{shrink:\
+%{__cargo} test \
+ %{__cargo_common_opts} \
+ --release \
+ --no-fail-fast \
+ %{__cargo_parse_opts %{-t:-t%{-t*}} %{-n} %{-a} %{-f:-f%{-f*}}} \
+ %* \
+}
+
+%cargo_install(t:naf:) (\
+set -eu \
+if %__cargo_is_lib; then \
+ CRATE_NAME=$(%__cargo_inspector --name Cargo.toml) \
+ CRATE_VERSION=$(%__cargo_inspector --version Cargo.toml) \
+ REG_DIR=%{buildroot}%{cargo_registry}/$CRATE_NAME-$CRATE_VERSION \
+ %{__mkdir} -p $REG_DIR \
+ %{__cargo} package -l | xargs %{__cp} --parents -a -t $REG_DIR \
+%if ! %{with check} \
+ %{__cp} -a Cargo.toml.orig $REG_DIR/Cargo.toml \
+%endif \
+ echo '{"files":{},"package":""}' > $REG_DIR/.cargo-checksum.json \
fi \
-if %__cargo_is_bin; then \
- %__cargo install %{__cargo_common_opts} --path . --root %{buildroot}%{_prefix} \
- %{__rm} %{buildroot}%{_prefix}/.crates.toml \
+if %__cargo_is_bin; then \
+ %{shrink:%{-t:CARGO_TARGET_DIR=%{-t*}} %{__cargo} install \
+ %{__cargo_common_opts} \
+ --path . \
+ --root %{buildroot}%{_prefix} \
+ %{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \
+ %* \
+ }\
+ %{__rm} %{buildroot}%{_prefix}/.crates.toml \
fi \
)
--
2.18.0.rc2

@ -0,0 +1,71 @@
From 80237720ae3397fc66d8f06e13f868c4bd2723c1 Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
Date: Fri, 22 Jun 2018 21:53:09 +0200
Subject: [PATCH 5/5] macros: remove support for target-dir
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
---
data/macros.cargo | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/data/macros.cargo b/data/macros.cargo
index 96a2931..a0c456a 100644
--- a/data/macros.cargo
+++ b/data/macros.cargo
@@ -35,30 +35,29 @@ EOF\
%endif \
)
-%__cargo_parse_opts(t:naf:) %{shrink:\
+%__cargo_parse_opts(naf:) %{shrink:\
%{-f:%{-a:%{error:Can't specify both -f(%{-f*}) and -a}}} \
- %{-t:--target-dir %{-t*}} \
%{-n:--no-default-features} \
%{-a:--all-features} \
%{-f:--features %{-f*}} \
%{nil}
}
-%cargo_build(t:naf:) %{shrink:\
-%{__cargo} build \
- %{__cargo_common_opts} \
- --release \
- %{__cargo_parse_opts %{-t:-t%{-t*}} %{-n} %{-a} %{-f:-f%{-f*}}} \
- %* \
+%cargo_build(naf:) %{shrink:\
+%{__cargo} build \
+ %{__cargo_common_opts} \
+ --release \
+ %{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \
+ %* \
}
-%cargo_test(t:naf:) %{shrink:\
-%{__cargo} test \
- %{__cargo_common_opts} \
- --release \
- --no-fail-fast \
- %{__cargo_parse_opts %{-t:-t%{-t*}} %{-n} %{-a} %{-f:-f%{-f*}}} \
- %* \
+%cargo_test(naf:) %{shrink:\
+%{__cargo} test \
+ %{__cargo_common_opts} \
+ --release \
+ --no-fail-fast \
+ %{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \
+ %* \
}
%cargo_install(t:naf:) (\
@@ -75,7 +74,7 @@ if %__cargo_is_lib; then \
echo '{"files":{},"package":""}' > $REG_DIR/.cargo-checksum.json \
fi \
if %__cargo_is_bin; then \
- %{shrink:%{-t:CARGO_TARGET_DIR=%{-t*}} %{__cargo} install \
+ %{shrink:%{__cargo} install \
%{__cargo_common_opts} \
--path . \
--root %{buildroot}%{_prefix} \
--
2.18.0.rc2

@ -2,7 +2,7 @@
Name: rust-packaging Name: rust-packaging
Version: 5 Version: 5
Release: 7%{?dist} Release: 8%{?dist}
Summary: RPM macros for building Rust packages on various architectures Summary: RPM macros for building Rust packages on various architectures
License: MIT License: MIT
@ -11,6 +11,8 @@ Source0: https://releases.pagure.org/fedora-rust/rust2rpm/rust2rpm-%{vers
Patch0001: 0001-macros-remove-Cargo.lock.patch Patch0001: 0001-macros-remove-Cargo.lock.patch
Patch0002: 0002-macros-remove-spurious-whitespace.patch Patch0002: 0002-macros-remove-spurious-whitespace.patch
Patch0003: 0003-macros-pass-__cargo_common_opts-to-cargo_install.patch Patch0003: 0003-macros-pass-__cargo_common_opts-to-cargo_install.patch
Patch0004: 0004-macros-make-cargo_-macros-parametric.patch
Patch0005: 0005-macros-remove-support-for-target-dir.patch
BuildArch: noarch BuildArch: noarch
ExclusiveArch: %{rust_arches} noarch ExclusiveArch: %{rust_arches} noarch
@ -78,6 +80,9 @@ py.test-%{python3_version} -vv test.py
%{python3_sitelib}/rust2rpm/ %{python3_sitelib}/rust2rpm/
%changelog %changelog
* Fri Jun 22 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 5-8
- Various improvements for %%cargo_* macros
* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 5-7 * Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 5-7
- Rebuilt for Python 3.7 - Rebuilt for Python 3.7

Loading…
Cancel
Save