From a628854d9c448589a4930010063726fec1d47883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Mon, 8 Nov 2021 17:41:15 +0100 Subject: [PATCH] rpm: Introduce `using_rustup` definition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `using_rustup` is needed as distros (such as Fedora or RHEL) don't provide the users a way to install`rustup` without conflicting with the distro provided `rust` package. In order to minimize the troubles for those who want to build cloud-hypervisor using the distros packages, let's allow the users to change that variable and then simply rely on their system packages. Signed-off-by: Fabiano FidĂȘncio --- rpm/cloud-hypervisor.spec | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/rpm/cloud-hypervisor.spec b/rpm/cloud-hypervisor.spec index 76c4125a3..f94e123d7 100644 --- a/rpm/cloud-hypervisor.spec +++ b/rpm/cloud-hypervisor.spec @@ -4,6 +4,8 @@ # * You have both x86_64-unknown-linux-gnu and x86_64-unknown-linux-musl # targets installed. +%define using_rustup 1 + Name: cloud-hypervisor Summary: Cloud Hypervisor is an open source Virtual Machine Monitor (VMM) that runs on top of KVM. Version: 19.0 @@ -18,7 +20,7 @@ BuildRequires: glibc-devel BuildRequires: binutils BuildRequires: git -%if 0%{?fedora} || 0%{?rhel} +%if ! 0%{?using_rustup} BuildRequires: rust BuildRequires: cargo %endif @@ -58,11 +60,17 @@ if [[ $? -ne 0 ]]; then echo "Cargo not found, please install cargo. exiting" exit 0 fi + +%if 0%{?using_rustup} which rustup if [[ $? -ne 0 ]]; then echo "Rustup not found please install rustup #curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh" fi +%endif + echo ${cargo_version} + +%if 0%{?using_rustup} rustup target list --installed | grep x86_64-unknown-linux-gnu if [[ $? -ne 0 ]]; then echo "Target x86_64-unknown-linux-gnu not found, please install(#rustup target add x86_64-unknown-linux-gnu). exiting" @@ -71,6 +79,7 @@ rustup target list --installed | grep x86_64-unknown-linux-musl if [[ $? -ne 0 ]]; then echo "Target x86_64-unknown-linux-musl not found, please install(#rustup target add x86_64-unknown-linux-musl). exiting" fi +%endif cargo build --release --target=x86_64-unknown-linux-gnu --all cargo build --release --target=x86_64-unknown-linux-musl --all