%define debug_package %{nil}

Name:           virtiofsd
Version:        1.10.1
Release:        3
Summary:        Virtio-fs vhost-user device daemon (Rust version)
License:        Apache-2.0 AND BSD-3-Clause
URL:            https://gitlab.com/virtio-fs/%{name}
Source0:        %{name}-%{version}.crate
Source1:        %{name}-%{version}-vendor.tar.gz
ExclusiveArch:  x86_64 aarch64 riscv64 loongarch64

BuildRequires:  rust-packaging >= 21
BuildRequires:  libcap-ng-devel
BuildRequires:  libseccomp-devel
Requires:       qemu
Provides:       vhostuser-backend(fs)
Provides:       qemu-virtiofsd = 7.2.1-1

%description
%{summary}.

%prep
%autosetup -n %{name}-%{version} -p1
tar xvf %{SOURCE1}
mkdir -p .cargo
cat >.cargo/config << EOF

[source.crates-io]
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "vendor"
EOF

%build
%cargo_build

%install
mkdir -p %{buildroot}%{_libexecdir}
install -D -p -m 0755 target/release/virtiofsd %{buildroot}%{_libexecdir}/virtiofsd
install -D -p -m 0644 50-virtiofsd.json %{buildroot}%{_datadir}/qemu/vhost-user/50-qemu-virtiofsd.json

%files
%license LICENSE-APACHE LICENSE-BSD-3-Clause
%doc README.md
%{_libexecdir}/virtiofsd
%{_datadir}/qemu/vhost-user/50-qemu-virtiofsd.json

%changelog
* Wed Jun 19 2024 Wenlong Zhang <zhangwenlong@loongson.cn> - 1.10.1-3
- fix build error for loongarch64

* Fri May 24 2024 Jingwiw <wangjingwei@iscas.ac.cn> - 1.10.1-2
- enable riscv build

* Mon May 06 2024 lijian <lijian2@kylinos.cn> - 1.10.1-1
- Initial package
