File atftp.spec of Package atftp

# spec file for package atftp
# Copyright (c) 2012 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
%define pkg_version 0.7

Name:           atftp
Summary:        Advanced TFTP Server and Client
License:        GPL-2.0+
Group:          System/Daemons
Version:        0.7.0
Release:        0
Source:         %{name}-%{pkg_version}.tar.bz2
Source1:        atftpd.init.d
Source2:        atftpd.sysconfig
Source3:        atftpd.logrotate
Patch1:         atftp-0.7.dif
Patch2:         atftp-CLK_TCK.diff
Patch3:         atftp-0.7_compiler_warnings.patch
Patch4:         atftp-0.7_thread_crash.patch
Patch5:         atftp-0.7_sol_ip.patch
Patch6:         atftp-0.7_bug-213384_OPT_NUMBER.patch
Patch7:         atftpd-0.7_unprotected_assignments_crash.patch
Patch8:         atftpd-0.7_circumvent_tftp_size_restrictions.patch
# PATCH-FIX-SUSE sorcerer's apprentice syndrom (bnc#727843)
Patch9:         atftp-0.7-sorcerers_apprentice.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
PreReq:         %insserv_prereq  %fillup_prereq
PreReq:         pwdutils
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  pcre-devel
BuildRequires:  readline-devel
BuildRequires:  tcpd-devel
Conflicts:      tftp
Recommends:     logrotate

atftp stands for Advanced Trivial File Transfer Protocol. It is called
"advanced", in contrast to others TFTP servers, for two reasons. First,
it is intended to be fully compliant with all related RFCs. This
includes RFC1350, RFC2090, RFC2347, RFC2348, and RFC2349. Second, atftp
is intended for serving boot files to large clusters. It is
multithreaded and will eventually support multicast, allowing faster
boot of hundreds of machines simultaneously.

%setup -q -n %{name}-%{pkg_version}
%patch9 -p1

autoreconf -fi
make %{?_smp_mflags}

# SuSE rc
%{__install} -D -m 0755 %{S:1} %{buildroot}/etc/init.d/atftpd
%{__ln_s} -f ../../etc/init.d/atftpd %{buildroot}%{_sbindir}/rcatftpd
%{__install} -D -m 0644 %{S:2} %{buildroot}/var/adm/fillup-templates/sysconfig.atftpd
%{__install} -D -m 0644 %{S:3} %{buildroot}/etc/logrotate.d/%{name}
%{__install} -d -m 0750 %{buildroot}/srv/tftpboot
%{__install} -d -m 0750 %{buildroot}/var/log/atftpd

# This group/user is shared with tftp, so please
# keep this in sync with tftp.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 || :
# fix sysconfig to get new defaults on Update
if [ -f /etc/sysconfig/atftpd ]; then
  %{__sed} -i -e "s@^\(ATFTPD_OPTIONS=\"--daemon \"\)@#\1@" /etc/sysconfig/atftpd
  %{__sed} -i -e "s@^\(ATFTPD_DIRECTORY=\"/tftpboot\"\)@#\1@" /etc/sysconfig/atftpd

%stop_on_removal atftpd

%{fillup_only -n atftpd}

%restart_on_update atftpd

%config /etc/logrotate.d/%{name}
%dir %attr(0750,root,tftp) /srv/tftpboot
%dir %attr(0750,tftp,root) /var/log/atftpd/