#needsrootforbuild
%global __cargo_skip_build 0
%global _debugsource_packages 1
%global _debuginfo_subpackages 1
%define _unpackaged_files_terminate_build 0

Name:           stratovirt
Version:        0.3.0
Release:        5
Summary:        StratoVirt is an opensource VMM(Virtual Machine Manager) which aims to perform next generation virtualization.

License:        Mulan PSL v2
URL:            https://gitee.com/openeuler/StratoVirt
Source0:        %{name}-%{version}.tar.gz

Patch0001: 0001-docs-update-readme.md-for-building-via-musl-toolchai.patch
Patch0002: 0002-docs-turn-on-the-option-switch-of-virtio-rng-for-x86.patch
Patch0003: 0003-doc-fix-an-uncorrect-link-for-build_guide-in-quickst.patch
Patch0004: 0004-update-rootfs-disk-image-description-in-README.ch.md.patch
Patch0005: 0005-update-rootfs-disk-image-description-in-README.md.patch
Patch0006: 0006-StratoVirt-clear-clippy-warnings-for-updating-rust-1.patch
Patch0007: 0007-testcases-virtio_blk-decrease-hot-plugged-blk-number.patch
Patch0008: 0008-testscases-vmlife-decrease-test-blk-number.patch
Patch0009: 0009-README-update-readme.patch
Patch0010: 0010-docs-add-IMAGE_BUILD.md.patch
Patch0011: 0011-kernel_config-micro_vm-add-CONFIG_HUGETLBFS-option-f.patch

ExclusiveArch:  x86_64 aarch64


%ifarch aarch64
Requires:      dtc
BuildRequires: dtc-devel
%endif

BuildRequires:  rust
BuildRequires:  cargo
BuildRequires:  rust-packaging
BuildRequires:  gcc

%description
Based on Rust programming language, StratoVirt is lightweight, efficient and safe. StratoVirt reduces memory resource consumption and improves VM startup speed while retains isolation capability and security capability of traditional virtualization. StratoVirt works with iSulad and Kata container, and can be integrated in Kubernetes ecosystem perfectly. The current version can be applied to microservices or serverless scenarios. StratoVirt reserves interface and design for importing more features, even standard virtualization.


Summary:        %{summary}

%files       -n stratovirt
%{_bindir}/stratovirt

%prep
%autosetup -p1

%cargo_prep

%cargo_generate_buildrequires

%build

sed -i '/\[source.crates-io\]/{n;d}' ./.cargo/config
sed -i '/\[source.local-registry\]/{n;d}' ./.cargo/config
sed -i '/\[source.local-registry\]/a directory = "vendor"' ./.cargo/config
%ifarch aarch64
sed -i 's/rustflags = \[/rustflags = \["-Clink-arg=-lgcc", "-Clink-arg=-lfdt", /g' ./.cargo/config
%endif

%cargo_build -a

%install
%cargo_install -a
chmod 550 ${RPM_BUILD_ROOT}/usr/bin/stratovirt

%changelog
* Tue Dec 28 2021 Jiajie Li <lijiajie11@huawei.com> - 0.3.0-5
- Type:NA
- ID:NA
- SUG:NA
- DESC:change kernel config for aarch64

* Wed Jun 16 2021 XuFei <xufei30@huawei.com> - 0.3.0-4
- Type:NA
- ID:NA
- SUG:NA
- DESC:add gcc dependency package

* Sun May 28 2021 XuFei <xufei30@huawei.com> - 0.3.0-3
- Type:NA
- ID:NA
- SUG:NA
- DESC:modify docs,modify testcases and clear clippy warnings for updating rust 1.51.0

* Sun Apr 25 2021 LiangZhang <zhangliang5@huawei.com> - 0.3.0-2
- Type:NA
- ID:NA
- SUG:NA
- DESC:Add hydropper to package

* Sun Apr 25 2021 LiangZhang <zhangliang5@huawei.com> - 0.3.0-1
- Type:NA
- ID:NA
- SUG:NA
- DESC:Update package to 0.3.0

* Wed Jan 13 2021 LiangZhang <zhangliang5@huawei.com> - 0.1.0-3
- Type:NA
- ID:NA
- SUG:NA
- DESC:Update package to latest source

* Wed Jan 13 2021 XuFei <xufei30@huawei.com> - 0.1.0-2
- Type:NA
- ID:NA
- SUG:NA
- DESC:Modify summary and description for spec

* Thu Jul 16 2020 Xu Yandong <xuyandong2@huawei.com> - 0.1.0-1
- Initial package
