mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 05:35:20 +00:00
rpm: Extend spec to support aarch64 and more
Refactoring and features in this patch: - Add support for aarch64 build - Add offline build configuration using vendored crates - Add script to generate vendored sources - Fix openssl-sys dependency Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
parent
e52175c2ab
commit
d0798aad59
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@
|
|||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
**/Cargo.lock
|
**/Cargo.lock
|
||||||
**/rusty-tags.vi
|
**/rusty-tags.vi
|
||||||
|
/rpm/SOURCES
|
||||||
|
@ -1,25 +1,32 @@
|
|||||||
# This spec file assumes you're building on an environment where:
|
# If this flag is set to 1, rustup installation needs to exist on the system and
|
||||||
# * You have access to the internet during the build
|
# <arch>-unknown-linux-gnu target is required.
|
||||||
# * You have rustup installed on your system
|
# If this flag is set to 0, distro specific Rust packages will be pulled into the build environment.
|
||||||
# * You have both x86_64-unknown-linux-gnu and x86_64-unknown-linux-musl
|
|
||||||
# targets installed.
|
|
||||||
|
|
||||||
%define using_rustup 1
|
%define using_rustup 1
|
||||||
|
# If this flag is set to 1, <arch>-unknown-linux-musl target is required.
|
||||||
%define using_musl_libc 1
|
%define using_musl_libc 1
|
||||||
|
# If this flag is set to 1, the vendored crates archive and cargo.toml need to be prepared and
|
||||||
|
# offline build is implied. Attached script update_src can be used for the vendorization.
|
||||||
|
# If this flag is set to 0, access to the internet is required during the build.
|
||||||
|
%define using_vendored_crates 0
|
||||||
|
|
||||||
Name: cloud-hypervisor
|
Name: cloud-hypervisor
|
||||||
Summary: Cloud Hypervisor is an open source Virtual Machine Monitor (VMM) that runs on top of KVM.
|
Summary: Cloud Hypervisor is an open source Virtual Machine Monitor (VMM) that runs on top of KVM.
|
||||||
Version: 23.0
|
Version: 23.1
|
||||||
Release: 0%{?dist}
|
Release: 0%{?dist}
|
||||||
License: ASL 2.0 or BSD-3-clause
|
License: ASL 2.0 or BSD-3-clause
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
Source0: https://github.com/cloud-hypervisor/cloud-hypervisor/archive/v%{version}.tar.gz
|
Source0: https://github.com/cloud-hypervisor/cloud-hypervisor/archive/v%{version}.tar.gz
|
||||||
ExclusiveArch: x86_64
|
%if 0%{?using_vendored_crates}
|
||||||
|
Source1: vendor.tar.gz
|
||||||
|
Source2: config.toml
|
||||||
|
%endif
|
||||||
|
ExclusiveArch: x86_64 aarch64
|
||||||
|
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
BuildRequires: glibc-devel
|
BuildRequires: glibc-devel
|
||||||
BuildRequires: binutils
|
BuildRequires: binutils
|
||||||
BuildRequires: git
|
BuildRequires: git
|
||||||
|
BuildRequires: openssl-devel
|
||||||
|
|
||||||
%if ! 0%{?using_rustup}
|
%if ! 0%{?using_rustup}
|
||||||
BuildRequires: rust
|
BuildRequires: rust
|
||||||
@ -31,29 +38,51 @@ Requires: glibc
|
|||||||
Requires: libgcc
|
Requires: libgcc
|
||||||
Requires: libcap
|
Requires: libcap
|
||||||
|
|
||||||
|
%ifarch x86_64
|
||||||
|
%define rust_def_target x86_64-unknown-linux-gnu
|
||||||
|
%if 0%{?using_musl_libc}
|
||||||
|
%define rust_musl_target x86_64-unknown-linux-musl
|
||||||
|
%endif
|
||||||
|
%endif
|
||||||
|
%ifarch aarch64
|
||||||
|
%define rust_def_target aarch64-unknown-linux-gnu
|
||||||
|
%if 0%{?using_musl_libc}
|
||||||
|
%define rust_musl_target aarch64-unknown-linux-musl
|
||||||
|
%endif
|
||||||
|
%endif
|
||||||
|
|
||||||
|
%if 0%{?using_vendored_crates}
|
||||||
|
%define cargo_offline --offline
|
||||||
|
%endif
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Cloud Hypervisor is an open source Virtual Machine Monitor (VMM) that runs on top of KVM. The project focuses on exclusively running modern, cloud workloads, on top of a limited set of hardware architectures and platforms. Cloud workloads refers to those that are usually run by customers inside a cloud provider. For our purposes this means modern Linux* distributions with most I/O handled by paravirtualised devices (i.e. virtio), no requirement for legacy devices and recent CPUs and KVM.
|
Cloud Hypervisor is an open source Virtual Machine Monitor (VMM) that runs on top of KVM. The project focuses on exclusively running modern, cloud workloads, on top of a limited set of hardware architectures and platforms. Cloud workloads refers to those that are usually run by customers inside a cloud provider. For our purposes this means modern Linux* distributions with most I/O handled by paravirtualised devices (i.e. virtio), no requirement for legacy devices and recent CPUs and KVM.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
|
|
||||||
%setup -q
|
%setup -q
|
||||||
|
%if 0%{?using_vendored_crates}
|
||||||
|
tar xf %{SOURCE1}
|
||||||
|
mkdir -p .cargo
|
||||||
|
cp %{SOURCE2} .cargo/
|
||||||
|
%endif
|
||||||
|
|
||||||
%install
|
%install
|
||||||
rm -rf %{buildroot}
|
rm -rf %{buildroot}
|
||||||
install -d %{buildroot}%{_bindir}
|
install -d %{buildroot}%{_bindir}
|
||||||
install -D -m755 ./target/x86_64-unknown-linux-gnu/release/cloud-hypervisor %{buildroot}%{_bindir}
|
install -D -m755 ./target/%{rust_def_target}/release/cloud-hypervisor %{buildroot}%{_bindir}
|
||||||
install -D -m755 ./target/x86_64-unknown-linux-gnu/release/ch-remote %{buildroot}%{_bindir}
|
install -D -m755 ./target/%{rust_def_target}/release/ch-remote %{buildroot}%{_bindir}
|
||||||
install -d %{buildroot}%{_libdir}
|
install -d %{buildroot}%{_libdir}
|
||||||
install -d %{buildroot}%{_libdir}/cloud-hypervisor
|
install -d %{buildroot}%{_libdir}/cloud-hypervisor
|
||||||
install -D -m755 target/x86_64-unknown-linux-gnu/release/vhost_user_block %{buildroot}%{_libdir}/cloud-hypervisor
|
install -D -m755 target/%{rust_def_target}/release/vhost_user_block %{buildroot}%{_libdir}/cloud-hypervisor
|
||||||
install -D -m755 target/x86_64-unknown-linux-gnu/release/vhost_user_net %{buildroot}%{_libdir}/cloud-hypervisor
|
install -D -m755 target/%{rust_def_target}/release/vhost_user_net %{buildroot}%{_libdir}/cloud-hypervisor
|
||||||
|
|
||||||
%if 0%{?using_musl_libc}
|
%if 0%{?using_musl_libc}
|
||||||
install -d %{buildroot}%{_libdir}/cloud-hypervisor/static
|
install -d %{buildroot}%{_libdir}/cloud-hypervisor/static
|
||||||
install -D -m755 target/x86_64-unknown-linux-musl/release/cloud-hypervisor %{buildroot}%{_libdir}/cloud-hypervisor/static
|
install -D -m755 target/%{rust_musl_target}/release/cloud-hypervisor %{buildroot}%{_libdir}/cloud-hypervisor/static
|
||||||
install -D -m755 target/x86_64-unknown-linux-musl/release/vhost_user_block %{buildroot}%{_libdir}/cloud-hypervisor/static
|
install -D -m755 target/%{rust_musl_target}/release/vhost_user_block %{buildroot}%{_libdir}/cloud-hypervisor/static
|
||||||
install -D -m755 target/x86_64-unknown-linux-musl/release/vhost_user_net %{buildroot}%{_libdir}/cloud-hypervisor/static
|
install -D -m755 target/%{rust_musl_target}/release/vhost_user_net %{buildroot}%{_libdir}/cloud-hypervisor/static
|
||||||
install -D -m755 target/x86_64-unknown-linux-musl/release/ch-remote %{buildroot}%{_libdir}/cloud-hypervisor/static
|
install -D -m755 target/%{rust_musl_target}/release/ch-remote %{buildroot}%{_libdir}/cloud-hypervisor/static
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
|
||||||
@ -74,21 +103,25 @@ fi
|
|||||||
echo ${cargo_version}
|
echo ${cargo_version}
|
||||||
|
|
||||||
%if 0%{?using_rustup}
|
%if 0%{?using_rustup}
|
||||||
rustup target list --installed | grep x86_64-unknown-linux-gnu
|
rustup target list --installed | grep -e "%{rust_def_target}"
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
echo "Target x86_64-unknown-linux-gnu not found, please install(#rustup target add x86_64-unknown-linux-gnu). exiting"
|
echo "Target %{rust_def_target} not found, please install(#rustup target add %{rust_def_target}). exiting"
|
||||||
fi
|
fi
|
||||||
%if 0%{?using_musl_libc}
|
%if 0%{?using_musl_libc}
|
||||||
rustup target list --installed | grep x86_64-unknown-linux-musl
|
rustup target list --installed | grep -e "%{rust_musl_target}"
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
echo "Target x86_64-unknown-linux-musl not found, please install(#rustup target add x86_64-unknown-linux-musl). exiting"
|
echo "Target %{rust_musl_target} not found, please install(#rustup target add %{rust_musl_target}). exiting"
|
||||||
fi
|
fi
|
||||||
%endif
|
%endif
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
cargo build --release --target=x86_64-unknown-linux-gnu --all
|
%if 0%{?using_vendored_crates}
|
||||||
|
# For vendored build, prepend this so openssl-sys doesn't trigger full OpenSSL build
|
||||||
|
export OPENSSL_NO_VENDOR=1
|
||||||
|
%endif
|
||||||
|
cargo build --release --target=%{rust_def_target} --all %{cargo_offline}
|
||||||
%if 0%{?using_musl_libc}
|
%if 0%{?using_musl_libc}
|
||||||
cargo build --release --target=x86_64-unknown-linux-musl --all
|
cargo build --release --target=%{rust_musl_target} --all %{cargo_offline}
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
|
||||||
@ -112,6 +145,12 @@ rm -rf %{buildroot}
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue May 18 2022 Anatol Belski <anbelski@linux.microsoft.com> - 23.1-0
|
||||||
|
- Update to 23.1
|
||||||
|
- Add support for aarch64 build
|
||||||
|
- Add offline build configuration using vendored crates
|
||||||
|
- Fix dependency for openssl-sys
|
||||||
|
|
||||||
* Thu Apr 13 2022 Rob Bradford <robert.bradford@intel.com> 23.0-0
|
* Thu Apr 13 2022 Rob Bradford <robert.bradford@intel.com> 23.0-0
|
||||||
- Update to 23.0
|
- Update to 23.0
|
||||||
|
|
||||||
|
36
rpm/update_src
Normal file
36
rpm/update_src
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
CH_VER=$1
|
||||||
|
CH_SPEC_DIR=$(pwd)
|
||||||
|
CH_TMP_DIR=$CH_SPEC_DIR/ch_tmp
|
||||||
|
CH_SRC_DIR=$CH_SPEC_DIR/SOURCES
|
||||||
|
|
||||||
|
if [ -z $CH_VER ]; then
|
||||||
|
echo "Replace sources with the given <version>"
|
||||||
|
echo "Usage: $0 <version>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf $CH_TMP_DIR
|
||||||
|
if [ ! -d $CH_SRC_DIR ]; then
|
||||||
|
mkdir $CH_SRC_DIR
|
||||||
|
fi
|
||||||
|
rm -f $CH_SRC_DIR/v*.tar.gz $CH_SRC_DIR/config.toml $CH_SRC_DIR/vendor.tar.gz
|
||||||
|
|
||||||
|
|
||||||
|
wget https://github.com/cloud-hypervisor/cloud-hypervisor/archive/v${CH_VER}.tar.gz -O $CH_SRC_DIR/v${CH_VER}.tar.gz
|
||||||
|
mkdir $CH_TMP_DIR
|
||||||
|
tar xf $CH_SRC_DIR/v${CH_VER}.tar.gz -C $CH_TMP_DIR --strip-components=1
|
||||||
|
|
||||||
|
|
||||||
|
pushd $CH_TMP_DIR
|
||||||
|
|
||||||
|
cargo vendor > $CH_SRC_DIR/config.toml
|
||||||
|
tar czvf $CH_SRC_DIR/vendor.tar.gz vendor
|
||||||
|
|
||||||
|
popd
|
||||||
|
|
||||||
|
rm -rf $CH_TMP_DIR
|
||||||
|
|
Loading…
Reference in New Issue
Block a user