File hydrasdr-rfone.spec of Package hydrasdr-rfone

#
# spec file for package hydrasdr-rfone
#
# Copyright (c) 2025, Martin Hauke <mardnh@gmx.de>
#
# 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/
#


%define sover   0
%define hydrasdr_group    hydrasdr
%define libname libhydrasdr%{sover}
Name:           hydrasdr-rfone
Version:        1.0.3
Release:        0
Summary:        Support programs for HydraSDR RFOne
License:        GPL-2.0-or-later
URL:            https://hydrasdr.com/
#Git-Clone:     https://github.com/hydrasdr/rfone_host.git
Source:         https://github.com/hydrasdr/rfone_host/archive/refs/tags/v%{version}.tar.gz#/rfone_host-%{version}.tar.gz
BuildRequires:  cmake
BuildRequires:  gcc-c++
BuildRequires:  ninja
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(libusb-1.0)
BuildRequires:  pkgconfig(udev)

%description
Host tools and shared libraries for HydraSDR RFOne software-defined radio.
Provides command-line utilities and development libraries for interfacing
with HydraSDR RFOne hardware.

%package host
Summary:        HydraSDR RFOne Host Tools

%description host
Command-line tools (hydrasdr_info, hydrasdr_lib_version, etc.) for
HydraSDR RFOne.

%package -n %{libname}
Summary:        Driver for HydraSDR RFOne
Requires:       %{name}-udev

%description -n %{libname}
Library to run HydraSDR RFOne SDR receiver.

%package udev
Summary:        Udev rules for HydraSDR RFOne
Requires(pre):  shadow

%description udev
Udev rules for HydraSDR RFOne.

%package devel
Summary:        Development files for HydraSDR RFOne
Requires:       %{libname} = %{version}
Requires:       pkgconfig(libusb-1.0)

%description devel
Library headers for HydraSDR RFOne driver.

%prep
%autosetup -p1 -n rfone_host-%{version}

# HACK: set udev group to hydrasdr
sed -i "s/plugdev/hydrasdr/g" hydrasdr-tools/51-hydrasdr.rules

%build
%define __builder ninja
%cmake -DINSTALL_UDEV_RULES=ON
%cmake_build

%install
%cmake_install
rm %{buildroot}%{_libdir}/libhydrasdr.a

mkdir -p %{buildroot}%{_udevrulesdir}
mv %{buildroot}%{_sysconfdir}/udev/rules.d/51-hydrasdr.rules %{buildroot}%{_udevrulesdir}

%check
%ctest

%ldconfig_scriptlets -n %{libname} 

%pre udev
getent group %{hydrasdr_group} >/dev/null || groupadd -r %{hydrasdr_group}

%post udev
%udev_rules_update

%postun udev
%udev_rules_update

%files host
%license hydrasdr-tools/LICENSE.md
%doc README.md
%doc hydrasdr-tools/hydrasdr_tools_readme.md
%doc hydrasdr-tools/hydrasdr_calibration_procedure.md
%doc hydrasdr-tools/hydrasdr_troubleshooting.md
%{_bindir}/hydrasdr_calibrate
%{_bindir}/hydrasdr_gpio
%{_bindir}/hydrasdr_gpiodir
%{_bindir}/hydrasdr_info
%{_bindir}/hydrasdr_lib_version
%{_bindir}/hydrasdr_r82x
%{_bindir}/hydrasdr_reset
%{_bindir}/hydrasdr_rx
%{_bindir}/hydrasdr_set_rf_port
%{_bindir}/hydrasdr_si5351c
%{_bindir}/hydrasdr_spiflash

%files -n %{libname}
%license libhydrasdr/LICENSE.md
%{_libdir}/libhydrasdr.so.*

%files udev
%{_udevrulesdir}/51-hydrasdr.rules

%files devel
%{_libdir}/libhydrasdr.so
%{_includedir}/libhydrasdr
%{_libdir}/pkgconfig/libhydrasdr.pc
%{_libdir}/cmake/HydraSDR

%changelog
openSUSE Build Service is sponsored by