From 0ff9bb855cf6be46f26801d00dd8c057a11eecd9 Mon Sep 17 00:00:00 2001
From: Yaakov Selkowitz <yselkowi@redhat.com>
Date: Aug 17 2023 17:33:17 +0000
Subject: Correct %__cargo and %__cargo_to_rpm paths


%{_bindir} should not be used like this in specfiles or macros. It
breaks flatpak builds.

Relates: https://docs.fedoraproject.org/en-US/packaging-guidelines/#_file_and_directory_dependencies

---

diff --git a/fileattrs/cargo.attr b/fileattrs/cargo.attr
index b97383d..0dabe9b 100644
--- a/fileattrs/cargo.attr
+++ b/fileattrs/cargo.attr
@@ -1,3 +1,3 @@
-%__cargo_provides  %{_bindir}/cargo2rpm provides --subpackage --feature=%{name}
-%__cargo_requires  %{_bindir}/cargo2rpm requires --subpackage --feature=%{name}
+%__cargo_provides  /usr/bin/cargo2rpm provides --subpackage --feature=%{name}
+%__cargo_requires  /usr/bin/cargo2rpm requires --subpackage --feature=%{name}
 %__cargo_path      ^%{cargo_registry}/[^/]+/Cargo\\.toml$
diff --git a/macros.d/macros.cargo b/macros.d/macros.cargo
index 672ae06..147a7ca 100644
--- a/macros.d/macros.cargo
+++ b/macros.d/macros.cargo
@@ -6,7 +6,7 @@
 #       features that have not been stabilized yet, i.e. the
 #       "-Z avoid-dev-deps" flag which is passed to cargo by the cargo_build,
 #       cargo_install, and cargo_test macros.
-%__cargo %{_bindir}/env CARGO_HOME=.cargo RUSTC_BOOTSTRAP=1 RUSTFLAGS='%{build_rustflags}' %{_bindir}/cargo
+%__cargo /usr/bin/env CARGO_HOME=.cargo RUSTC_BOOTSTRAP=1 RUSTFLAGS='%{build_rustflags}' /usr/bin/cargo
 
 # __cargo_common_opts: common command line flags for cargo
 #
@@ -22,7 +22,7 @@
 %__cargo_common_opts %{?_smp_mflags} -Z avoid-dev-deps
 
 # __cargo_to_rpm: path to the default cargo2rpm executable
-%__cargo_to_rpm %{_bindir}/cargo2rpm
+%__cargo_to_rpm /usr/bin/cargo2rpm
 
 # cargo_registry: path to the root of the directory-based "local cargo registry"
 #       with replaces the "crates.io" source

