#
# spec file for package netcat-openbsd
#
# Copyright (c) 2021 SUSE LLC
#
# 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/
#


Name:           netcat-openbsd
Version:        1.203
Release:        5.1
Summary:        TCP/IP swiss army knife
License:        BSD-3-Clause
Group:          Productivity/Networking/Other
URL:            https://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/nc/
Source0:        http://old.kali.org/kali/pool/main/n/netcat-openbsd/netcat-openbsd_%{version}.orig.tar.gz
#Patches from: http://http.debian.net/debian/pool/main/n/netcat-openbsd/netcat-openbsd_%{version}-2.debian.tar.xz
Patch0:         port-to-linux-with-libsd.patch
Patch1:         build-without-TLS-support.patch
Patch2:         connect-timeout.patch
Patch3:         get-sev-by-name.patch
Patch4:         send-crlf.patch
Patch5:         quit-timer.patch
Patch6:         udp-scan-timeout.patch
Patch7:         dccp-support.patch
Patch8:         broadcast-support.patch
Patch9:         serialized-handling-multiple-clients.patch
Patch10:        set-TCP-MD5SIG-correctly-for-client-connections.patch
Patch11:        destination-port-list.patch
Patch12:        use-flags-to-specify-listen-address.patch
Patch13:        misc-failures-and-features.patch
Patch14:        port-select-on-connect.patch
Patch15:        enable-udp-ip_recverr.patch
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(libbsd)
Provides:       nc6 = %{version}
Provides:       netcat = %{version}
Obsoletes:      nc6 <= 1.0
Obsoletes:      netcat <= 1.10

%description
A simple Unix utility which reads and writes data across network
connections using TCP or UDP protocol. It is designed to be a reliable
"back-end" tool that can be used directly or easily driven by other
programs and scripts. At the same time it is a feature-rich network
debugging and exploration tool, since it can create almost any kind of
connection you would need and has several interesting built-in
capabilities.

This package contains the OpenBSD rewrite of netcat, including support
for IPv6, proxies, and Unix sockets.

%prep
%setup -q
%autopatch -p1

%build
make %{?_smp_mflags} \
  CFLAGS="%{optflags} -fvisibility=hidden -std=gnu99"

%install
install -D -m0755 nc %{buildroot}%{_bindir}/nc
install -D -m0644 nc.1 %{buildroot}/%{_mandir}/man1/nc.1
ln -s -f %{_bindir}/nc %{buildroot}/%{_bindir}/netcat
ln -s -f nc.1%{ext_man} %{buildroot}/%{_mandir}/man1/netcat.1%{ext_man}

%files
%{_bindir}/nc
%{_bindir}/netcat
%{_mandir}/man1/nc.1%{?ext_man}
%{_mandir}/man1/netcat.1%{?ext_man}

%changelog
* Tue Apr  8 2025 Friedrich Haubensak <hsk17@mail.de>
- add -std=gnu99 to CFLAGS to fix gcc15 compile time errors
* Mon Nov 22 2021 Peter Simons <psimons@suse.com>
- Fix download URL. Debian has purged older versions from their
  servers.
* Tue Dec 15 2020 Cristian Rodríguez <crrodriguez@opensuse.org>
- Build with hidden visibility since no symbols should be exported
* Tue Dec 15 2020 Cristian Rodríguez <crrodriguez@opensuse.org>
- enable-udp-ip_recverr.patch: Enable IP_RECVERR on UDP sockets
  to match *bsd behaviour and avoid long timeouts if an error
  ocurrs.
* Mon Dec  7 2020 Cristian Rodríguez <crrodriguez@opensuse.org>
- Add port-select-on-connect.patch: if -s is given but not -p
  do not select port at bind() but at connect() time.
* Mon Sep  9 2019 Tomáš Chvátal <tchvatal@suse.com>
- Update to 1.203 matching debian
- Remove patch verbose-numeric-port.patch
- Refresh patches:
  * broadcast-support.patch
  * build-without-TLS-support.patch
  * connect-timeout.patch
  * dccp-support.patch
  * destination-port-list.patch
  * get-sev-by-name.patch
  * misc-failures-and-features.patch
  * port-to-linux-with-libsd.patch
  * quit-timer.patch
  * send-crlf.patch
  * serialized-handling-multiple-clients.patch
  * set-TCP-MD5SIG-correctly-for-client-connections.patch
  * udp-scan-timeout.patch
  * use-flags-to-specify-listen-address.patch
* Wed Nov 14 2018 Tomáš Chvátal <tchvatal@suse.com>
- Update to 1.195 release matching with debian
- Added new patches:
  * broadcast-support.patch
  * build-without-TLS-support.patch
  * destination-port-list.patch
  * use-flags-to-specify-listen-address.patch
- Refreshed patches:
  * connect-timeout.patch
  * dccp-support.patch
  * get-sev-by-name.patch
  * misc-failures-and-features.patch
  * port-to-linux-with-libsd.patch
  * quit-timer.patch
  * send-crlf.patch
  * serialized-handling-multiple-clients.patch
  * set-TCP-MD5SIG-correctly-for-client-connections.patch
  * udp-scan-timeout.patch
  * verbose-numeric-port.patch
- Drop patch compile-without-TLS-support.patch, renamed
* Mon Jul 17 2017 tchvatal@suse.com
- Drop all patches that were never upstreamed:
  * connect-timeout.patch
  * dccp.patch
  * gcc-warnings.patch
  * getservbyname.patch
  * glib-strlcpy.patch
  * help-version-exit.patch
  * nc-1.84-udp_stop.patch
  * netcat-info.patch
  * netcat-openbsd-debian.patch
  * netcat-openbsd-examples.patch
  * netcat-openbsd-openbsd-compat.patch
  * no-strtonum.patch
  * pollhup.patch
  * quit-timer.patch
  * reuseaddr.patch
  * send-crlf.patch
  * silence-z.patch
  * socks-b64-prototype.patch
  * udp-scan-timeout.patch
  * verbose-message-to-stderr.patch
  * verbose-numeric-port.patch
- Switch to debian package to not waste resources on doing exactly
  the same.
- Switches URL for debian package
- Apply patches already prepared for debian package
  * port-to-linux-with-libsd.patch
  * compile-without-TLS-support.patch
  * connect-timeout.patch
  * get-sev-by-name.patch
  * send-crlf.patch
  * quit-timer.patch
  * udp-scan-timeout.patch
  * verbose-numeric-port.patch
  * dccp-support.patch
  * serialized-handling-multiple-clients.patch
  * set-TCP-MD5SIG-correctly-for-client-connections.patch
  * misc-failures-and-features.patch
- Do not use hand provided CMakeLists.txt but rely on upstream makefile
* Fri Jan 17 2014 crrodriguez@opensuse.org
- drop dependency on glib, strlcpy can be implemented with
  snprintf with glibc/linux
- drop "quilt" from buildrequires, no longer used.
- Use fvisibiliy=hidden to build, this is a program not
  a library and no symbols should be exported.
- modified patches:
  * glib-strlcpy.patch
* Mon Sep  2 2013 pth@suse.de
- Split up the huge ubuntu patch into a debian specific patch,
  a patch that creates the examples, a patch with the openbasd-compat
  stuff and single files for each of the patches in debian/patches.
  This hugely eases maintainabilty:
  connect-timeout.patch, dccp.patch, gcc-warnings.patch,
  getservbyname.patch, glib-strlcpy.patch, help-version-exit.patch,
  nc-1.84-udp_stop.patch, netcat-info.patch, netcat-openbsd-debian.patch,
  netcat-openbsd-examples.patch, netcat-openbsd-openbsd-compat.patch,
  no-strtonum.patch, pollhup.patch, quit-timer.patch, reuseaddr.patch,
  send-crlf.patch, silence-z.patch, socks-b64-prototype.patch,
  udp-scan-timeout.patch, verbose-message-to-stderr.patch,
  verbose-numeric-port.patch.
* Sat Dec 10 2011 crrodriguez@opensuse.org
- Update xbuntu patches.
- Ensure we have large file support in 32 bit builds
- Fix rpmlint warnings
* Sat Jul 16 2011 andrea.turrini@gmail.com
- Fixed typos in description of netcat-openbsd.spec
* Fri Jun 25 2010 lmuelle@suse.de
- Use update-alternatives to set netcat symbolic links for compatibility.
- Provides and obsoltes netcat.
* Fri May 28 2010 cristian.rodriguez@opensuse.org
- Obsolete nc6
* Tue May 18 2010 cristian.rodriguez@opensuse.org
- sync recent bugfixes from Ubuntu
* Fri Feb 20 2009 crrodriguez@suse.de
- sync most recent bugfixes from debian/Ubuntu
* Sat Jul  5 2008 crrodriguez@suse.de
-  netcat-openbsd conflicts with netcat but it should not [BNC#406581]
* Sun Apr 13 2008 crrodriguez@suse.de
- initial version for the OBS