%define name zenmap
%define version @VERSION@
%define release 1
%define _prefix /usr

Summary: Multi-platform graphical Nmap frontend and results viewer
Name: %{name}
Version: %{version}
Release: %{release}
Epoch: 1
License: https://nmap.org/man/man-legal.html
Group: Applications/System
Source0: https://nmap.org/dist/nmap-%{version}.tgz
URL: https://nmap.org/zenmap/
BuildArch: noarch

BuildRequires: python3-devel
# Add any build-time deps declared in pyproject.toml [build-system.requires]
BuildRequires: python3-setuptools, python3-wheel, python3-build, python3-setuptools-gettext
BuildRequires: desktop-file-utils
Requires: python3 >= 3.8, nmap, python3-gobject, gtk3
%global debug_package %{nil}

Prefix: %{_prefix}
BuildRoot: %{_tmppath}/%{name}-root

%global _description %{expand:
The Nmap frontend. It is meant to be useful for advanced users
and to make Nmap easy to use by beginners. It was originally derived
from Umit, an Nmap GUI created as part of the Google Summer of Code.}

%description %{_description}

%package -n python3-%{name}
Summary: %{summary}

%description -n python3-%{name} %{_description}

%prep
%autosetup -n nmap-%{version}

%generate_buildrequires
cd zenmap/
%pyproject_buildrequires

%build
cp ndiff/ndiff.py zenmap/ndiff.py
cd zenmap/
%pyproject_wheel

%install
install -Dpm 0644 docs/zenmap.1 %{buildroot}%{_mandir}/man1/zenmap.1
install -Dpm 0644 -t %{buildroot}%{_datadir}/applications/ zenmap/install_scripts/unix/*.desktop
install -Dpm 0644 zenmap/zenmapCore/data/pixmaps/zenmap.png %{buildroot}%{_datadir}/icons/hicolor/256x256/apps/zenmap.png
install -Dpm 0644 ndiff/docs/ndiff.1 %{buildroot}%{_mandir}/man1/ndiff.1
# Don't package the uninstaller with the RPM.
rm -f %{buildroot}%{_bindir}/uninstall_zenmap
rm -f %{buildroot}%{_bindir}/uninstall_ndiff
%pyproject_install
%pyproject_save_files zenmapCore zenmapGUI radialnet ndiff

%clean
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT

%check
%pyproject_check_import zenmapCore zenmapGUI radialnet ndiff
desktop-file-validate %{buildroot}%{_datadir}/applications/zenmap.desktop

%files -f %{pyproject_files}
%doc zenmap/README
%doc %{_mandir}/man1/*.1*
%license zenmap/LICENSE
%license zenmap/COPYING_HIGWIDGETS
%{_bindir}/zenmap
%{_bindir}/ndiff
%{_datadir}/applications/*.desktop
%{_datadir}/icons/hicolor/256x256/apps/zenmap.png

%changelog

* Sat Jun 06 2009 Fyodor (fyodor(a)insecure.org)
- Removed changelog entries as SVN is a more authoritative source. Execute:
- svn log --username guest --password "" https://svn.nmap.org/nmap/zenmap.spec.in
