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

Name:           stratovirt
Version:        0.1.0
Release:        1
Summary:        StratoVirt is an opensource VMM(Vritual Machine Manager) which aims to emulate and manage light-weight virtual machines for serverless runtime.

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

ExclusiveArch:  x86_64 aarch64


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

BuildRequires:  rust
BuildRequires:  cargo
BuildRequires:  rust-packaging

%description
StratoVirt is an opensource VMM(Vritual Machine Manager) which aims to emulate and manage light-weight
virtual machines for serverless runtime.


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

%check
%cargo_test -a -- --all

%changelog
* Thu Jul 16 03:19:44 EDT 2020 Xu Yandong <xuyandong2@huawei.com> - 0.1.0-1
- Initial package
