File librespot.spec of Package librespot

#
# spec file for package librespot
#
# Copyright (c) 2025 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

%global rustflags '-Clink-arg=-Wl,-z,relro,-z,now'

Name:           librespot
Version:        0.6.0
Release:        0
Summary:        an open source client library for Spotify
License:        MIT
Url:            https://github.com/librespot-org/librespot
Source0:        https://github.com/librespot-org/librespot/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        vendor.tar.gz
BuildRequires:  cargo >= 1.41
BuildRequires:  rust >= 1.31
BuildRequires:  alsa-devel
BuildRequires:  avahi-compat-mDNSResponder-devel
BuildRequires:  libpulse-devel

%description

librespot is an open source client library for Spotify. It enables applications to use Spotify's service to control and play music via various backends, and to act as a Spotify Connect receiver. It is an alternative to the official and now deprecated closed-source libspotify. Additionally, it will provide extra features which are not available in the official library.

Note: librespot only works with Spotify Premium. This will remain the case for the foreseeable future, as we are unlikely to work on implementing the features such as limited skips and adverts that would be required to make librespot compliant with free accounts.

%prep
%setup -qa1

%build
RUSTFLAGS=%{rustflags} cargo build --release \
    --features "pulseaudio-backend"

%install
RUSTFLAGS=%{rustflags} cargo install --no-track --root=%{buildroot}%{_prefix} --path .
install -D -m 0644 ./contrib/%{name}.service %{buildroot}%{_unitdir}/%{name}.service

%pre
%service_add_pre %{name}.service

%post
%service_add_post %{name}.service

%preun
%service_del_preun %{name}.service

%postun
%service_del_postun %{name}.service

%files
%doc README.md
%license LICENSE
%{_bindir}/librespot
%{_unitdir}/%{name}.service

%changelog

openSUSE Build Service is sponsored by