recipe 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. # Build recipe for tcp_wrappers.
  2. #
  3. # Copyright (c) 2018, 2021 Matias Fonzo, <selk@dragora.org>.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. # Exit immediately on any error
  17. set -e
  18. program=tcp_wrappers
  19. version=7.6
  20. release=3
  21. # Define a category for the output of the package name
  22. pkgcategory=networking
  23. tarname=${program}_${version}.tar.gz
  24. # Remote source(s)
  25. fetch=http://ftp.porcupine.org/pub/security/$tarname
  26. description="
  27. Monitor of incoming TCP connections.
  28. TCP Wrapper is a host-based Networking ACL system, used to
  29. filter network access to Internet Protocol servers on
  30. (Unix-like) operating systems such as Linux or BSD.
  31. It allows host or subnetwork IP addresses, names and/or
  32. ident query replies, to be used as tokens on which to
  33. filter for access control purposes.
  34. "
  35. homepage=ftp://ftp.porcupine.org/pub/security/index.html
  36. license=BSD
  37. # Source documentation
  38. docs="BLURB CHANGES DISCLAIMER README README.NIS"
  39. docsdir="${docdir}/${program}-${version}"
  40. # Source directory
  41. srcdir=${program}_${version}
  42. # Limit parallel jobs for the compiler to 1
  43. jobs=1
  44. build()
  45. {
  46. unpack "${tardir}/$tarname"
  47. cd "$srcdir"
  48. # Refresh old source code plus security issues via patches
  49. # Apply patches from Debian (Thanks!)
  50. while read -r line
  51. do
  52. patch -p1 < "${worktree}/patches/tcp_wrappers/${line}"
  53. done < "${worktree}/patches/tcp_wrappers/series"
  54. # Apply extras patches from "musl development overlay" (Thanks to "Gentoo Linux")
  55. patch -p1 < "${worktree}/patches/tcp_wrappers/tcp-wrappers-7.6.22-remove-DECLS.patch"
  56. patch -p1 < "${worktree}/patches/tcp_wrappers/tcp-wrappers-7.6-redhat-bug11881.patch"
  57. patch -p1 < "${worktree}/patches/tcp_wrappers/0001-Remove-fgets-extern-declaration.patch"
  58. # Set sane permissions
  59. chmod -R u+w,go-w,a+rX-s .
  60. make -j${jobs} COPTS="$QICFLAGS" LDOPTS="$QILDFLAGS" \
  61. STYLE="-DPROCESS_OPTIONS" REAL_DAEMON_DIR=/usr/sbin musl
  62. # Install manually
  63. mkdir -p "${destdir}/usr/include" \
  64. "${destdir}/usr/sbin" "${destdir}/usr/lib${libSuffix}"
  65. for file in safe_finger tcpd tcpdchk tcpdmatch try-from
  66. do
  67. cp -p $file "${destdir}/usr/sbin/"
  68. chmod 755 "${destdir}/usr/sbin/${file}"
  69. done
  70. unset -v file
  71. cp -p libwrap.a "${destdir}/usr/lib${libSuffix}/"
  72. chmod 644 "${destdir}/usr/lib${libSuffix}/libwrap.a"
  73. cp -p tcpd.h "${destdir}/usr/include/"
  74. chmod 644 "${destdir}/usr/include/tcpd.h"
  75. mkdir -p "${destdir}${mandir}/man3" \
  76. "${destdir}${mandir}/man5" "${destdir}${mandir}/man8"
  77. lzip -9c < hosts_access.3 > "${destdir}${mandir}/man3/hosts_access.3.lz"
  78. lzip -9c < hosts_access.5 > "${destdir}${mandir}/man5/hosts_access.5.lz"
  79. lzip -9c < hosts_options.5 > "${destdir}${mandir}/man5/hosts_options.5.lz"
  80. lzip -9c < tcpd.8 > "${destdir}${mandir}/man8/tcpd.8.lz"
  81. lzip -9c < tcpdchk.8 > "${destdir}${mandir}/man8/tcpdchk.8.lz"
  82. lzip -9c < tcpdmatch.8 > "${destdir}${mandir}/man8/tcpdmatch.8.lz"
  83. # Strip remaining binaries and libraries
  84. find "$destdir" -type f | xargs file | \
  85. awk '/ELF/ && /executable/ || /shared object/' | \
  86. cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  87. strip --strip-debug "${destdir}/usr/lib${libSuffix}/libwrap.a"
  88. # Copy local config files
  89. mkdir -p "${destdir}/etc"
  90. cp -p "${worktree}/archive/tcp_wrappers/etc/hosts.allow" "${destdir}/etc/"
  91. cp -p "${worktree}/archive/tcp_wrappers/etc/hosts.deny" "${destdir}/etc/"
  92. chmod 644 "${destdir}/etc/hosts.allow" "${destdir}/etc/hosts.deny"
  93. touch "${destdir}/etc/.graft-config"
  94. # Copy documentation
  95. mkdir -p "${destdir}/$docsdir"
  96. cp -p $docs "${destdir}/$docsdir"
  97. }