File pipewire.spec of Package pipewire

#
# spec file for package pipewire
#
# Copyright (c) 2021 SUSE LLC
# Copyright (c) 2018 Luciano Santos, luc14n0@linuxmail.org.
#
# 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 https://bugs.opensuse.org/
#


#
%global use_clang 1
%global use_lld 1
# viable only on x86_64… when clang doesn't mess it up and produce segfaulting binaries… or is it ?
%ifarch %ix86 %arm
%global use_lto 1
%else
%global use_lto 1
%endif
%global with_libcamera 1

#define _use_internal_dependency_generator 0

%global provfind sh -c "grep -v -e 'libjack.*\\.so' | %__find_provides"
%global __find_provides %provfind

%define apiver 0.3
%define apiver_str 0_3
%define spa_ver 0.2
%define spa_ver_str 0_2
%define sover_jack 0
%define sover_pulse 0
%define limits_ver 7
%define libpipewire libpipewire-%{apiver_str}-0

# it's actually a useless placeholder for now
# but it already depends on ffmpeg that depends on vulkan libs
%define with_vulkan 1

%ifnarch s390 s390x ppc64
%define with_ldacBT 1
%else
%define with_ldacBT 0
%endif

%bcond_with aac
%bcond_with aptx
%bcond_with lc3plus

Name:           pipewire
Version:        1.2.0+591~git20250117.eb91f097d
Release:        0
Summary:        A Multimedia Framework designed to be an audio and video server and more
License:        MIT
Group:          Development/Libraries/C and C++
URL:            https://pipewire.org/
Source0:        %{name}-%{version}.tar.xz
Source1:        %{name}-rpmlintrc
Source99:       baselibs.conf
Source100:      limits-realtime_low_latency.conf
Source101:      pipewire.service.d-user-limits.conf
Source103:      pipewire-pulse.service.d-user-limits.conf
Source104:      pipewire.service.d-system-limits.conf
Source105:      user@.service.d-limits.conf
Source106:      user.d-realtime_low_latency.conf
Source110:      rtkit-daemon.service.d-system-limits.conf
Source111:      rtkit.conf
Source120:      tuned_latency-balanced.conf
Source121:      tuned_latency-balanced.script
Patch900:       pipewire_stop-bitrate-starving-opus.patch
Patch902:       pipewire-issue1708-heaac.patch
Patch910:       pipewire-reorder_BT_codecs.patch
# otherwise EasyEffects nodes are getting 4/14 quality level even if it's overriden in every single config-file
Patch990:       pipewire-resample_quality_boost.patch
# there seems to be no way to tweak it in config
Patch991:       pipewire-alsa_default_params_tweak.patch
#Patch991:       pipewire-alsa_default_params_tweak-1.2.7.patch
BuildRequires:  cmake
BuildRequires:  doxygen
BuildRequires:  fdupes
BuildRequires:  fontconfig
%if 0%{?use_clang}
BuildRequires:  clang-devel
#BuildRequires:     npth-devel
%if 0%{?use_lld}
BuildRequires:  lld
%else
BuildRequires:  binutils-gold
BuildRequires:  llvm-gold
%endif
%else
BuildRequires:  binutils-gold
BuildRequires:  gcc-c++
%endif
BuildRequires:  graphviz
BuildRequires:  graphviz-gd
BuildRequires:  graphviz-plugins-core
BuildRequires:  meson
BuildRequires:  perl-XML-Parser
BuildRequires:  pkgconfig
BuildRequires:  systemd-rpm-macros
BuildRequires:  python3-docutils
BuildRequires:  pkgconfig(alsa)
BuildRequires:  pkgconfig(avahi-client)
BuildRequires:  pkgconfig(bluez)
BuildRequires:  pkgconfig(ModemManager)
%if 0%{?with_libcamera}
BuildRequires:  pkgconfig(libcamera)
%endif
BuildRequires:  pkgconfig(dbus-1)
%if %{with aac}
BuildRequires:  pkgconfig(fdk-aac)
%endif
BuildRequires:  pkgconfig(fftw3f)
BuildRequires:  pkgconfig(gio-2.0)
BuildRequires:  pkgconfig(gio-unix-2.0)
BuildRequires:  pkgconfig(glib-2.0) >= 2.32.0
BuildRequires:  pkgconfig(gmodule-2.0)
BuildRequires:  pkgconfig(gobject-2.0)
BuildRequires:  pkgconfig(gstreamer-1.0)
BuildRequires:  pkgconfig(gstreamer-allocators-1.0)
BuildRequires:  pkgconfig(gstreamer-audio-1.0)
BuildRequires:  pkgconfig(gstreamer-plugins-base-1.0)
BuildRequires:  pkgconfig(gstreamer-video-1.0)
BuildRequires:  pkgconfig(jack) >= 1.9.10
# OBS may just skip libjack for no reason, despite installing its devel-package
BuildRequires:  libjack%{sover_jack}
BuildRequires:  libpulse%{sover_pulse}
BuildRequires:  pkgconfig(opus)
%if %{with_ldacBT}
BuildRequires:  pkgconfig(ldacBT-abr)
BuildRequires:  pkgconfig(ldacBT-enc)
%endif
BuildRequires:  pkgconfig(libavcodec)
BuildRequires:  pkgconfig(libavfilter)
BuildRequires:  pkgconfig(libavformat)
%if %{with aptx}
BuildRequires:  pkgconfig(libfreeaptx)
%endif
BuildRequires:  pkgconfig(lc3)
%if %{with lc3plus}
BuildRequires:  pkgconfig(lc3plus)
%endif
BuildRequires:  pkgconfig(libapparmor)
BuildRequires:  pkgconfig(libcanberra)
BuildRequires:  pkgconfig(libdrm)
BuildRequires:  pkgconfig(libebur128)
BuildRequires:  pkgconfig(libffado)
BuildRequires:  pkgconfig(libmysofa)
BuildRequires:  pkgconfig(libpulse)
BuildRequires:  pkgconfig(libsystemd)
BuildRequires:  pkgconfig(libudev)
BuildRequires:  pkgconfig(libusb-1.0)
BuildRequires:  pkgconfig(libva)
BuildRequires:  pkgconfig(lilv-0)
BuildRequires:  pkgconfig(openssl)
BuildRequires:  pkgconfig(ncurses)
BuildRequires:  pkgconfig(readline)
BuildRequires:  pkgconfig(sbc)
#BuildRequires:  pkgconfig(sdl2)
BuildRequires:  pkgconfig(sndfile)
BuildRequires:  pkgconfig(systemd)
BuildRequires:  pkgconfig(udev)
%if %{with_vulkan}
BuildRequires:  pkgconfig(vulkan)
%endif
BuildRequires:  pkgconfig(webrtc-audio-processing-2)
BuildRequires:  pkgconfig(x11)
#BuildRequires:  snapd
#BuildRequires:  pkgconfig(snapd-glib-2)
#Requires(post): %fillup_prereq
Requires(post): alsa-utils
Requires:       %{libpipewire} = %{version}
Requires:       %{name}-modules = %{version}
Requires:       %{name}-spa-plugins-%{spa_ver_str} = %{version}
Requires:       %{name}-spa-tools = %{version}
Requires:       %{name}-tools = %{version}
Requires:       realtime-lowlatency-limits
Requires:       rtkit
Provides:       pipewire-pulseaudio = %{version}
Provides:       pulseaudio = 17.0
# This actually creates conflict and forbids installation of original PA
# it's unnecessary but some people can't configure things properly and lose audio
Provides:       pulseaudio-daemon
Provides:       jack-daemon
# it's not maintained anymore and "native" BT backend is the new primary
#Recommends:     hsphfpd
Recommends:     wireplumber
#Recommends:     pipewire-media-session
Requires:       pipewire-session-manager
# node managers
Recommends:     qpwgraph
Recommends:     qjackctl
Recommends:     carla
%{?systemd_ordering}

%description
PipeWire is a server and user space API to deal with multimedia pipelines.

Some of its features include:

 * Capture and playback of audio and video with minimal latency;
 * Real-time Multimedia processing on audio and video;
 * Multiprocess architecture to let applications share multimedia content;
 * GStreamer plugins for easy use and integration in current applications;
 * Sandboxed applications support.

%package -n %{libpipewire}
Summary:        A Multimedia Framework designed to be an audio and video server and more
Group:          System/Libraries
%ifarch x86_64 %{arm64} %{mips64} %{sparc64} %{power64}
Recommends:     %{libpipewire}-32bit
%endif
Recommends:     pipewire >= %{version}

%description -n %{libpipewire}
PipeWire is a server and user space API to deal with multimedia pipelines.

Some of its features include:

 * Capture and playback of audio and video with minimal latency;
 * Real-time Multimedia processing on audio and video;
 * Multiprocess architecture to let applications share multimedia content;
 * GStreamer plugins for easy use and integration in current applications;
 * Sandboxed applications support.

Some features of its Simple Plugin API include:

 * Unlimited input/output ports;
 * Per port format enumeration and negotiation;
 * Enumeration/configuration of per port parameters;
 * Application controlled buffer allocation with option to let the plugin
   Allocate memory;
 * Arbitrary buffer metadata;
 * Buffers are passed around by id which is very fast and avoids the need
   for refcounting;
 * Synchronous and asynchronous processing;
 * All api is designed to work without any allocations;
 * Arbirary input/output behaviour.

This package provides the PipeWire shared library.

%package -n gstreamer-plugin-pipewire
Summary:        Gstreamer Plugin for PipeWire
Group:          System/Libraries
%ifarch x86_64 %{arm64} %{mips64} %{sparc64} %{power64}
Recommends:     gstreamer-plugin-pipewire-32bit
%endif

%description -n gstreamer-plugin-pipewire
PipeWire is a server and user space API to deal with multimedia pipelines.

This package provides the gstreamer plugin.

%package tools
Summary:        The PipeWire Tools
Group:          Productivity/Multimedia/Other

%description tools
This package contains command line utilities for the PipeWire media server.

%package spa-tools
Summary:        The PipeWire SPA Tools
Group:          Productivity/Multimedia/Other

%description spa-tools
SPA or Simple Plugin API is a plugin API.

This package provides spa-inspect and spa-monitor tools.

%package modules
Summary:        Modules For PipeWire, A Multimedia Framework
Group:          Productivity/Multimedia/Other
Recommends:     pipewire-modules-jack-override
%ifarch x86_64 %{arm64} %{mips64} %{sparc64} %{power64}
Recommends:     pipewire-modules-32bit
%endif
Provides:       pipewire-modules-jack
Provides:       pipewire-modules-pulse
Obsoletes:      pipewire-modules-jack
Obsoletes:      pipewire-modules-pulse
Requires:       pipewire = %{version}

%description modules
PipeWire is a server and user space API to deal with multimedia pipelines.

The framework is used to build a modular daemon that can be configured to:

 * Be a low-latency audio server with features like pulseaudio and/or jack;
 * A video capture server that can manage hardware video capture devices
   and provide access to them;
 * A central hub where video can be made available for other applications
   such as the gnome-shell screencast API.

%package modules-jack-override
Summary:        Shim for JACK emulation via PipeWire Multimedia Framework
Group:          Productivity/Multimedia/Other
Requires:       pipewire-modules
%define libjack_version %(rpm -q --queryformat '%%{VERSION}' libjack0)
Provides:       jack = %{libjack_version}
Provides:       libjack0 = %{libjack_version}
Provides:       libjack0%{_isa} = %{libjack_version}
Provides:       libjack2 = %{libjack_version}
%ifarch %{ix86} %{mips32}
Provides:       libjack.so.0 = %{libjack_version}
%else
Provides:       libjack.so.0()(64bit) = %{libjack_version}
%endif

%description modules-jack-override
PipeWire is a server and user space API to deal with multimedia pipelines.
This is ld.so LDPATH override for forcing PW's libjack to be loaded before trying
the original one. This is less clunky alternative to symlinking libjack in %{_libdir}

%package spa-plugins-%{spa_ver_str}
Summary:        Plugins For PipeWire SPA
Group:          Productivity/Multimedia/Other
Requires:       pipewire
%ifarch x86_64 %{arm64} %{mips64} %{sparc64} %{power64}
Recommends:     pipewire-spa-plugins-32bit
%endif

%description spa-plugins-%{spa_ver_str}
PipeWire is a server and user space API to deal with multimedia pipelines.

Some of its features include:

 * Unlimited input/output ports;
 * Per port format enumeration and negotiation;
 * Enumeration/configuration of per port parameters;
 * Application controlled buffer allocation with option to let the plugin
   Allocate memory;
 * Arbitrary buffer metadata;
 * Buffers are passed around by id which is very fast and avoids the need
   for refcounting;
 * Synchronous and asynchronous processing;
 * All api is designed to work without any allocations;
 * Arbirary input/output behaviour.

This package provides plugins for extending PipeWire SPA's functionality.

%package devel
Summary:        Development Files For PipeWire, A Multimedia Framework
Group:          Development/Libraries/C and C++
Requires:       %{libpipewire} >= %{version}

%description devel
PipeWire is a server and user space API to deal with multimedia pipelines.

This package provides all the necessary files for development with PipeWire

%package doc
Summary:        PipeWire media server documentation
Group:          Development/Libraries/C and C++

%description doc
This package contains documentation for the PipeWire media server.

%lang_package

%package -n realtime-lowlatency-limits
Summary:        PAM config-file to remove excessive process limits
Group:          Development/Libraries/C and C++
BuildArch:      noarch
Requires(post): tuned
# all default tuned profiles suck
#Requires(postun): tuned
#Requires(postun): tuned-profiles-realtime
Requires(post): perl-Bootloader
#!BuildIgnore:  perl-Bootloader
Requires:       pam
Requires:       systemd
Requires:       tuned
Provides:       realtime-lowlatency-limits = %{limits_ver}
# boost handling of multimedia-related irq ?
Recommends:     rtirq
# kernel should handle irq balancing fine by default
#Recommends:     irqbalance
# use full/realtime preemption kernel ?
# https://build.opensuse.org/project/monitor/home:X0F:HSF:Kernel
#Recommends:     kernel-HSF
# replace stagnated PA & JACK ?
Recommends:     pipewire
# trade CPU latency for NVMe access latency
Recommends:     zram

%description -n realtime-lowlatency-limits
File that lifts default limits on process capabilities to allow better preemption
and scheduling latencies suitable for modern user-level multimedia tasks.

It's needed for PipeWire, JACK or any other latency-sensitive service to function properly.

%prep
%autosetup -p1
# https://aur.archlinux.org/cgit/aur.git/tree/?h=pipewire-git
# Reduce docs size
printf '%s\n' >> doc/Doxyfile.in \
    HAVE_DOT=yes DOT_IMAGE_FORMAT=svg INTERACTIVE_SVG=yes
# crutch for "release" version of pulseaudio's webrtc
#sed -i -e '/webrtc_dep/s:'webrtc-audio-processing':'webrtc-audio-processing-1':' meson.build
#sed -i -e 's:#include <webrtc/:#include <:g' src/modules/module-echo-cancel/aec-webrtc.cpp

%build
# this macro needs 'BuildRequires: memory-constraints'
#limit_build -m 3072
ulimit -Sn 4000
UCFLAGS="%{optflags} -fPIC -O3 -Wno-error=strict-prototypes -Wno-error=implicit-function-declaration"
#export UCFLAGS="${UCFLAGS} -I%{_includedir}/webrtc-audio-processing-2"
%ifarch x86_64 
export UCFLAGS="${UCFLAGS} -march=x86-64 -mtune=generic -mssse3 -msse4 -msse4.1 -msse4.2 -mavx -maes -mpclmul"
%endif
export ULDFLAGS="-fPIC -Wl,--icf=safe -Wl,--gc-sections -Wl,-O1"
%if 0%{?use_lld}
export ULDFLAGS="${ULDFLAGS} -fuse-ld=lld"
%ifarch %ix86 %arm
UCFLAGS="${UCFLAGS} -Wno-error=format"
export ULDFLAGS="${ULDFLAGS} -Wl,-z,notext"
%endif
export LD="lld"
alias ld=ld.lld
%else
export ULDFLAGS="${ULDFLAGS} -fuse-ld=gold -Wl,--sort-common -Wl,-O1"
export LD=ld.gold
alias ld=gold
%endif
%if 0%{?use_clang}
export CC=clang
export CXX=clang++
#export UCFLAGS="${UCFLAGS} -v -D_GNU_SOURCE"
export UCFLAGS="${UCFLAGS} -fexceptions -relocatable-pch -faligned-allocation"
export UCXXFLAGS="${UCFLAGS}"
export UCXXFLAGS="${UCXXFLAGS} -fpermissive -fcxx-exceptions"
%ifarch %ix86 %arm
# it's back again
export ULDFLAGS="${ULDFLAGS} -latomic"
%endif
export HOST="$(${CC} -print-target-triple)"
%if 0%{?use_lto}
%if 0%{?use_lld}
%global _lto_cflags -flto=thin -Wl,--plugin-opt=O3 %{?jobs:-Wl,--threads=%{jobs} }
%global _lto_ldlags -flto=thin -Wl,--plugin-opt=O3 %{?jobs:-Wl,--threads=%{jobs} }
%else
%global _lto_cflags -flto=thin
%global _lto_ldlags -flto=thin
%endif
%else
%global _lto_cflags %nil
%global _lto_ldlags %nil
%endif
%else
export CC=gcc
export CXX=g++
export UCFLAGS="${UCFLAGS} -ftree-parallelize-loops=4 -ftree-vectorize -fpredictive-commoning"
export UCXXFLAGS="${UCFLAGS} -fpermissive"
export HOST="%{_target_platform}"
%if 0%{?use_lto}
%global _lto_cflags -fuse-linker-plugin %_lto_cflags -ffat-lto-objects -flto-odr-type-merging
%global _lto_ldlags -fuse-linker-plugin %{?jobs:-Wl,-flto=%{jobs} }
%else
%global _lto_cflags %nil
%global _lto_ldlags %nil
%endif
%endif
export TARGET="${HOST}"
export UCFLAGS="${UCFLAGS} %_lto_cflags"
export UCXXFLAGS="${UCXXFLAGS} %_lto_cflags"
export ULDFLAGS="${ULDFLAGS} %_lto_cflags %_lto_ldlags"
# override OBS defaults ?
export CFLAGS="${UCFLAGS}"
export CXXFLAGS="${UCXXFLAGS}"
export LDFLAGS="${ULDFLAGS}"

%meson \
	-Dpipewire-alsa=enabled \
	-Dpipewire-jack=enabled \
	-Djack=enabled \
	-Dlibpulse=enabled \
	-Dgsettings-pulse-schema=enabled \
	-Dlv2=enabled \
	-Dbluez5=enabled \
	-Dbluez5-backend-hsphfpd=enabled \
	-Dbluez5-backend-native-mm=enabled \
	-Ddocs=enabled \
	-Dman=enabled \
	-Dgstreamer=enabled \
	-Dffmpeg=enabled \
	-Dopus=enabled \
	-Dlibffado=enabled \
	-Dpw-cat-ffmpeg=enabled \
	-Dcompress-offload=enabled \
	-Draop=enabled \
	-Dsnap=disabled \
	-Dsystemd=enabled \
	-Dsystemd-system-service=enabled \
	-Dsystemd-user-service=enabled \
	-Dvolume=enabled \
%if %{with_vulkan}
	-Dvulkan=enabled \
%else
	-Dvulkan=disabled \
%endif
%if 0%{?with_libcamera}
	-Dlibcamera=enabled \
%else
        -Dlibcamera=disabled \
%endif
	-Dbluez5-codec-opus=enabled \
%if %{with aac}
	-Dbluez5-codec-aac=enabled \
%else
	-Dbluez5-codec-aac=disabled \
%endif
%if %{with aptx}
	-Dbluez5-codec-aptx=enabled \
%else
	-Dbluez5-codec-aptx=disabled \
%endif
	-Dbluez5-codec-lc3=enabled \
%if %{with lc3plus}
	-Dbluez5-codec-lc3plus=enabled \
%else
	-Dbluez5-codec-lc3plus=disabled \
%endif
%if %{with_ldacBT}
	-Dbluez5-codec-ldac=enabled \
%else
	-Dbluez5-codec-ldac=disabled \
%endif
	-Droc=disabled \
	-Davb=enabled \
	-Dtest=enabled \
	-Daudiotestsrc=enabled \
	-Dvideotestsrc=enabled \
	-Dtests=disabled \
	-Dsdl2=disabled \
	-Dudevrulesdir="%{_udevrulesdir}" \
	-Dsession-managers='[]' \
	-Drlimits-install=false \
	-Drtprio-server=44 \
	-Drtprio-client=25 \
	%{nil} || cat */meson-logs/meson-log.txt
%meson_build

%install
%meson_install

# expand default process capabilities for realtime
install -vD -m 0644 %{SOURCE100} %{buildroot}%{_sysconfdir}/security/limits.d/99-realtime_low_latency.conf
install -vD -m 0644 %{SOURCE101} %{buildroot}%{_userunitdir}/pipewire.service.d/limits.conf
install -vD -m 0644 %{SOURCE103} %{buildroot}%{_userunitdir}/pipewire-pulse.service.d/limits.conf
install -vD -m 0644 %{SOURCE104} %{buildroot}%{_unitdir}/pipewire.service.d/limits.conf
install -vD -m 0644 %{SOURCE105} %{buildroot}%{_unitdir}/user@.service.d/99-limits.conf
install -vD -m 0644 %{SOURCE106} %{buildroot}%{_unitdir}/user.conf.d/99-realtime_low_latency.conf
install -vD -m 0644 %{SOURCE110} %{buildroot}%{_unitdir}/rtkit-daemon.service.d/99-limits.conf
# using "fillup" script may mangle the config
#install -vD -m 0644 %{SOURCE111} %{buildroot}%{_fillupdir}/sysconfig.rtkit
install -vD -m 0644 %{SOURCE111} %{buildroot}%{_sysconfdir}/rtkit.conf
install -vD -m 0644 %{SOURCE120} %{buildroot}%{_sysconfdir}/tuned/profiles/latency-balanced/tuned.conf
install -vD -m 0755 %{SOURCE121} %{buildroot}%{_sysconfdir}/tuned/profiles/latency-balanced/script.sh

mkdir -p %{buildroot}%{_sysconfdir}/alsa/conf.d/
ln -s ../../../%{_datadir}/alsa/alsa.conf.d/50-pipewire.conf %{buildroot}%{_sysconfdir}/alsa/conf.d/
ln -s ../../../%{_datadir}/alsa/alsa.conf.d/99-pipewire-default.conf %{buildroot}%{_sysconfdir}/alsa/conf.d/

# simpler libjack shim
mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d/
echo '%{_libdir}/pipewire-%{apiver}/jack' > %{buildroot}%{_sysconfdir}/ld.so.conf.d/pipewire-libjack.conf
%ifarch x86_64 %{arm64} %{mips64} %{sparc64} %{power64}
echo '%{_prefix}/lib/pipewire-%{apiver}/jack' >> %{buildroot}%{_sysconfdir}/ld.so.conf.d/pipewire-libjack.conf
%endif

%fdupes -s %{buildroot}/%{_datadir}/doc/pipewire/html

%find_lang %{name} %{name}.lang

%check
#meson_test

%pre
%systemd_user_pre pipewire.service
#systemd_user_pre pipewire.socket
#systemd_user_pre pipewire-manager.socket
%systemd_user_pre pipewire-pulse.service
#systemd_user_pre pipewire-pulse.socket
%systemd_user_pre filter-chain.service

%post
%systemd_user_post pipewire.service
#systemd_user_post pipewire.socket
#systemd_user_post pipewire-manager.socket
%systemd_user_post pipewire-pulse.service
#systemd_user_post pipewire-pulse.socket
%systemd_user_post filter-chain.service
%service_del_preun alsa-state.service alsasound.service alsa-restore.service
%service_del_postun alsa-state.service alsasound.service alsa-restore.service
# systemd_user_post macro seems to be broken
# or, at least, some package check about it is
#systemctl --global enable pipewire.socket
#systemctl --global enable pipewire-manager.socket
#systemctl --global enable pipewire-pulse.service
#systemctl --global enable pipewire-pulse.socket
# disable ALSA's kludge for saving volume
#systemctl disable alsa-state.service alsasound.service alsa-restore.service
#systemctl stop alsa-state.service alsasound.service alsa-restore.service
# put settings file for our override of rtkit-daemon.service's useless defaults ?
# but SUSE's sysconfig shim mangles the file by cutting all lines but the first
#{fillup_only -n rtkit}

%preun
%systemd_user_preun pipewire.service
#systemd_user_preun pipewire.socket
#systemd_user_preun pipewire-manager.socket
%systemd_user_preun pipewire-pulse.service
#systemd_user_preun pipewire-pulse.socket
%systemd_user_preun filter-chain.service
%service_add_post alsa-state.service alsasound.service alsa-restore.service
#systemctl --global disable pipewire.socket
#systemctl --global disable pipewire-manager.socket
#systemctl --global disable pipewire-pulse.service
#systemctl --global disable pipewire-pulse.socket
# put ALSA's kludge back ?
#systemctl enable alsa-state.service alsasound.service alsa-restore.service

%postun
%systemd_user_postun pipewire.service
#systemd_user_postun pipewire.socket
#systemd_user_postun pipewire-manager.socket
%systemd_user_postun pipewire-pulse.service
#systemd_user_postun pipewire-pulse.socket
%systemd_user_postun filter-chain.service
#systemctl stop pipewire.socket
#systemctl stop pipewire-manager.socket
#systemctl stop pipewire-pulse.service
#systemctl stop pipewire-pulse.socket

%post   -n %{libpipewire} -p /sbin/ldconfig
%postun -n %{libpipewire} -p /sbin/ldconfig

%post   modules-jack-override -p /sbin/ldconfig
%postun modules-jack-override -p /sbin/ldconfig

%post   -n realtime-lowlatency-limits
tuned-adm profile latency-balanced || :

#postun -n realtime-lowlatency-limits
#tuned-adm profile realtime || :

%files -n realtime-lowlatency-limits
%dir %{_sysconfdir}/security/limits.d
%config %{_sysconfdir}/security/limits.d/99-realtime_low_latency.conf
#{_fillupdir}/sysconfig.rtkit
%config(noreplace) %{_sysconfdir}/rtkit.conf
%dir %{_unitdir}/rtkit-daemon.service.d
%config %{_unitdir}/rtkit-daemon.service.d/99-limits.conf
%dir %{_unitdir}/user@.service.d
%config %{_unitdir}/user@.service.d/99-limits.conf
%dir %{_unitdir}/user.conf.d
%config %{_unitdir}/user.conf.d/99-realtime_low_latency.conf
%dir %{_sysconfdir}/tuned
%dir %{_sysconfdir}/tuned/profiles
%dir %{_sysconfdir}/tuned/profiles/latency-balanced
%config(noreplace) %{_sysconfdir}/tuned/profiles/latency-balanced/tuned.conf
%config(noreplace) %{_sysconfdir}/tuned/profiles/latency-balanced/script.sh

%files
%doc README.md
%caps(cap_sys_nice=eip) %{_bindir}/pipewire
%caps(cap_sys_nice=eip) %{_bindir}/pipewire-aes67
%caps(cap_sys_nice=eip) %{_bindir}/pipewire-avb
%caps(cap_sys_nice=eip) %{_bindir}/pipewire-pulse
%ghost %caps(cap_sys_nice=eip) %{_bindir}/pipewire-vulkan
#exclude %{_bindir}/pipewire-media-session
%dir %{_unitdir}/pipewire.service.d
%dir %{_userunitdir}/pipewire.service.d
%dir %{_userunitdir}/pipewire-pulse.service.d
%config %{_unitdir}/*/*.conf
#exclude %{_unitdir}/*/pipewire-media-session.service.d/limits.conf
%exclude %{_unitdir}/rtkit-daemon.service.d/99-limits.conf
%exclude %{_unitdir}/user@.service.d/99-limits.conf
%exclude %{_unitdir}/user.conf.d/99-realtime_low_latency.conf
%{_unitdir}/*.*
%{_userunitdir}/*.*
#exclude %{_userunitdir}/pipewire-media-session.service
%{_udevrulesdir}/*.rules
%{_mandir}/man?/pipewire*.*.*
%dir %{_libdir}/alsa-lib/
%{_libdir}/alsa-lib/*.so
%{_datadir}/alsa-card-profile
%dir %{_datadir}/alsa
%dir %{_datadir}/alsa/alsa.conf.d
%{_datadir}/alsa/alsa.conf.d/*.conf
%{_datadir}/glib-2.0/schemas/*.gschema.xml
%dir %{_sysconfdir}/alsa
%dir %{_sysconfdir}/alsa/conf.d
%config %{_sysconfdir}/alsa/conf.d/*.conf
%dir %{_datadir}/pipewire
%dir %{_datadir}/pipewire/filter-chain
%config %{_datadir}/pipewire/*.conf
%config %{_datadir}/pipewire/filter-chain/*.conf
%ghost %dir %{_sysconfdir}/pipewire
%ghost %dir %{_sysconfdir}/pipewire/filter-chain
%dir %{_datadir}/pipewire/*conf.*
%config %{_datadir}/pipewire/*conf.*/*.conf

%files -n %{libpipewire}
%license LICENSE COPYING
%{_libdir}/libpipewire-%{apiver}.so.*

%files -n gstreamer-plugin-pipewire
%{_libdir}/gstreamer-1.0/libgstpipewire.so

%files tools
%{_bindir}/pw-*
%{_mandir}/man?/pw-*.*

%files spa-tools
%{_bindir}/spa-*
%{_datadir}/spa-%{spa_ver}
%{_mandir}/man?/spa-*.*

%files modules
%{_libdir}/pipewire-%{apiver}
%{_mandir}/man?/libpipewire-*.*.*

%files modules-jack-override
%config %{_sysconfdir}/ld.so.conf.d/pipewire-libjack.conf

%files spa-plugins-%{spa_ver_str}
%{_libdir}/spa-*

%files devel
%{_libdir}/libpipewire-%{apiver}.so
%{_libdir}/pkgconfig/libpipewire-%{apiver}.pc
%{_libdir}/pkgconfig/libspa-%{spa_ver}.pc
%{_includedir}/pipewire-*
%{_includedir}/spa-*

%files doc
%dir %{_datadir}/doc/pipewire
%{_datadir}/doc/pipewire/html

%files lang -f %{name}.lang

%changelog
openSUSE Build Service is sponsored by