fwknop-2.6.9.ebuild 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. # Python extension supports only Python 2.
  5. # See https://github.com/mrash/fwknop/issues/167
  6. PYTHON_COMPAT=( python2_7 )
  7. DISTUTILS_OPTIONAL=1
  8. inherit autotools distutils-r1 eutils linux-info readme.gentoo-r1 systemd
  9. DESCRIPTION="Single Packet Authorization and Port Knocking application"
  10. HOMEPAGE="https://www.cipherdyne.org/fwknop/ https://github.com/mrash/fwknop"
  11. SRC_URI="https://github.com/mrash/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"
  12. LICENSE="GPL-2+"
  13. SLOT="0"
  14. KEYWORDS="~amd64 ~x86"
  15. IUSE="client extras firewalld gdbm gpg iptables nfqueue python server udp-server"
  16. DEPEND="
  17. client? ( net-misc/wget[ssl] )
  18. firewalld? ( net-firewall/firewalld[${PYTHON_USEDEP}] )
  19. gdbm? ( sys-libs/gdbm )
  20. gpg? (
  21. app-crypt/gpgme
  22. dev-libs/libassuan
  23. dev-libs/libgpg-error
  24. )
  25. iptables? ( net-firewall/iptables )
  26. nfqueue? ( net-libs/libnetfilter_queue )
  27. python? ( ${PYTHON_DEPS} )
  28. server? ( !nfqueue? ( !udp-server? ( net-libs/libpcap ) ) )
  29. "
  30. RDEPEND="${DEPEND}"
  31. REQUIRED_USE="
  32. firewalld? ( server )
  33. gdbm? ( server )
  34. iptables? ( server )
  35. nfqueue? ( server )
  36. python? ( ${PYTHON_REQUIRED_USE} )
  37. server? ( ^^ ( firewalld iptables ) )
  38. udp-server? ( server )
  39. "
  40. DOCS=( AUTHORS ChangeLog README.md )
  41. DISABLE_AUTOFORMATTING=1
  42. DOC_CONTENTS="
  43. Example configuration files were installed to '${EPREFIX}/etc/fwknopd/'.
  44. Please edit them to suit your needs and then remove the .example suffix.
  45. fwknopd supports several backends: firewalld, iptables, ipfw, pf, ipf.
  46. You can set the desired backend via FIREWALL_EXE option in fwknopd.conf
  47. instead of the default one chosen at compile time.
  48. "
  49. src_prepare() {
  50. default_src_prepare
  51. # Install example configs with .example suffix.
  52. if use server; then
  53. sed -i -e 's|conf;|conf.example;|g' Makefile.am || die
  54. fi
  55. eautoreconf
  56. }
  57. src_configure() {
  58. local myeconfargs=(
  59. --localstatedir="${EPREFIX}/run"
  60. $(use_enable client)
  61. $(use_enable !gdbm file-cache)
  62. $(use_enable nfqueue nfq-capture)
  63. $(use_enable server)
  64. $(use_enable udp-server)
  65. $(use_with gpg gpgme)
  66. )
  67. use firewalld && myeconfargs+=(--with-firewalld="${EPREFIX}/usr/sbin/firewalld")
  68. use iptables && myeconfargs+=(--with-iptables="${EPREFIX}/sbin/iptables")
  69. econf "${myeconfargs[@]}"
  70. }
  71. src_compile() {
  72. default_src_compile
  73. if use python; then
  74. cd python || die
  75. distutils-r1_src_compile
  76. fi
  77. }
  78. src_install() {
  79. default_src_install
  80. prune_libtool_files --modules
  81. if use extras; then
  82. dodoc extras/apparmor/usr.sbin.fwknopd
  83. dodoc extras/console-qr/console-qr.sh
  84. dodoc extras/fwknop-launcher/*
  85. fi
  86. if use server; then
  87. newinitd "${FILESDIR}/fwknopd.init" fwknopd
  88. newconfd "${FILESDIR}/fwknopd.confd" fwknopd
  89. systemd_dounit extras/systemd/fwknopd.service
  90. systemd_newtmpfilesd extras/systemd/fwknopd.tmpfiles.conf fwknopd.conf
  91. readme.gentoo_create_doc
  92. fi
  93. if use python; then
  94. # Redefine DOCS, otherwise distutils-r1 eclass interferes.
  95. local DOCS=()
  96. cd python || die
  97. distutils-r1_src_install
  98. fi
  99. }
  100. pkg_postinst() {
  101. if use server; then
  102. readme.gentoo_print_elog
  103. if ! linux_config_exists || ! linux_chkconfig_present NETFILTER_XT_MATCH_COMMENT; then
  104. echo
  105. ewarn "fwknopd daemon relies on the 'comment' match in order to expire"
  106. ewarn "created firewall rules, which is an important security feature."
  107. ewarn "Please enable NETFILTER_XT_MATCH_COMMENT support in your kernel."
  108. echo
  109. fi
  110. if use nfqueue && \
  111. ! linux_config_exists || ! linux_chkconfig_present NETFILTER_XT_TARGET_NFQUEUE; then
  112. echo
  113. ewarn "fwknopd daemon relies on the 'NFQUEUE' target for NFQUEUE mode."
  114. ewarn "Please enable NETFILTER_XT_TARGET_NFQUEUE support in your kernel."
  115. echo
  116. fi
  117. fi
  118. }