File netcat-openbsd.spec of Package netcat-openbsd

#
# spec file for package netcat-openbsd
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#


Url:            http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/nc/

Name:           netcat-openbsd
Version:        1.89
Release:        0
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  cmake
PreReq:         update-alternatives
Summary:        TCP/IP swiss army knife
License:        BSD-3-Clause
Group:          Productivity/Networking/Other
Source:         %{name}-%{version}.tar.bz2
Source1:        CMakeLists.txt
Patch0:         netcat-openbsd-openbsd-compat.patch
Patch1:         socks-b64-prototype.patch
Patch2:         silence-z.patch
Patch3:         glib-strlcpy.patch
Patch4:         no-strtonum.patch
Patch5:         pollhup.patch
Patch6:         reuseaddr.patch
Patch7:         connect-timeout.patch
Patch8:         udp-scan-timeout.patch
Patch9:         verbose-numeric-port.patch
Patch10:        send-crlf.patch
Patch11:        help-version-exit.patch
Patch12:        quit-timer.patch
Patch13:        getservbyname.patch
Patch14:        gcc-warnings.patch
Patch15:        verbose-message-to-stderr.patch
Patch16:        netcat-info.patch
Patch17:        dccp.patch
#These are patches, but as they aren't applied list them as source
Source2:        nc-1.84-udp_stop.patch
Source3:        netcat-openbsd-debian.patch
Source4:        netcat-openbsd-examples.patch

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
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
cp %{S:1} .

%build
export CFLAGS="%{optflags}"
cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} .
make %{?jobs:-j%{jobs}}

%install
make DESTDIR=%{buildroot} install
mkdir -p %{buildroot}/etc/alternatives
touch %{buildroot}/etc/alternatives/netcat \
      %{buildroot}/etc/alternatives/netcat.1.gz
ln -s -f %{_bindir}/nc %{buildroot}/%{_bindir}/netcat
ln -s -f nc.1.gz %{buildroot}/%{_mandir}/man1/netcat.1.gz

%clean

%files
%defattr(-,root,root)
%{_bindir}/nc
%ghost %{_bindir}/netcat
%{_mandir}/man1/nc.1.gz
%ghost %{_mandir}/man1/netcat.1.gz
%ghost /etc/alternatives/netcat
%ghost /etc/alternatives/netcat.1.gz

%post
/usr/sbin/update-alternatives --install \
	%{_bindir}/netcat netcat %{_bindir}/nc 10 \
	--slave %{_mandir}/man1/netcat.1.gz netcat.1.gz %{_mandir}/man1/nc.1.gz

%preun
if [ "$1" = 0 ] ; then
	/usr/sbin/update-alternatives --remove \
		netcat %{_bindir}/nc
fi

%changelog
openSUSE Build Service is sponsored by