Provide rust-srpm-macros in RHEL
rust-srpm-macros is a dependency of redhat-rpm-config so that Rust-based SRPMs can rely on these particular macros. In RHEL 9 and earlier, rust-srpm-macros was a separate source package which was included in RHEL. Since then, it became a subpackage of rust-packaging in Fedora. In order to not pull in any part of rust-packaging into RHEL 10, thereby allowing it to be maintained separately in EPEL, those macros are provided here instead.
This commit is contained in:
parent
6c6aaa4382
commit
8c1ae0e762
62
macros.rust-srpm
Normal file
62
macros.rust-srpm
Normal file
@ -0,0 +1,62 @@
|
||||
# rust_arches: list of architectures where building Rust is supported
|
||||
#
|
||||
# Since RPM itself now depends on Rust code (via its GPG backend, rpm-sequoia),
|
||||
# this list will probably always be a superset of all architectures that are
|
||||
# supported by Fedora, which is why it is no longer required to set
|
||||
# "ExclusiveArch: rust_arches" for Rust packages in Fedora.
|
||||
%rust_arches x86_64 %{ix86} armv7hl aarch64 ppc64 ppc64le riscv64 s390x
|
||||
|
||||
# version_no_tilde: lua macro for reconstructing the original crate version
|
||||
# from the RPM version (i.e. replace any "~" characters with "-")
|
||||
%version_no_tilde() %{lua:
|
||||
local sep = rpm.expand('%1')
|
||||
local ver = rpm.expand('%2')
|
||||
\
|
||||
if sep == '%1' then
|
||||
sep = '-'
|
||||
end
|
||||
\
|
||||
if ver == '%2' then
|
||||
ver = rpm.expand('%version')
|
||||
end
|
||||
ver = ver:gsub('~', sep)
|
||||
\
|
||||
print(ver)
|
||||
}
|
||||
|
||||
# __crates_url: default API endpoint for downloading .crate files from crates.io
|
||||
%__crates_url https://crates.io/api/v1/crates/
|
||||
|
||||
# crates_source: lua macro for constructing the Source URL for a crate
|
||||
%crates_source() %{lua:
|
||||
local crate = rpm.expand('%1')
|
||||
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('%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')
|
||||
}
|
||||
|
||||
# __cargo_skip_build: unused macro, set to 0 for backwards compatibility
|
||||
%__cargo_skip_build 0
|
||||
|
13
rust.spec
13
rust.spec
@ -125,6 +125,7 @@ Patch6: 0001-bootstrap-only-show-PGO-warnings-when-verbose.patch
|
||||
|
||||
# Simple rpm macros for rust-toolset (as opposed to full rust-packaging)
|
||||
Source100: macros.rust-toolset
|
||||
Source101: macros.rust-srpm
|
||||
|
||||
# Disable cargo->libgit2->libssh2 on RHEL, as it's not approved for FIPS (rhbz1732949)
|
||||
Patch100: rustc-1.75.0-disable-libssh2.patch
|
||||
@ -520,6 +521,14 @@ useful as a reference for code completion tools in various editors.
|
||||
|
||||
%if 0%{?rhel}
|
||||
|
||||
%package srpm-macros
|
||||
Summary: RPM macros for building Rust source packages
|
||||
BuildArch: noarch
|
||||
|
||||
%description srpm-macros
|
||||
RPM macros for building source packages for Rust projects.
|
||||
|
||||
|
||||
%package toolset
|
||||
Summary: Rust Toolset
|
||||
BuildArch: noarch
|
||||
@ -848,6 +857,7 @@ rm -f %{buildroot}%{rustlibdir}/%{rust_triple}/bin/rust-ll*
|
||||
%if 0%{?rhel}
|
||||
# This allows users to build packages using Rust Toolset.
|
||||
%{__install} -D -m 644 %{S:100} %{buildroot}%{rpmmacrodir}/macros.rust-toolset
|
||||
%{__install} -D -m 644 %{S:101} %{buildroot}%{rpmmacrodir}/macros.rust-srpm
|
||||
%endif
|
||||
|
||||
|
||||
@ -1027,6 +1037,9 @@ rm -rf "./build/%{rust_triple}/stage2-tools/%{rust_triple}/cit/"
|
||||
|
||||
|
||||
%if 0%{?rhel}
|
||||
%files srpm-macros
|
||||
%{rpmmacrodir}/macros.rust-srpm
|
||||
|
||||
%files toolset
|
||||
%{rpmmacrodir}/macros.rust-toolset
|
||||
%endif
|
||||
|
Loading…
Reference in New Issue
Block a user