File readsb.spec of Package readsb
#
# spec file for package readsb
#
# Copyright (c) 2024 Eugenio Paolantonio <me@medesimo.eu>
#
# 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/
#
%bcond_without rtlsdr
%bcond_without plutosdr
%if ! %{defined _distconfdir}
%define _distconfdir %{_sysconfdir}
%define no_usretc 1
%endif
Name: readsb
Version: 3.14.1690
Release: 0
License: GPL-3.0+ and GPL-2.0+ and BSD-2-Clause
Summary: Mode-S/ADSB/TIS decoder
Source0: https://github.com/wiedehopf/readsb/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1: readsb.service
Source2: readsb.tmpfiles.conf
Source3: readsb.user.conf
Patch0: disambiguate-unterminated-strings.patch
Patch1: followup.patch
BuildRequires: make
BuildRequires: systemd-rpm-macros
BuildRequires: sysuser-tools
BuildRequires: pkgconfig(zlib)
BuildRequires: pkgconfig(libzstd)
BuildRequires: pkgconfig(ncurses)
BuildRequires: pkgconfig(libiio)
BuildRequires: pkgconfig(libusb)
%if %{with rtlsdr}
BuildRequires: pkgconfig(librtlsdr)
%endif
%if %{with plutosdr}
BuildRequires: pkgconfig(libad9361)
%endif
Requires(pre): system-user-%{name} = %{version}-%{release}
%description
readsb is a Mode-S/ADSB/TIS decoder for RTLSDR, BladeRF, Modes-Beast and GNS5894 devices.
%package -n system-user-%{name}
Summary: System user %{name}
BuildArch: noarch
Provides: user(readsb)
Provides: group(readsb)
Requires(pre): group(dialout)
%?sysusers_requires
%description -n system-user-%{name}
System user %{name}
%prep
%autosetup -p1
%build
make %{?_smp_mflags} \
RTLSDR=%{?with_rtlsdr:yes} \
PLUTOSDR=%{?with_plutosdr:yes} \
AIRCRAFT_HASH_BITS=15 \
HISTORY=yes \
HAVE_BIASTEE=yes
%sysusers_generate_pre %{SOURCE3} %{name} %{name}-user.conf
%install
install -D -m 755 readsb %{buildroot}%{_bindir}/readsb
install -D -m 755 viewadsb %{buildroot}%{_bindir}/viewadsb
install -D -m 644 debian/readsb.default %{buildroot}%{_distconfdir}/%{name}
install -D -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
install -D -m 644 %{SOURCE2} %{buildroot}%{_tmpfilesdir}/%{name}.conf
install -D -m 644 %{SOURCE3} %{buildroot}%{_sysusersdir}/%{name}-user.conf
%pre
%service_add_pre %{name}.service
%pre -n system-user-%{name} -f %{name}.pre
%post
%tmpfiles_create %_tmpfilesdir/readsb
%service_add_post %{name}.service
%preun
%service_del_preun %{name}.service
%postun
%service_del_postun %{name}.service
%files
%defattr(-,root,root)
%doc README.md
%doc README-api.md
%doc README-json.md
%doc debian/README.librtlsdr
%license LICENSE
%{_bindir}/readsb
%{_bindir}/viewadsb
%if 0%{?no_usretc} == 1
%config(noreplace) %{_distconfdir}/%{name}
%else
%{_distconfdir}/%{name}
%endif
%{_unitdir}/%{name}.service
%{_tmpfilesdir}/%{name}.conf
%ghost %{_rundir}/readsb
%files -n system-user-%{name}
%{_sysusersdir}/%{name}-user.conf
%changelog