Fix RHEL/ELN builds

The eln macro requires ELN SIG approval, and there is no need to differ
from RHEL here.  More importantly, we don't want the dynamic
buildrequires in ELN either.

RHEL/ELN cargo macros do not support -f, so import the RHEL/c9s patch
which adds rdcore to the default features.

While we're at it, use the RHEL %%cargo_prep -V to handle vendoring
rather than manually modifing the cargo config.
This commit is contained in:
Yaakov Selkowitz 2023-05-19 18:50:28 -04:00
parent 9bf4babe67
commit 90930c04f1
2 changed files with 24 additions and 16 deletions

11
enable-rdcore.patch Normal file
View File

@ -0,0 +1,11 @@
diff -ur a/Cargo.toml b/Cargo.toml
--- a/Cargo.toml 1969-12-31 19:00:01.000000000 -0500
+++ b/Cargo.toml 2023-03-14 07:57:14.025021766 -0400
@@ -195,6 +195,7 @@
[features]
docgen = ["dep:clap_mangen"]
+default = ["rdcore"]
rdcore = []
[target."cfg(target_arch = \"s390x\")".dependencies.mbrman]

View File

@ -23,8 +23,12 @@ Source0: https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{
Source1: https://github.com/coreos/%{crate}/releases/download/v%{version}/%{crate}-%{version}-vendor.tar.gz
Source2: https://github.com/coreos/coreos-installer-dracut/archive/%{dracutcommit}/coreos-installer-dracut-%{dracutshortcommit}.tar.gz
## RHEL specific patches
# enable rdcore in default feature set (RHEL macros do not take -f)
Patch1000: enable-rdcore.patch
ExclusiveArch: %{rust_arches}
%if 0%{?rhel} && !0%{?eln}
%if 0%{?rhel}
BuildRequires: rust-toolset
BuildRequires: openssl-devel
# To ensure we're not bundling system libraries
@ -79,17 +83,10 @@ Obsoletes: coreos-installer-dracut < 0.0.1
%description -n %{crate} %{_description}
%prep
%autosetup -n %{crate}-%{version} -p1 -a 2
%if 0%{?rhel} && !0%{?eln}
tar xvf %{SOURCE1}
mkdir -p .cargo
cat >.cargo/config << EOF
[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"
EOF
%autosetup -n %{crate}-%{version} -N -a 2
%autopatch -p1 %{?!rhel:-M 999}
%if 0%{?rhel}
%cargo_prep -V 1
%else
%cargo_prep
%endif
@ -97,20 +94,20 @@ EOF
# https://bugzilla.redhat.com/show_bug.cgi?id=1883457
sed -i 's/"-Ccodegen-units=1",//' .cargo/config
%if !0%{?rhel} || 0%{?eln}
%if !0%{?rhel}
%generate_buildrequires
%cargo_generate_buildrequires -f rdcore
%endif
%build
%if 0%{?rhel} && !0%{?eln}
%if 0%{?rhel}
%cargo_build
%else
%cargo_build -f rdcore
%endif
%install
%if 0%{?rhel} && !0%{?eln}
%if 0%{?rhel}
%make_install RELEASE=1
%else
%cargo_install -f rdcore
@ -172,7 +169,7 @@ from the initramfs in IoT/Edge and is supported by the community.
%if %{with check}
%check
%if 0%{?rhel} && !0%{?eln}
%if 0%{?rhel}
%cargo_test
%else
%cargo_test -f rdcore