From a23a0f036b96650216758d354499cbc60ef55b27 Mon Sep 17 00:00:00 2001 From: Sohan Kunkerkar Date: Tue, 12 Oct 2021 13:59:11 -0400 Subject: [PATCH] Vendor rust dependencies on RHEL only & add coreos-installer-dracut subpackage --- .gitignore | 1 + rust-coreos-installer.spec | 74 +++++++++++++++++++++++++++++++++++--- sources | 1 + 3 files changed, 71 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 6434450..00b1e23 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ /coreos-installer-0.9.1.crate /coreos-installer-0.10.0.crate /coreos-installer-0.10.1.crate +/coreos-installer-dracut-bbefcb8.tar.gz diff --git a/rust-coreos-installer.spec b/rust-coreos-installer.spec index 2b1e16e..639893d 100644 --- a/rust-coreos-installer.spec +++ b/rust-coreos-installer.spec @@ -5,6 +5,9 @@ # The library is for internal code reuse and is not a public API %global __cargo_is_lib 0 +%global dracutcommit bbefcb88b9ea092be68baf191849a349b09a1f3b +%global dracutshortcommit %(c=%{dracutcommit}; echo ${c:0:7}) + %global crate coreos-installer Name: rust-%{crate} @@ -15,11 +18,23 @@ Summary: Installer for Fedora CoreOS and RHEL CoreOS # Upstream license specification: Apache-2.0 License: ASL 2.0 URL: https://crates.io/crates/coreos-installer -Source: %{crates_source} +%if 0%{?rhel} && !0%{?eln} +Source0: https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{crate}-%{version}.crate +Source1: https://github.com/coreos/%{crate}/releases/download/v%{version}/%{crate}-%{version}-vendor.tar.gz +%else +Source0: %{crates_source} +%endif +Source2: https://github.com/coreos/coreos-installer-dracut/archive/%{dracutcommit}/coreos-installer-dracut-%{dracutshortcommit}.tar.gz ExclusiveArch: %{rust_arches} - +%if 0%{?rhel} && !0%{?eln} +BuildRequires: rust-toolset +BuildRequires: openssl-devel +# To ensure we're not bundling system libraries +BuildRequires: xz-devel +%else BuildRequires: rust-packaging +%endif BuildRequires: systemd-rpm-macros # For tests BuildRequires: gnupg2 @@ -71,19 +86,49 @@ Obsoletes: coreos-installer-dracut < 0.0.1 %{_bindir}/coreos-installer %prep -%autosetup -n %{crate}-%{version_no_tilde} -p1 +%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 +%else %cargo_prep +%endif # Fix SIGSEGV in tests on s390x # https://bugzilla.redhat.com/show_bug.cgi?id=1883457 sed -i 's/"-Ccodegen-units=1",//' .cargo/config +%if !0%{?rhel} || 0%{?eln} %generate_buildrequires %cargo_generate_buildrequires -f rdcore +%endif %build +%if 0%{?rhel} && !0%{?eln} +%cargo_build +%else %cargo_build -f rdcore +%endif %install +%if 0%{?rhel} && !0%{?eln} +%make_install +# 51coreos-installer for coreos-installer-dracut +install -D -m 0755 -t %{buildroot}%{dracutlibdir}/modules.d/51coreos-installer coreos-installer-dracut-%{dracutcommit}/dracut/51coreos-installer/module-setup.sh +install -D -m 0755 -t %{buildroot}%{dracutlibdir}/modules.d/51coreos-installer coreos-installer-dracut-%{dracutcommit}/dracut/scripts/coreos-installer-service +install -D -m 0755 -t %{buildroot}%{dracutlibdir}/modules.d/51coreos-installer coreos-installer-dracut-%{dracutcommit}/dracut/scripts/coreos-installer-growfs +install -D -m 0644 -t %{buildroot}%{dracutlibdir}/modules.d/51coreos-installer coreos-installer-dracut-%{dracutcommit}/dracut/systemd/coreos-installer.service +install -D -m 0644 -t %{buildroot}%{dracutlibdir}/modules.d/51coreos-installer coreos-installer-dracut-%{dracutcommit}/dracut/systemd/coreos-installer-growfs.service +install -D -m 0644 -t %{buildroot}%{dracutlibdir}/modules.d/51coreos-installer coreos-installer-dracut-%{dracutcommit}/dracut/systemd/coreos-installer-reboot.service +install -D -m 0644 -t %{buildroot}%{dracutlibdir}/modules.d/51coreos-installer coreos-installer-dracut-%{dracutcommit}/dracut/systemd/coreos-installer-noreboot.service +install -D -m 0755 -t %{buildroot}%{dracutlibdir}/modules.d/51coreos-installer coreos-installer-dracut-%{dracutcommit}/dracut/systemd/coreos-installer-generator +%else %cargo_install -f rdcore # Install binaries, dracut modules, units, targets, generators for running via systemd install -D -m 0755 -t %{buildroot}%{dracutlibdir}/modules.d/50rdcore dracut/50rdcore/module-setup.sh @@ -98,6 +143,7 @@ install -D -m 0644 -t %{buildroot}%{_unitdir} systemd/coreos-installer.target install -D -m 0644 -t %{buildroot}%{_unitdir} systemd/coreos-installer-post.target install -D -m 0755 -t %{buildroot}%{_systemdgeneratordir} systemd/coreos-installer-generator mv %{buildroot}%{_bindir}/rdcore %{buildroot}%{dracutlibdir}/modules.d/50rdcore/ +%endif %package -n %{crate}-bootinfra Summary: %{crate} boot-time infrastructure for use on Fedora/RHEL CoreOS @@ -124,14 +170,32 @@ RHEL CoreOS. It is not needed on other platforms. %{_unitdir}/* %{_systemdgeneratordir}/* +%if 0%{?rhel} && !0%{?eln} +%package -n %{crate}-dracut +Summary: Dracut module for running coreos-installer in the initrd +Requires: %{crate} = %{version}-%{release} + +%description -n %{crate}-dracut +This subpackage contains files and configuration to run coreos-installer +from the initramfs. + +%files -n %{crate}-dracut +%{dracutlibdir}/modules.d/51coreos-installer/* +%endif + %if %{with check} %check +%if 0%{?rhel} && !0%{?eln} +%cargo_test +%else %cargo_test -f rdcore %endif +%endif %changelog -* Tue Oct 12 2021 Benjamin Gilbert - 0.10.1-2 -- Rebuild for F33 bump +* Thu Nov 04 2021 Sohan Kunkerkar - 0.10.1-2 +- Vendor rust dependencies on RHEL only +- Add coreos-installer-dracut subpackage on RHEL only * Mon Oct 11 2021 Benjamin Gilbert - 0.10.1-1 - New release diff --git a/sources b/sources index 6e09a04..3173bf9 100644 --- a/sources +++ b/sources @@ -1 +1,2 @@ SHA512 (coreos-installer-0.10.1.crate) = 33ca2d4d13ce6a0c42b4f2b8ef0206e8dd1a91b377363ce908f265540b40653be7e3d0baa0cd0b308877be656c3bfd40d1a368f94da2b619f71f5ba635af9076 +SHA512 (coreos-installer-dracut-bbefcb8.tar.gz) = 79336d4cf779e4acfa012381de9ca7438345c9019b0a27fddbaf8df16333709d93a0fa4be6ff5e62d83cc2004bf5e5d9b189e49ef8c8eb9f04f1a713b62530f8