cloud-hypervisor/rpm/cloud-hypervisor.spec

180 lines
6.1 KiB
RPMSpec
Raw Normal View History

# If this flag is set to 1, rustup installation needs to exist on the system and
# <arch>-unknown-linux-gnu target is required.
# If this flag is set to 0, distro specific Rust packages will be pulled into the build environment.
%define using_rustup 1
# If this flag is set to 1, <arch>-unknown-linux-musl target is required.
%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
Summary: Cloud Hypervisor is an open source Virtual Machine Monitor (VMM) that runs on top of KVM.
Version: 25.0
Release: 0%{?dist}
License: ASL 2.0 or BSD-3-clause
Group: Applications/System
Source0: https://github.com/cloud-hypervisor/cloud-hypervisor/archive/v%{version}.tar.gz
%if 0%{?using_vendored_crates}
Source1: vendor.tar.gz
Source2: config.toml
%endif
ExclusiveArch: x86_64 aarch64
BuildRequires: gcc
BuildRequires: glibc-devel
BuildRequires: binutils
BuildRequires: git
BuildRequires: openssl-devel
%if ! 0%{?using_rustup}
BuildRequires: rust
BuildRequires: cargo
%endif
Requires: bash
Requires: glibc
Requires: libgcc
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
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
%setup -q
%if 0%{?using_vendored_crates}
tar xf %{SOURCE1}
mkdir -p .cargo
cp %{SOURCE2} .cargo/
%endif
%install
rm -rf %{buildroot}
install -d %{buildroot}%{_bindir}
install -D -m755 ./target/%{rust_def_target}/release/cloud-hypervisor %{buildroot}%{_bindir}
install -D -m755 ./target/%{rust_def_target}/release/ch-remote %{buildroot}%{_bindir}
install -d %{buildroot}%{_libdir}
install -d %{buildroot}%{_libdir}/cloud-hypervisor
install -D -m755 target/%{rust_def_target}/release/vhost_user_block %{buildroot}%{_libdir}/cloud-hypervisor
install -D -m755 target/%{rust_def_target}/release/vhost_user_net %{buildroot}%{_libdir}/cloud-hypervisor
%if 0%{?using_musl_libc}
install -d %{buildroot}%{_libdir}/cloud-hypervisor/static
install -D -m755 target/%{rust_musl_target}/release/cloud-hypervisor %{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/%{rust_musl_target}/release/vhost_user_net %{buildroot}%{_libdir}/cloud-hypervisor/static
install -D -m755 target/%{rust_musl_target}/release/ch-remote %{buildroot}%{_libdir}/cloud-hypervisor/static
%endif
%build
cargo_version=$(cargo --version)
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 -e "%{rust_def_target}"
if [[ $? -ne 0 ]]; then
echo "Target %{rust_def_target} not found, please install(#rustup target add %{rust_def_target}). exiting"
fi
%if 0%{?using_musl_libc}
rustup target list --installed | grep -e "%{rust_musl_target}"
if [[ $? -ne 0 ]]; then
echo "Target %{rust_musl_target} not found, please install(#rustup target add %{rust_musl_target}). exiting"
fi
%endif
%endif
%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}
cargo build --release --target=%{rust_musl_target} --all %{cargo_offline}
%endif
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
%{_bindir}/ch-remote
rpm: Don't set cap_net_admin via %post OSTree based systems (such as Fedora CoreOS) behave differently than yum based systems (such as Fedora) with regarding to the RPM installations. While the latter will install the RPM on the running system, modifying it; the former will be layered (installed in a "chroot") and only will be present on the system after the user boots this layer up. While in theory there shouldn't be much differences on the installation itself, when installing cloud-hypervisor on RHCOS, the following issue would be seen: ``` $ sudo sudo rpm-ostree install cloud-hypervisor Checking out tree 9c1cdf9... done Enabled rpm-md repositories: copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor Updating metadata for 'copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor'... done rpm-md repo 'copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor'; generated: 2021-11-08T19:02:32Z Importing rpm-md... done Resolving dependencies... done Will download: 1 package (3.1 MB) Downloading from 'copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor'... done Importing packages... done Checking out packages... done Running pre scripts... done Running post scripts... done error: Running %post for cloud-hypervisor: Executing bwrap(/bin/sh): Child process killed by signal 1; run `journalctl -t 'rpm-ostree(cloud-hypervisor.post)'` for more information $ sudo journalctl -t 'rpm-ostree(cloud-hypervisor.post)' -- Logs begin at Fri 2021-11-12 12:18:33 UTC, end at Fri 2021-11-12 12:22:55 UTC. -- Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: Failed to set capabilities on file `/usr/bin/cloud-hypervisor' (Operation not supported) Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: usage: setcap [-q] [-v] [-n <rootid>] (-r|-|<caps>) <filename> [ ... (-r|-|<capsN>) <filenameN> ] Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: Note <filename> must be a regular (non-symlink) file. Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: Failed to set capabilities on file `/usr/lib64/cloud-hypervisor/vhost_user_net' (Operation not supported) Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: usage: setcap [-q] [-v] [-n <rootid>] (-r|-|<caps>) <filename> [ ... (-r|-|<capsN>) <filenameN> ] Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: Note <filename> must be a regular (non-symlink) file. ``` It seems to happen as the "chroot" where the package is installed does not have enough privileges to set the binaries capabilities during the `%post` step. Considering this, and also considering that calling `setcap` during `%post` may not be the most elegant solution when speaking RPM spec files, let's take advantage of the already existent `%caps()` directive for the `%files` list to do so. With that change applied, cloud-hypervisor could be successfully installed on RHCOS, as shown below: ``` $ sudo rpm-ostree install cloud-hypervisor-19.0-2.el8.x86_64.rpm Checking out tree 9c1cdf9... done Enabled rpm-md repositories: copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor rpm-md repo 'copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor' (cached); generated: 2021-11-08T19:02:32Z Importing rpm-md... done Resolving dependencies... done Checking out packages... done Running pre scripts... done Running post scripts... done Running posttrans scripts... done Writing rpmdb... done Writing OSTree commit... done Staging deployment... done Freed: 18.2 MB (pkgcache branches: 2) Added: cloud-hypervisor-19.0-2.el8.x86_64 Run "systemctl reboot" to start a reboot ... $ getcap /usr/bin/cloud-hypervisor /usr/bin/cloud-hypervisor = cap_net_admin+ep $ getcap /usr/lib64/cloud-hypervisor/vhost_user_net /usr/lib64/cloud-hypervisor/vhost_user_net = cap_net_admin+ep ``` Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2021-11-12 13:45:32 +00:00
%caps(cap_net_admin=ep) %{_bindir}/cloud-hypervisor
%{_libdir}/cloud-hypervisor/vhost_user_block
rpm: Don't set cap_net_admin via %post OSTree based systems (such as Fedora CoreOS) behave differently than yum based systems (such as Fedora) with regarding to the RPM installations. While the latter will install the RPM on the running system, modifying it; the former will be layered (installed in a "chroot") and only will be present on the system after the user boots this layer up. While in theory there shouldn't be much differences on the installation itself, when installing cloud-hypervisor on RHCOS, the following issue would be seen: ``` $ sudo sudo rpm-ostree install cloud-hypervisor Checking out tree 9c1cdf9... done Enabled rpm-md repositories: copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor Updating metadata for 'copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor'... done rpm-md repo 'copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor'; generated: 2021-11-08T19:02:32Z Importing rpm-md... done Resolving dependencies... done Will download: 1 package (3.1 MB) Downloading from 'copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor'... done Importing packages... done Checking out packages... done Running pre scripts... done Running post scripts... done error: Running %post for cloud-hypervisor: Executing bwrap(/bin/sh): Child process killed by signal 1; run `journalctl -t 'rpm-ostree(cloud-hypervisor.post)'` for more information $ sudo journalctl -t 'rpm-ostree(cloud-hypervisor.post)' -- Logs begin at Fri 2021-11-12 12:18:33 UTC, end at Fri 2021-11-12 12:22:55 UTC. -- Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: Failed to set capabilities on file `/usr/bin/cloud-hypervisor' (Operation not supported) Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: usage: setcap [-q] [-v] [-n <rootid>] (-r|-|<caps>) <filename> [ ... (-r|-|<capsN>) <filenameN> ] Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: Note <filename> must be a regular (non-symlink) file. Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: Failed to set capabilities on file `/usr/lib64/cloud-hypervisor/vhost_user_net' (Operation not supported) Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: usage: setcap [-q] [-v] [-n <rootid>] (-r|-|<caps>) <filename> [ ... (-r|-|<capsN>) <filenameN> ] Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: Note <filename> must be a regular (non-symlink) file. ``` It seems to happen as the "chroot" where the package is installed does not have enough privileges to set the binaries capabilities during the `%post` step. Considering this, and also considering that calling `setcap` during `%post` may not be the most elegant solution when speaking RPM spec files, let's take advantage of the already existent `%caps()` directive for the `%files` list to do so. With that change applied, cloud-hypervisor could be successfully installed on RHCOS, as shown below: ``` $ sudo rpm-ostree install cloud-hypervisor-19.0-2.el8.x86_64.rpm Checking out tree 9c1cdf9... done Enabled rpm-md repositories: copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor rpm-md repo 'copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor' (cached); generated: 2021-11-08T19:02:32Z Importing rpm-md... done Resolving dependencies... done Checking out packages... done Running pre scripts... done Running post scripts... done Running posttrans scripts... done Writing rpmdb... done Writing OSTree commit... done Staging deployment... done Freed: 18.2 MB (pkgcache branches: 2) Added: cloud-hypervisor-19.0-2.el8.x86_64 Run "systemctl reboot" to start a reboot ... $ getcap /usr/bin/cloud-hypervisor /usr/bin/cloud-hypervisor = cap_net_admin+ep $ getcap /usr/lib64/cloud-hypervisor/vhost_user_net /usr/lib64/cloud-hypervisor/vhost_user_net = cap_net_admin+ep ``` Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2021-11-12 13:45:32 +00:00
%caps(cap_net_admin=ep) %{_libdir}/cloud-hypervisor/vhost_user_net
%if 0%{?using_musl_libc}
%{_libdir}/cloud-hypervisor/static/ch-remote
rpm: Don't set cap_net_admin via %post OSTree based systems (such as Fedora CoreOS) behave differently than yum based systems (such as Fedora) with regarding to the RPM installations. While the latter will install the RPM on the running system, modifying it; the former will be layered (installed in a "chroot") and only will be present on the system after the user boots this layer up. While in theory there shouldn't be much differences on the installation itself, when installing cloud-hypervisor on RHCOS, the following issue would be seen: ``` $ sudo sudo rpm-ostree install cloud-hypervisor Checking out tree 9c1cdf9... done Enabled rpm-md repositories: copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor Updating metadata for 'copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor'... done rpm-md repo 'copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor'; generated: 2021-11-08T19:02:32Z Importing rpm-md... done Resolving dependencies... done Will download: 1 package (3.1 MB) Downloading from 'copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor'... done Importing packages... done Checking out packages... done Running pre scripts... done Running post scripts... done error: Running %post for cloud-hypervisor: Executing bwrap(/bin/sh): Child process killed by signal 1; run `journalctl -t 'rpm-ostree(cloud-hypervisor.post)'` for more information $ sudo journalctl -t 'rpm-ostree(cloud-hypervisor.post)' -- Logs begin at Fri 2021-11-12 12:18:33 UTC, end at Fri 2021-11-12 12:22:55 UTC. -- Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: Failed to set capabilities on file `/usr/bin/cloud-hypervisor' (Operation not supported) Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: usage: setcap [-q] [-v] [-n <rootid>] (-r|-|<caps>) <filename> [ ... (-r|-|<capsN>) <filenameN> ] Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: Note <filename> must be a regular (non-symlink) file. Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: Failed to set capabilities on file `/usr/lib64/cloud-hypervisor/vhost_user_net' (Operation not supported) Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: usage: setcap [-q] [-v] [-n <rootid>] (-r|-|<caps>) <filename> [ ... (-r|-|<capsN>) <filenameN> ] Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: Note <filename> must be a regular (non-symlink) file. ``` It seems to happen as the "chroot" where the package is installed does not have enough privileges to set the binaries capabilities during the `%post` step. Considering this, and also considering that calling `setcap` during `%post` may not be the most elegant solution when speaking RPM spec files, let's take advantage of the already existent `%caps()` directive for the `%files` list to do so. With that change applied, cloud-hypervisor could be successfully installed on RHCOS, as shown below: ``` $ sudo rpm-ostree install cloud-hypervisor-19.0-2.el8.x86_64.rpm Checking out tree 9c1cdf9... done Enabled rpm-md repositories: copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor rpm-md repo 'copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor' (cached); generated: 2021-11-08T19:02:32Z Importing rpm-md... done Resolving dependencies... done Checking out packages... done Running pre scripts... done Running post scripts... done Running posttrans scripts... done Writing rpmdb... done Writing OSTree commit... done Staging deployment... done Freed: 18.2 MB (pkgcache branches: 2) Added: cloud-hypervisor-19.0-2.el8.x86_64 Run "systemctl reboot" to start a reboot ... $ getcap /usr/bin/cloud-hypervisor /usr/bin/cloud-hypervisor = cap_net_admin+ep $ getcap /usr/lib64/cloud-hypervisor/vhost_user_net /usr/lib64/cloud-hypervisor/vhost_user_net = cap_net_admin+ep ``` Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2021-11-12 13:45:32 +00:00
%caps(cap_net_admim=ep) %{_libdir}/cloud-hypervisor/static/cloud-hypervisor
%{_libdir}/cloud-hypervisor/static/vhost_user_block
rpm: Don't set cap_net_admin via %post OSTree based systems (such as Fedora CoreOS) behave differently than yum based systems (such as Fedora) with regarding to the RPM installations. While the latter will install the RPM on the running system, modifying it; the former will be layered (installed in a "chroot") and only will be present on the system after the user boots this layer up. While in theory there shouldn't be much differences on the installation itself, when installing cloud-hypervisor on RHCOS, the following issue would be seen: ``` $ sudo sudo rpm-ostree install cloud-hypervisor Checking out tree 9c1cdf9... done Enabled rpm-md repositories: copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor Updating metadata for 'copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor'... done rpm-md repo 'copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor'; generated: 2021-11-08T19:02:32Z Importing rpm-md... done Resolving dependencies... done Will download: 1 package (3.1 MB) Downloading from 'copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor'... done Importing packages... done Checking out packages... done Running pre scripts... done Running post scripts... done error: Running %post for cloud-hypervisor: Executing bwrap(/bin/sh): Child process killed by signal 1; run `journalctl -t 'rpm-ostree(cloud-hypervisor.post)'` for more information $ sudo journalctl -t 'rpm-ostree(cloud-hypervisor.post)' -- Logs begin at Fri 2021-11-12 12:18:33 UTC, end at Fri 2021-11-12 12:22:55 UTC. -- Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: Failed to set capabilities on file `/usr/bin/cloud-hypervisor' (Operation not supported) Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: usage: setcap [-q] [-v] [-n <rootid>] (-r|-|<caps>) <filename> [ ... (-r|-|<capsN>) <filenameN> ] Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: Note <filename> must be a regular (non-symlink) file. Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: Failed to set capabilities on file `/usr/lib64/cloud-hypervisor/vhost_user_net' (Operation not supported) Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: usage: setcap [-q] [-v] [-n <rootid>] (-r|-|<caps>) <filename> [ ... (-r|-|<capsN>) <filenameN> ] Nov 12 12:22:40 rhcoslatest rpm-ostree(cloud-hypervisor.post)[1637]: Note <filename> must be a regular (non-symlink) file. ``` It seems to happen as the "chroot" where the package is installed does not have enough privileges to set the binaries capabilities during the `%post` step. Considering this, and also considering that calling `setcap` during `%post` may not be the most elegant solution when speaking RPM spec files, let's take advantage of the already existent `%caps()` directive for the `%files` list to do so. With that change applied, cloud-hypervisor could be successfully installed on RHCOS, as shown below: ``` $ sudo rpm-ostree install cloud-hypervisor-19.0-2.el8.x86_64.rpm Checking out tree 9c1cdf9... done Enabled rpm-md repositories: copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor rpm-md repo 'copr:copr.fedorainfracloud.org:fidencio:cloud-hypervisor' (cached); generated: 2021-11-08T19:02:32Z Importing rpm-md... done Resolving dependencies... done Checking out packages... done Running pre scripts... done Running post scripts... done Running posttrans scripts... done Writing rpmdb... done Writing OSTree commit... done Staging deployment... done Freed: 18.2 MB (pkgcache branches: 2) Added: cloud-hypervisor-19.0-2.el8.x86_64 Run "systemctl reboot" to start a reboot ... $ getcap /usr/bin/cloud-hypervisor /usr/bin/cloud-hypervisor = cap_net_admin+ep $ getcap /usr/lib64/cloud-hypervisor/vhost_user_net /usr/lib64/cloud-hypervisor/vhost_user_net = cap_net_admin+ep ``` Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2021-11-12 13:45:32 +00:00
%caps(cap_net_admin=ep) %{_libdir}/cloud-hypervisor/static/vhost_user_net
%endif
%license LICENSE-APACHE
%license LICENSE-BSD-3-Clause
%changelog
* Thu Jul 07 2022 Rob Bradford <robert.bradford@intel.com> 25.0-0
- Update to 25.0
* Wed May 25 2022 Sebastien Boeuf <sebastien.boeuf@intel.com> 24.0-0
- Update to 24.0
* 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
- Update to 23.0
* Thu Mar 03 2022 Rob Bradford <robert.bradford@intel.com> 22.0-0
- Update to 22.0
* Thu Jan 20 2022 Rob Bradford <robert.bradford@intel.com> 21.0-0
- Update to 21.0
* Thu Dec 02 2021 Sebastien Boeuf <sebastien.boeuf@intel.com> 20.0-0
- Update to 20.0
* Mon Nov 08 2021 Fabiano Fidêncio <fabiano.fidencio@intel.com> 19.0-0
- Update to 19.0
* Fri May 28 2021 Muminul Islam <muislam@microsoft.com> 15.0-0
- Update version to 15.0
* Wed Jul 22 2020 Muminul Islam <muislam@microsoft.com> 0.8.0-0
- Initial version