tftp/tftp.spec

Mon, 25 Aug 2014 19:07:19 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Mon, 25 Aug 2014 19:07:19 +0200
changeset 796
02101011a9bc
parent 795
ef076e9bc56b
permissions
-rw-r--r--

Correct process identification writing of PID file on -P parameter.

     1 ##
     2 ##  tftp.spec -- OpenPKG RPM Package Specification
     3 ##  Copyright (c) 2000-2014 OpenPKG Foundation e.V. <http://openpkg.net/>
     4 ##
     5 ##  Permission to use, copy, modify, and distribute this software for
     6 ##  any purpose with or without fee is hereby granted, provided that
     7 ##  the above copyright notice and this permission notice appear in all
     8 ##  copies.
     9 ##
    10 ##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    11 ##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    12 ##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    13 ##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
    14 ##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    15 ##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    16 ##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    17 ##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    18 ##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    19 ##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    20 ##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    21 ##  SUCH DAMAGE.
    22 ##
    24 #   package information
    25 Name:         tftp
    26 Summary:      TFTP Client and Server
    27 URL:          http://www.kernel.org/pub/software/network/tftp/
    28 Vendor:       H. Peter Anvin
    29 Packager:     OpenPKG Foundation e.V.
    30 Distribution: OpenPKG Community
    31 Class:        BASE
    32 Group:        FTP
    33 License:      GPL
    34 Version:      5.2
    35 Release:      20140800
    37 #   package options
    38 %option       with_fsl  yes
    40 #   list of sources
    41 Source0:      http://www.kernel.org/pub/software/network/tftp/tftp-hpa/tftp-hpa-%{version}.tar.gz
    42 Source1:      tftpd.remap
    43 Source2:      rc.tftp
    44 Source3:      fsl.tftp
    45 Patch0:       tftp.patch
    47 #   build information
    48 BuildPreReq:  OpenPKG, openpkg >= 20100101, make, gcc
    49 PreReq:       OpenPKG, openpkg >= 20100101
    50 BuildPreReq:  getopt
    51 PreReq:       getopt
    52 %if "%{with_fsl}" == "yes"
    53 BuildPreReq:  fsl
    54 PreReq:       fsl
    55 %endif
    57 %description
    58     This is a portable client and server for the Trivial File Transfer
    59     Protocol (TFTP).
    61 %track
    62     prog tftp = {
    63         version   = %{version}
    64         url       = http://www.kernel.org/pub/software/network/tftp/tftp-hpa/
    65         regex     = tftp-hpa-(__VER__)\.tar\.gz
    66     }
    68 %prep
    69     %setup -q -n tftp-hpa-%{version}
    70     %patch -p0
    71     %{l_shtool} subst -e 's;PKTSIZE;TFTP_PKTSIZE;g' */*.[ch]
    73 %build
    74     export CC="%{l_cc}"
    75     export CFLAGS="%{l_cflags -O} %{l_cppflags} -DPID_FILE='\"%{l_prefix}/var/tftp/tftpd.pid\"'"
    76     export CPPFLAGS="%{l_cppflags}"
    77     export LDFLAGS="%{l_ldflags} %{l_fsl_ldflags}"
    78     export LIBS="%{l_fsl_libs} -lgetopt"
    79     case "%{l_platform -t}" in
    80         *-netbsd* )
    81             CFLAGS="$CFLAGS -D_NETBSD_SOURCE"
    82             CPPFLAGS="$CPPFLAGS -D_NETBSD_SOURCE"
    83             ;;
    84     esac
    85     ./configure \
    86         --prefix=%{l_prefix} \
    87         --mandir=%{l_prefix}/man \
    88         --with-remap \
    89         --without-tcpwrappers \
    90         --without-readline
    91     %{l_shtool} subst -e 's; -W[^ ]*;;g' MCONFIG
    92     %{l_make} %{l_mflags}
    94 %install
    95     %{l_shtool} mkdir -f -p -m 755 \
    96         $RPM_BUILD_ROOT%{l_prefix}/var/tftp \
    97         $RPM_BUILD_ROOT%{l_prefix}/etc/tftp \
    98         $RPM_BUILD_ROOT%{l_prefix}/var/tftp
    99     %{l_make} %{l_mflags} install \
   100         INSTALL="%{l_shtool} install -c" \
   101         INSTALLROOT=$RPM_BUILD_ROOT
   102     %{l_shtool} install -c -m 644 %{l_value -s -a} \
   103         %{SOURCE tftpd.remap} $RPM_BUILD_ROOT%{l_prefix}/etc/tftp/
   104     rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man8/tftpd.8
   105     mv  $RPM_BUILD_ROOT%{l_prefix}/man/man8/in.tftpd.8 \
   106         $RPM_BUILD_ROOT%{l_prefix}/man/man8/tftpd.8
   107     mv  $RPM_BUILD_ROOT%{l_prefix}/sbin/in.tftpd \
   108         $RPM_BUILD_ROOT%{l_prefix}/sbin/tftpd
   109     strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
   110     strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
   112     #   install run-command script
   113     %{l_shtool} mkdir -f -p -m 755 \
   114         $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
   115     %{l_shtool} install -c -m 755 %{l_value -s -a} \
   116         %{SOURCE rc.tftp} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
   118     #   install OSSP fsl configuration
   119     %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
   120     %{l_shtool} install -c -m 644 %{l_value -s -a} \
   121         %{SOURCE fsl.tftp} \
   122         $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
   124     #   determine installation files
   125     %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
   126         %{l_files_std} \
   127         '%config %{l_prefix}/etc/fsl/fsl.tftp' \
   128         '%config %{l_prefix}/etc/tftp/*'
   130 %files -f files
   132 %clean
   134 %pre
   135     #   before upgrade, save status and stop service
   136     [ $1 -eq 2 ] || exit 0
   137     eval `%{l_rc} tftp status 2>/dev/null | tee %{l_tmpfile}`
   138     %{l_rc} tftp stop 2>/dev/null
   139     exit 0
   141 %post
   142     if [ $1 -eq 2 ]; then
   143         #   after upgrade, restore status
   144         eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}
   145         [ ".$tftp_active" = .yes ] && %{l_rc} tftp start
   146     fi
   147     exit 0
   149 %preun
   150     #   before erase, stop service and remove log files
   151     [ $1 -eq 0 ] || exit 0
   152     %{l_rc} tftp stop 2>/dev/null
   153     rm -f $RPM_INSTALL_PREFIX/var/tftp/*.log* >/dev/null 2>&1 || true
   154     exit 0

mercurial