File tftp.spec of Package tftp

# spec file for package tftp
# Copyright (c) 2017 SUSE LINUX 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

%define _fwdefdir /etc/sysconfig/SuSEfirewall2.d/services
%if 0%{?suse_version} >= 1230
%define _systemddir /usr/lib/systemd/
%define _systemddir /lib/systemd/
%define _unitdir %{_systemddir}/system

Name:           tftp
Version:        5.2
Release:        0
Summary:        Trivial File Transfer Protocol (TFTP)
License:        BSD-3-Clause
Group:          Productivity/Networking/Ftp/Clients
Source1:        tftp.xinetd
Source2:        tftp.fw
Source3:        tftp.service
Source4:        tftp.socket
Patch0:         tftp-hpa-0.43_include_sys_params.patch
Patch1:         tftp-hpa-0.46_colon_check.patch
Patch4:         tftp-hpa-0.49-fortify-strcpy-crash.patch
Patch5:         tftp-hpa-0.48-tzfix.patch
Patch42:        tftp-hpa-0.43_old-autoconf.diff
Patch6:         tftp-multi-addresses.patch
Patch7:         tftp-hpa-0.48-macros-crash.patch
Patch8:         tftp-hpa-0.48-macros-v6mapped.patch
Provides:       tftp(client)
Provides:       tftp(server)
PreReq:         pwdutils
BuildRequires:  autoconf
BuildRequires:  pwdutils
BuildRequires:  tcpd-devel
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} > 1110
BuildRequires:  binutils-devel
Recommends:     inet-daemon
Requires:       netcfg
Conflicts:      atftp

The Trivial File Transfer Protocol (TFTP) is normally used only for
booting diskless workstations and for getting or saving network
component configuration files.

%setup -n %{name}-hpa-%{version}
%patch4 -p1
%patch5 -p1
%patch6 -p1
%if 0%{?suse_version} < 1030

autoreconf -fi
%configure \
  --enable-largefile \
  --with-tcpwrappers \
  --with-remap \
  --without-editline \

%makeinstall INSTALLROOT=%{buildroot} MANDIR="%{_mandir}"
install -D -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/xinetd.d/tftp
mkdir -p $RPM_BUILD_ROOT/%{_fwdefdir}
install -m 644 %SOURCE2 $RPM_BUILD_ROOT/%{_fwdefdir}/tftp
install -d -m 0755 %{buildroot}/srv/tftpboot

# Install systemd unit / socket (As an alternativ to xinetd activation)
install -d %{buildroot}%{_unitdir}
install -m 0644 %{S:3} %{S:4} %{buildroot}%{_unitdir}

# This group/user is shared with atftp, so please
# keep this in sync with atftp.spec
# add group
%{_sbindir}/groupadd -r tftp 2>/dev/null || :
# add user
%{_sbindir}/useradd -c "TFTP account" -d /srv/tftpboot -G tftp -g tftp \
  -r -s /bin/false tftp 2>/dev/null || :

rm -rf %{buildroot};

%doc README tftpd/sample.rules
%dir %{_systemddir}
%dir %{_unitdir}
%config(noreplace) %{_sysconfdir}/xinetd.d/tftp
%config %{_fwdefdir}/tftp
%dir %attr(0755,tftp,tftp) /srv/tftpboot