Blame netcat.spec

66ecafb
%global commit 03fa76f835e0954845b206c6f0cadf39975ba82c
0396422
c8a5240
%if 0%{?fedora} || 0%{?rhel} > 8
0396422
%global link_bin nc
0396422
%global link_man nc-man
0396422
%else
0396422
%global link_bin nmap
0396422
%global link_man ncman
0396422
%endif
0396422
e7e6781
Summary:         OpenBSD netcat to read and write data across connections using TCP or UDP
0396422
Name:            netcat
0396422
# Version from CVS revision of OpenBSD netcat.c
66ecafb
Version:         1.226
f4b40e5
Release:         3%{?dist}
4b06f69
# BSD-3-Clause: nc.1 and netcat.c
4b06f69
# BSD-2-Clause: atomicio.{c,h} and socks.c
4b06f69
License:         BSD-3-Clause AND BSD-2-Clause
0396422
URL:             https://man.openbsd.org/nc.1
0396422
Source0:         https://raw.githubusercontent.com/openbsd/src/%{commit}/usr.bin/nc/netcat.c
0396422
Source1:         https://raw.githubusercontent.com/openbsd/src/%{commit}/usr.bin/nc/nc.1
0396422
Source2:         https://raw.githubusercontent.com/openbsd/src/%{commit}/usr.bin/nc/atomicio.c
0396422
Source3:         https://raw.githubusercontent.com/openbsd/src/%{commit}/usr.bin/nc/atomicio.h
0396422
Source4:         https://raw.githubusercontent.com/openbsd/src/%{commit}/usr.bin/nc/socks.c
0396422
Source5:         https://raw.githubusercontent.com/openbsd/src/%{commit}/usr.bin/nc/Makefile
0396422
# Port peculiarities from OpenBSD to Linux
b9d4195
Patch0:          https://salsa.debian.org/debian/netcat-openbsd/-/raw/08f1670e0f7c682b3a86335c026a2df62daab3d4/debian/patches/port-to-linux-with-libbsd.patch
0396422
BuildRequires:   make
0396422
BuildRequires:   gcc
0396422
BuildRequires:   libbsd-devel
0396422
BuildRequires:   libretls-devel
0396422
Requires(post):  %{_sbindir}/alternatives
0396422
Requires(preun): %{_sbindir}/alternatives
0396422
0396422
%description
0396422
The OpenBSD nc (or netcat) utility can be used for just about anything involving
0396422
TCP, UDP, or UNIX-domain sockets. It can open TCP connections, send UDP packets,
0396422
listen on arbitrary TCP and UDP ports, do port scanning, and deal with both IPv4
0396422
and IPv6. Unlike telnet(1), nc scripts nicely, and separates error messages onto
0396422
standard error instead of sending them to standard output, as telnet(1) might do
0396422
with some.
0396422
0396422
%prep
0396422
%setup -q -T -c
0396422
cp -pf %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} %{SOURCE5} .
f5bd06f
%patch0 -p1 -b .port-to-linux-with-libbsd
0396422
sed -e '1i #define unveil(path, permissions) 0' \
0396422
    -e '1i #define pledge(request, paths) 0' \
0396422
    -i netcat.c
0396422
sed -e 's/^\(LIBS=.*\)/\1 -ltls/' -i Makefile
0396422
b9d4195
%if 0%{?eln}
b9d4195
echo "The netcat package is not intended for ELN: Red Hat decided explicitly to switch from OpenBSD nc to Nmap ncat for RHEL; see also:"
b9d4195
echo "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/sec-managing_data_using_the_ncat_utility"
b9d4195
exit 1
b9d4195
%endif
b9d4195
0396422
%build
0396422
%make_build CFLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_LD_FLAGS"
0396422
0396422
%install
0396422
install -D -p -m 0755 nc $RPM_BUILD_ROOT%{_bindir}/%{name}
0396422
install -D -p -m 0644 nc.1 $RPM_BUILD_ROOT%{_mandir}/man1/%{name}.1
0396422
0396422
touch $RPM_BUILD_ROOT%{_bindir}/nc
0396422
touch $RPM_BUILD_ROOT%{_mandir}/man1/nc.1.gz
0396422
0396422
%post
0396422
%{_sbindir}/alternatives --install %{_bindir}/nc %{link_bin} %{_bindir}/%{name} 10 \
0396422
  --slave %{_mandir}/man1/nc.1.gz %{link_man} %{_mandir}/man1/%{name}.1.gz
0396422
0396422
%preun
0396422
if [ $1 -eq 0 ]; then
0396422
  %{_sbindir}/alternatives --remove %{link_bin} %{_bindir}/%{name}
0396422
fi
0396422
0396422
%files
0396422
%ghost %{_bindir}/nc
0396422
%ghost %{_mandir}/man1/nc.1.gz
0396422
%{_bindir}/netcat
0396422
%{_mandir}/man1/netcat.1*
0396422
0396422
%changelog
f4b40e5
* Thu Jan 25 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.226-3
f4b40e5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
f4b40e5
78f072a
* Sun Jan 21 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.226-2
78f072a
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
78f072a
66ecafb
* Tue Nov 14 2023 Robert Scheck <robert@fedoraproject.org> 1.226-1
66ecafb
- Upgrade to 1.226 (#2244540)
66ecafb
4b894e4
* Sun Nov 05 2023 Robert Scheck <robert@fedoraproject.org> 1.225-3
4b894e4
- Rebuilt for libretls 3.8.1
4b894e4
c6b61ab
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.225-2
c6b61ab
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
c6b61ab
b9d4195
* Sun Jun 11 2023 Robert Scheck <robert@fedoraproject.org> 1.225-1
b9d4195
- Upgrade to 1.225 (#2214050)
b9d4195
62aa61e
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.219-3
62aa61e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
62aa61e
161a3c4
* Sat Dec 24 2022 Robert Scheck <robert@fedoraproject.org> 1.219-2
161a3c4
- Rebuilt for libretls 3.7.0
161a3c4
f5bd06f
* Sun Oct 23 2022 Robert Scheck <robert@fedoraproject.org> 1.219-1
f5bd06f
- Upgrade to 1.219 (#2136750)
f5bd06f
a2c5d28
* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.218-6
a2c5d28
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
a2c5d28
4f1c336
* Sat May 14 2022 Robert Scheck <robert@fedoraproject.org> 1.218-5
4f1c336
- Rebuilt for libretls 3.5.2
4f1c336
c8a5240
* Sun Feb 27 2022 Robert Scheck <robert@fedoraproject.org> 1.218-4
c8a5240
- Rebuilt for libretls 3.5.0
c8a5240
1a1d027
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.218-3
1a1d027
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
1a1d027
b90c21e
* Sat Oct 16 2021 Robert Scheck <robert@fedoraproject.org> 1.218-2
b90c21e
- Rebuilt for libretls 3.4.1
b90c21e
fa3031e
* Mon Aug 30 2021 Robert Scheck <robert@fedoraproject.org> 1.218-1
fa3031e
- Upgrade to 1.218 (#1993735)
fa3031e
fb1c9ad
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.217-4
fb1c9ad
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
fb1c9ad
0396422
* Wed Mar 17 2021 Robert Scheck <robert@fedoraproject.org> 1.217-3
0396422
- Changes to match the Fedora Packaging Guidelines (#1939769 #c1)
0396422
0396422
* Wed Mar 17 2021 Robert Scheck <robert@fedoraproject.org> 1.217-2
0396422
- Changes to match the Fedora Packaging Guidelines (#1939769)
0396422
0396422
* Sun Mar 07 2021 Robert Scheck <robert@fedoraproject.org> 1.217-1
0396422
- Upgrade to 1.217
0396422
- Initial spec file for Fedora and Red Hat Enterprise Linux