blob: ad99a80a6df0d4bd96e5e7347e5ac27492a28c60 [file] [log] [blame]
Patrick Williamsac13d5f2023-11-24 18:59:46 -06001SUMMARY = "Netfilter Tables userspace utillites"
Patrick Williams03514f12024-04-05 07:04:11 -05002DESCRIPTION = "nftables replaces the popular {ip,ip6,arp,eb}tables. \
3 This software provides an in-kernel packet classification framework \
4 that is based on a network-specific Virtual Machine (VM), \
5 nft, a userspace command line tool and libnftables, a high-level userspace library."
6HOMEPAGE = "https://netfilter.org/projects/nftables"
Patrick Williamsac13d5f2023-11-24 18:59:46 -06007SECTION = "net"
8LICENSE = "GPL-2.0-only"
9LIC_FILES_CHKSUM = "file://COPYING;md5=81ec33bb3e47b460fc993ac768c74b62"
10
11DEPENDS = "libmnl libnftnl bison-native \
12 ${@bb.utils.contains('PACKAGECONFIG', 'mini-gmp', '', 'gmp', d)}"
13
14SRC_URI = "http://www.netfilter.org/projects/nftables/files/${BP}.tar.xz \
Patrick Williams03514f12024-04-05 07:04:11 -050015 file://0001-tests-shell-Fix-sets-reset_command_0-for-current-ker.patch \
16 file://0001-tests-shell-skip-secmark-tests-if-kernel-does-not-su.patch \
Patrick Williamsac13d5f2023-11-24 18:59:46 -060017 file://run-ptest \
18 "
19SRC_URI[sha256sum] = "a3c304cd9ba061239ee0474f9afb938a9bb99d89b960246f66f0c3a0a85e14cd"
20
21inherit autotools manpages pkgconfig ptest
22
23PACKAGECONFIG ?= "python readline json"
24PACKAGECONFIG[editline] = "--with-cli=editline, , libedit, , , linenoise readline"
25PACKAGECONFIG[json] = "--with-json, --without-json, jansson"
26PACKAGECONFIG[linenoise] = "--with-cli=linenoise, , linenoise, , , editline readline"
27PACKAGECONFIG[manpages] = "--enable-man-doc, --disable-man-doc, asciidoc-native"
28PACKAGECONFIG[mini-gmp] = "--with-mini-gmp, --without-mini-gmp"
29PACKAGECONFIG[python] = ",, python3-setuptools-native"
30PACKAGECONFIG[readline] = "--with-cli=readline, , readline, , , editline linenoise"
31PACKAGECONFIG[xtables] = "--with-xtables, --without-xtables, iptables"
32
33EXTRA_OECONF = " \
34 ${@bb.utils.contains_any('PACKAGECONFIG', 'editline linenoise readline', '', '--without-cli', d)}"
35
36SETUPTOOLS_SETUP_PATH = "${S}/py"
37
38inherit ${@bb.utils.contains('PACKAGECONFIG', 'python', 'setuptools3', '', d)}
39
40RRECOMMENDS:${PN} += "kernel-module-nf-tables"
41
42PACKAGES =+ "${PN}-python"
43FILES:${PN}-python = "${PYTHON_SITEPACKAGES_DIR}"
44RDEPENDS:${PN}-python = "python3-core python3-json ${PN}"
45
46# Explicitly define do_configure, do_compile and do_install because both autotools and setuptools3
47# have EXPORT_FUNCTIONS do_configure do_compile do_install
48do_configure() {
49 autotools_do_configure
50 if ${@bb.utils.contains('PACKAGECONFIG', 'python', 'true', 'false', d)}; then
51 setuptools3_do_configure
52 fi
53}
54
55do_compile() {
56 autotools_do_compile
57 if ${@bb.utils.contains('PACKAGECONFIG', 'python', 'true', 'false', d)}; then
58 setuptools3_do_compile
59 fi
60}
61
62do_install() {
63 autotools_do_install
64 if ${@bb.utils.contains('PACKAGECONFIG', 'python', 'true', 'false', d)}; then
65 setuptools3_do_install
66 fi
67}
68
69RDEPENDS:${PN}-ptest += " ${PN}-python bash make iproute2 iputils-ping procps python3-core python3-ctypes python3-json python3-misc sed util-linux"
70
71TESTDIR = "tests"
72
73PRIVATE_LIBS:${PN}-ptest:append = " libnftables.so.1"
74
75do_install_ptest() {
76 cp -rf ${S}/build-aux ${D}${PTEST_PATH}
77 cp -rf ${S}/src ${D}${PTEST_PATH}
78 mkdir -p ${D}${PTEST_PATH}/src/.libs
79 cp -rf ${B}/src/.libs/* ${D}${PTEST_PATH}/src/.libs
80 cp -rf ${B}/src/.libs/nft ${D}${PTEST_PATH}/src/
81 cp -rf ${S}/${TESTDIR} ${D}${PTEST_PATH}/${TESTDIR}
82 sed -i 's#/usr/bin/python#/usr/bin/python3#' ${D}${PTEST_PATH}/${TESTDIR}/json_echo/run-test.py
83 sed -i 's#/usr/bin/env python#/usr/bin/env python3#' ${D}${PTEST_PATH}/${TESTDIR}/py/nft-test.py
84 # handle multilib
85 sed -i s:@libdir@:${libdir}:g ${D}${PTEST_PATH}/run-ptest
86}