# Generated by rust2rpm 25
%bcond_without check

%global crate vhost-device-sound

Name:           rust-vhost-device-sound
Version:        0.1.0
Release:        %autorelease
Summary:        Virtio-sound device using the vhost-user protocol

License:        Apache-2.0 OR BSD-3-Clause
URL:            https://crates.io/crates/vhost-device-sound
Source:         %{crates_source}

# Upstream doesn't provide man pages
Patch0: man-page.patch

# Package dependencies vmm-sys-util not built for s390x
# Upstream Package dependency vm-memory only support 64bit
ExcludeArch: i386 i686 s390x

BuildRequires:  cargo-rpm-macros >= 24
BuildRequires:  dbus-daemon >= 1.14.10

%global _description %{expand:
A virtio-sound device using the vhost-user protocol.}

%description %{_description}

%package     -n %{crate}
Summary:        %{summary}
# (MIT OR Apache-2.0) AND Unicode-DFS-2016
# Apache-2.0
# Apache-2.0 OR BSD-3-Clause
# Apache-2.0 OR MIT
# BSD-3-Clause
# MIT
# Unlicense OR MIT
License:        ((MIT OR Apache-2.0) AND Unicode-DFS-2016) AND Apache-2.0 AND (Apache-2.0 OR BSD-3-Clause) AND (Apache-2.0 OR MIT) AND BSD-3-Clause AND MIT AND (Unlicense OR MIT)
# LICENSE.dependencies contains a full license breakdown

%description -n %{crate} %{_description}

%files       -n %{crate}
%license LICENSE-APACHE
%license LICENSE-BSD-3-Clause
%license LICENSE.dependencies
%doc CHANGELOG.md
%doc README.md
%{_bindir}/vhost-device-sound
%{_mandir}/man1/*

%package        devel
Summary:        %{summary}
BuildArch:      noarch

%description    devel %{_description}

This package contains library source intended for building other packages which
use the "%{crate}" crate.

%files          devel
%license %{crate_instdir}/LICENSE-APACHE
%license %{crate_instdir}/LICENSE-BSD-3-Clause
%doc %{crate_instdir}/CHANGELOG.md
%doc %{crate_instdir}/README.md
%{crate_instdir}/

%package     -n %{name}+default-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+default-devel %{_description}

This package contains library source intended for building other packages which
use the "default" feature of the "%{crate}" crate.

%files       -n %{name}+default-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+alsa-backend-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+alsa-backend-devel %{_description}

This package contains library source intended for building other packages which
use the "alsa-backend" feature of the "%{crate}" crate.

%files       -n %{name}+alsa-backend-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+pw-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+pw-devel %{_description}

This package contains library source intended for building other packages which
use the "pw" feature of the "%{crate}" crate.

%files       -n %{name}+pw-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+pw-backend-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+pw-backend-devel %{_description}

This package contains library source intended for building other packages which
use the "pw-backend" feature of the "%{crate}" crate.

%files       -n %{name}+pw-backend-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+xen-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+xen-devel %{_description}

This package contains library source intended for building other packages which
use the "xen" feature of the "%{crate}" crate.

%files       -n %{name}+xen-devel
%ghost %{crate_instdir}/Cargo.toml

%prep
%autosetup -n %{crate}-%{version} -p1
%cargo_prep

%generate_buildrequires
%cargo_generate_buildrequires

%build
%cargo_build
%{cargo_license_summary}
%{cargo_license} > LICENSE.dependencies

%install
%cargo_install
mkdir -p %{buildroot}/%{_mandir}/man1
install -p -m 644 vhost-device-sound.1 %{buildroot}/%{_mandir}/man1/

%if %{with check}
%check
# * skip pipewire tests that fail because it requires test utility to launch a temporary dbus daemon for pipewire.
# * skip alsa tests that fail because of unwrapping the result of PCM::new(), which lead to a runtime panic
%cargo_test -- -- --skip audio_backends::pipewire::tests::test_pipewire_backend_invalid_stream \
--skip audio_backends::pipewire::tests::test_pipewire_backend_success \
--skip audio_backends::tests::test_alloc_audio_backend --skip audio_backends::alsa::tests::test_alsa_invalid_fmt \
--skip audio_backends::alsa::tests::test_alsa_valid_parameters --skip audio_backends::alsa::tests::test_alsa_ops \
--skip audio_backends::alsa::tests::test_alsa_invalid_rate \
--skip audio_backends::alsa::tests::test_alsa_invalid_state_transitions \
--skip audio_backends::alsa::tests::test_alsa_invalid_stream_id
%endif

%changelog
%autochangelog