%global pkgvers 0
%global scdate0 20241111
%global schash0 6abdd54185268efe59fc16913ead6046e98c9834
%global branch0 master
%global source0 https://github.com/jopohl/urh.git

%global sshort0 %{expand:%%{lua:print(('%{schash0}'):sub(1,8))}}

Name:           urh
Version:        2.9.8
Release:        %{scdate0}.%{pkgvers}.git%{sshort0}%{?dist}
Summary:        Universal Radio Hacker
License:        GPLv3

URL:            https://github.com/jopohl/urh

BuildRequires:  git gcc-c++ make python3 python3-setuptools
BuildRequires:  python3-devel python3-numpy python3-psutil
BuildRequires:  limesuite-devel airspyhf-devel bladerf-devel hackrf-devel
BuildRequires:  uhd-devel rtl-sdr-devel libiio-devel python3-qt5 desktop-file-utils
Requires:       python3-numpy python3-qt5
%if 0%{?fedora} > 39
BuildRequires: python3-Cython
%else
BuildRequires: ((python3dist(cython) > 0.23) with (python3dist(cython) < 3~~))
%endif

%description
The Universal Radio Hacker (URH) is a complete suite for
wireless protocol investigation with native support for
many common Software Defined Radios.


%prep
%setup -T -c -n %{name}
git clone --depth 1 -n -b %{branch0} %{source0} .
git fetch --depth 1 origin %{schash0}
git reset --hard %{schash0}
git log --format=fuller


%build
%py3_build

# remove *.pyc
find . -name '*.pyc' | xargs rm -f

# remove profiling data
pushd data
rm -f hacker.prof
popd

# remove binaries
pushd data/decodings
rm -f enocean_switchtelegram homematic homematic_complete test
popd
pushd src/urh/dev/native/lib
rm -rf win
popd


%install
%py3_install

# remove cpp files generated by cython
pushd %{buildroot}%{python3_sitearch}/urh/dev/native/lib
rm -f *.cpp
popd
pushd %{buildroot}%{python3_sitearch}/urh/cythonext
rm -f *.cpp
popd

# icon
install -Dpm 0644 data/icons/appicon.png %{buildroot}%{_datadir}/icons/hicolor/128x128/apps/urh.png

# desktop file
mkdir -p  %{buildroot}%{_datadir}/applications
desktop-file-install --add-category="Utility" \
  --dir=%{buildroot}%{_datadir}/applications \
  data/urh.desktop



%files
%doc README.md
%license LICENSE
%{_bindir}/*
%{_datadir}/applications/urh.desktop
%{_datadir}/icons/hicolor/128x128/apps/urh.png
%{python3_sitearch}/*


%changelog
* Sun Apr 24 2022 Balint Cristian <cristian.balint@gmail.com>
- github update releases