commit:     0d207f6f90bfed5e7128ee6502806476023a5c5e
Author:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
AuthorDate: Tue Apr  7 21:37:02 2020 +0000
Commit:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
CommitDate: Tue Apr  7 21:37:19 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0d207f6f

net-firewall/nftables-0.9.4-r2: revbump, cleanup deps, provide man pages

It turns out that flex and bison aren't actually needed to build, but
there was a bug in the build system that made it abort if they weren't
available. Add a patch to fix this bug, and remove the extra deps.

Disable USE=doc by default and provide pre-built man pages in a separate
tarball. Script to build them is at man-pages/gen-manpages.bash

Package-Manager: Portage-2.3.96, Repoman-2.3.22
Signed-off-by: Patrick McLean <chutzpah <AT> gentoo.org>

 net-firewall/nftables/Manifest                     |   1 +
 .../nftables/files/man-pages/gen-manpages.bash     |  72 ++++++++++
 ...w-building-from-tarballs-without-yacc-lex.patch |  37 +++++
 net-firewall/nftables/nftables-0.9.4-r2.ebuild     | 158 +++++++++++++++++++++
 4 files changed, 268 insertions(+)

diff --git a/net-firewall/nftables/Manifest b/net-firewall/nftables/Manifest
index 8efe409eb2f..e2877db7245 100644
--- a/net-firewall/nftables/Manifest
+++ b/net-firewall/nftables/Manifest
@@ -1,2 +1,3 @@
 DIST nftables-0.9.3.tar.bz2 786759 BLAKE2B 
578276d861fdb2b843223aca1276bbc1dda9627d0058259a966e324e30ee64d8c102d1e2cceb82d29143caa9dcd1a4492df168f1c87b136fc7b3a1a7dc8568a8
 SHA512 
d264f6fc75c95510e29fe7d5b82ae418d502f40437b098ba6117ffb1374d9989d70a7296e2e58c5fb25142145a987bb9c160902637899f892589809f9541db43
+DIST nftables-0.9.4-manpages.tar.xz 38580 BLAKE2B 
bb561c7824d032ecfff5c98af10c95af6f5188377f43de8398be7e503adff0441d49fa3e2cefcb646927cc1a4222957f0cc75d5ad4c770ef3a3f8cb8a677c5ce
 SHA512 
1b94ff06ceccf75bbefbf64496d5fa0b492907d7ec5fe41f7808c6e239b2a0a42e88d61e35e22485abee7e4bd382178e962a7c5b113433247ca329cbfa408bca
 DIST nftables-0.9.4.tar.bz2 792788 BLAKE2B 
3f2d8ff3bcfe3ab815ee369c4937adef5e5730edee8ea59b32031732802e608bcb47ddd3e55303ad6c295158aff51b2f2c069d98600db83d732ff78836c7abb5
 SHA512 
cef5b5f26f3a2893a3eb1323f1f0ecfd6e2865e0eb040e9b7da5824e5be2274b888e661abe96e828add9e951f47303e30cb7c9238d267a031c0f99b5f3b6e2c0

diff --git a/net-firewall/nftables/files/man-pages/gen-manpages.bash 
b/net-firewall/nftables/files/man-pages/gen-manpages.bash
new file mode 100644
index 00000000000..a2223d3dd5b
--- /dev/null
+++ b/net-firewall/nftables/files/man-pages/gen-manpages.bash
@@ -0,0 +1,72 @@
+#!/bin/bash
+#
+# create manpages for nftables
+
+declare -A MAN_PAGES
+
+MAN_PAGES=(
+       [nft.8]="nft.txt"
+       [libnftables-json.5]="libnftables-json.adoc"
+       [libnftables.3]="libnftables.adoc"
+)
+
+build_manpages() {
+       tar axf "${distfile}" -C "${srcdir}" || return
+
+       pushd "${srcdir}/${version}/doc" > /dev/null || return
+       local manpage
+       for manpage in "${!MAN_PAGES[@]}"; do
+               a2x -L --doctype manpage --format manpage -D . 
"${MAN_PAGES[${manpage}]}" || return
+       done
+       popd > /dev/null || return
+
+       local -a tarfiles
+       readarray -t tarfiles < <(printf -- "${version}/doc/%s\\n" 
"${!MAN_PAGES[@]}")
+
+       tar -Jc --owner='root:0' --group='root:0' \
+               --transform="s:^${version}/doc:${version}-manpages:" \
+               -f "${version}-manpages.tar.xz" \
+               -C "${srcdir}" \
+               "${tarfiles[@]}" || return
+
+       rm -rf "${srcdir:?}/${version}" || return
+}
+
+main() {
+       shopt -s failglob
+       local version="${1}" srcdir="${0%/*}"
+
+       if [[ -z ${version} ]]; then
+               # shellcheck disable=SC2016
+               version=$(
+                       find . -maxdepth 1 -type d -a -name 'nftables-*' 
-printf '%P\0' 2>/dev/null \
+                       | LC_COLLATE=C sort -z \
+                       | sed -z -n '${p;Q}' \
+                       | tr -d '\000'
+               )
+               if [[ -z ${version} ]]; then
+                       # shellcheck disable=SC2016
+                       version=$(
+                               find . -maxdepth 3 -mindepth 3 -type f -a -name 
'nftables-*.ebuild' -printf '%P\0' 2>/dev/null \
+                               | LC_COLLATE=C sort -z \
+                               | sed -r -z -n 
'${s:.*/::;s:-r[0-9]+::;s:[.]ebuild::;p;Q}' \
+                               | tr -d '\000'
+                       )
+                       if [[ -z ${version} ]]; then
+                               printf 'Usage %s <version>\n' "${0}" >&2
+                               return 1
+                       fi
+               fi
+       elif [[ ${version} =~ [0-9.]+ ]]; then
+               version="nftables-${version}"
+       fi
+
+       local distdir distfile
+       local -a distfiles
+       distdir="$(portageq distdir)" || return
+       distfiles=( "${distdir}/${version}.tar."* ) || return
+       distfile="${distfiles[-1]}"
+       build_manpages || return
+}
+
+main "${@}"

diff --git 
a/net-firewall/nftables/files/nftables-0.9.4-Allow-building-from-tarballs-without-yacc-lex.patch
 
b/net-firewall/nftables/files/nftables-0.9.4-Allow-building-from-tarballs-without-yacc-lex.patch
new file mode 100644
index 00000000000..6eb70859625
--- /dev/null
+++ 
b/net-firewall/nftables/files/nftables-0.9.4-Allow-building-from-tarballs-without-yacc-lex.patch
@@ -0,0 +1,37 @@
+From 3c83e2bca90b697e7c98f849319f1ad015dcdb86 Mon Sep 17 00:00:00 2001
+From: Matt Turner <matts...@gmail.com>
+Date: Tue, 7 Apr 2020 13:16:59 -0700
+Subject: [PATCH nftables 2/2] build: Allow building from tarballs without
+ yacc/lex
+
+The generated files are included in the tarballs already, but
+configure.ac was coded to fail if yacc/lex were not found regardless.
+
+Signed-off-by: Matt Turner <matts...@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index a04d94bc..3496e410 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -29,13 +29,13 @@ AC_PROG_SED
+ AM_PROG_LEX
+ AC_PROG_YACC
+ 
+-if test -z "$ac_cv_prog_YACC"
++if test -z "$ac_cv_prog_YACC" -a ! -f "${srcdir}/src/parser_bison.c"
+ then
+         echo "*** Error: No suitable bison/yacc found. ***"
+         echo "    Please install the 'bison' package."
+         exit 1
+ fi
+-if test -z "$ac_cv_prog_LEX"
++if test -z "$ac_cv_prog_LEX" -a ! -f "${srcdir}/src/scanner.c"
+ then
+         echo "*** Error: No suitable flex/lex found. ***"
+         echo "    Please install the 'flex' package."
+-- 
+2.24.1
+

diff --git a/net-firewall/nftables/nftables-0.9.4-r2.ebuild 
b/net-firewall/nftables/nftables-0.9.4-r2.ebuild
new file mode 100644
index 00000000000..f9a434586f7
--- /dev/null
+++ b/net-firewall/nftables/nftables-0.9.4-r2.ebuild
@@ -0,0 +1,158 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python3_{6,7,8} )
+
+inherit autotools linux-info python-r1 systemd
+
+DESCRIPTION="Linux kernel (3.13+) firewall, NAT and packet mangling tools"
+HOMEPAGE="https://netfilter.org/projects/nftables/";
+#SRC_URI="https://git.netfilter.org/nftables/snapshot/v${PV}.tar.gz -> 
${P}.tar.gz"
+SRC_URI="https://netfilter.org/projects/nftables/files/${P}.tar.bz2
+       !doc? ( 
https://dev.gentoo.org/~chutzpah/dist/nftables/${P}-manpages.tar.xz )"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~arm64 ~ia64 ~ppc64 ~sparc ~x86"
+IUSE="debug doc +gmp json +modern-kernel python +readline static-libs xtables"
+
+RDEPEND="
+       >=net-libs/libmnl-1.0.3:0=
+       gmp? ( dev-libs/gmp:0= )
+       json? ( dev-libs/jansson )
+       python? ( ${PYTHON_DEPS} )
+       readline? ( sys-libs/readline:0= )
+       >=net-libs/libnftnl-1.1.6:0=
+       xtables? ( >=net-firewall/iptables-1.6.1 )
+"
+
+DEPEND="${RDEPEND}"
+
+BDEPEND="
+       doc? (
+               app-text/asciidoc
+               >=app-text/docbook2X-0.8.8-r4
+       )
+       virtual/pkgconfig
+"
+
+REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
+
+#S="${WORKDIR}/v${PV}"
+
+PATCHES=(
+       # this has been sent upstream, see
+       # https://marc.info/?l=netfilter-devel&m=158629102300853
+       
"${FILESDIR}/nftables-0.9.4-Allow-building-from-tarballs-without-yacc-lex.patch"
+)
+
+python_make() {
+       emake \
+               -C py \
+               abs_builddir="${S}" \
+               DESTDIR="${D}" \
+               PYTHON_BIN="${PYTHON}" \
+               ${@}
+}
+
+pkg_setup() {
+       if kernel_is ge 3 13; then
+               if use modern-kernel && kernel_is lt 3 18; then
+                       eerror "The modern-kernel USE flag requires kernel 
version 3.18 or newer to work properly."
+               fi
+               CONFIG_CHECK="~NF_TABLES"
+               linux-info_pkg_setup
+       else
+               eerror "This package requires kernel version 3.13 or newer to 
work properly."
+       fi
+}
+
+src_prepare() {
+       default
+
+       # fix installation path for doc stuff
+       sed '/^pkgsysconfdir/s@${sysconfdir}.*$@${docdir}/skels@' \
+               -i files/nftables/Makefile.am || die
+       sed '/^pkgsysconfdir/s@${sysconfdir}.*$@${docdir}/skels/osf@' \
+               -i files/osf/Makefile.am || die
+
+       eautoreconf
+}
+
+src_configure() {
+       local myeconfargs=(
+               # We handle python separately
+               --disable-python
+               --sbindir="${EPREFIX}"/sbin
+               $(use_enable debug)
+               $(use_enable doc man-doc)
+               $(use_with !gmp mini_gmp)
+               $(use_with json)
+               $(use_with readline cli readline)
+               $(use_enable static-libs static)
+               $(use_with xtables)
+       )
+       econf "${myeconfargs[@]}"
+}
+
+src_compile() {
+       default
+
+       if use python ; then
+               python_foreach_impl python_make
+       fi
+}
+
+src_install() {
+       default
+
+       if ! use doc; then
+               pushd "${WORKDIR}/${P}-manpages" >/dev/null || die
+               doman *.?
+               popd >/dev/null || die
+       fi
+
+       local mksuffix="$(usex modern-kernel '-mk' '')"
+
+       exeinto /usr/libexec/${PN}
+       newexe "${FILESDIR}"/libexec/${PN}${mksuffix}.sh ${PN}.sh
+       newconfd "${FILESDIR}"/${PN}${mksuffix}.confd ${PN}
+       newinitd "${FILESDIR}"/${PN}${mksuffix}.init ${PN}
+       keepdir /var/lib/nftables
+
+       systemd_dounit "${FILESDIR}"/systemd/${PN}-restore.service
+
+       if use python ; then
+               python_foreach_impl python_make install
+       fi
+
+       python_foreach_impl python_optimize
+       find "${ED}" -type f -name "*.la" -delete || die
+}
+
+pkg_postinst() {
+       local save_file
+       save_file="${EROOT}/var/lib/nftables/rules-save"
+
+       # In order for the nftables-restore systemd service to start
+       # the save_file must exist.
+       if [[ ! -f "${save_file}" ]]; then
+               ( umask 177; touch "${save_file}" )
+       elif [[ $(( "$( stat --printf '%05a' "${save_file}" )" & 07177 )) -ne 0 
]]; then
+               ewarn "Your system has dangerous permissions for ${save_file}"
+               ewarn "It is probably affected by bug #691326."
+               ewarn "You may need to fix the permissions of the file. To do 
so,"
+               ewarn "you can run the command in the line below as root."
+               ewarn "    'chmod 600 \"${save_file}\"'"
+       fi
+
+       elog "If you wish to enable the firewall rules on boot (on systemd) you"
+       elog "will need to enable the nftables-restore service."
+       elog "    'systemctl enable ${PN}-restore.service'"
+       elog
+       elog "If you are creating firewall rules before the next system restart 
"
+       elog "the nftables-restore service must be manually started in order to 
"
+       elog "save those rules on shutdown."
+}

Reply via email to