File rfcat.spec of Package rfcat

#
# spec file for package rfcat
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2017-2023, 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 rfcat_group rfcat
Name:           rfcat
Version:        2.0.1
Release:        0
Summary:        The swiss army knife of subGHz
License:        BSD-2-Clause
Group:          Productivity/Hamradio/Other
URL:            https://github.com/atlas0fd00m/rfcat
Source:         https://github.com/atlas0fd00m/rfcat/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
BuildRequires:  python3-future
BuildRequires:  python3-numpy
BuildRequires:  python3-pyserial
BuildRequires:  python3-pytest
BuildRequires:  python3-usb
BuildRequires:  python3-pyside2
BuildRequires:  python3-setuptools
Requires:       %{name}-udev
Requires:       python3-future
Requires:       python3-numpy
Requires:       python3-usb
Requires:       python3-pyside2
Requires:       python3-pyserial
Recommends:     python3-ipython
BuildArch:      noarch

%description
RfCat allows you to control the wireless transceiver from an interactive
Python shell or your own program running on your computer.

%package udev
Summary:        Udev rules for rfcat
Group:          Hardware/Other
Requires(pre):  shadow

%description udev
Udev rules for rfcat.

%prep
%setup -q

## Remove files that may be problematic from a license point of view
rm firmware/cc1111_vcom.c
rm firmware/cc1111_vcomdesc.c
rm firmware/include/cc1111_vcom.h
## HACK: set udev group to rfcat
sed -i 's|GROUP="dialout"|GROUP="rfcat"|g' etc/udev/rules.d/20-rfcat.rules

# These are a mix of python and ipython interpreters in the hashbang,
# but residing inside the site-packages and they have relative imports
# making them not executable as-is.
sed -i '1{/#!/d}' rflib/*.py

%build
%python3_build

%install
%python3_install
%fdupes %{buildroot}/%{python3_sitelib}
install -Dpm0644 etc/udev/rules.d/20-rfcat.rules %{buildroot}%{_udevrulesdir}/20-rfcat.rules
# Remove tests from sitelib
rm -R %{buildroot}%{python3_sitelib}/tests

%check
python3 -m pytest -vv

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

%post udev
%udev_rules_update

%postun udev
%udev_rules_update

%files
%license LICENSE
%doc README.md README.immesniff README.msfrelay README.nonroot README.rst
%{_bindir}/rfcat
%{_bindir}/rfcat_bootloader
%{_bindir}/rfcat_msfrelay
%{_bindir}/rfcat_server
%{python3_sitelib}/rflib
%{python3_sitelib}/rfcat-%{version}-py%{py3_ver}.egg-info

%files udev
%{_udevrulesdir}/20-rfcat.rules

%changelog
openSUSE Build Service is sponsored by