blob: 8380bbd73d9efdfd6ac7198d4646ebf34c99f708 [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001SUMMARY = "Netfilter Tables userspace utillites"
2SECTION = "net"
3LICENSE = "GPL-2.0-only"
Patrick Williams8e7b46e2023-05-01 14:19:06 -05004LIC_FILES_CHKSUM = "file://COPYING;md5=81ec33bb3e47b460fc993ac768c74b62"
Andrew Geissler517393d2023-01-13 08:55:19 -06005
6DEPENDS = "libmnl libnftnl bison-native \
7 ${@bb.utils.contains('PACKAGECONFIG', 'mini-gmp', '', 'gmp', d)}"
8
9SRC_URI = "http://www.netfilter.org/projects/nftables/files/${BP}.tar.xz \
10 file://run-ptest \
11 "
Patrick Williams8e7b46e2023-05-01 14:19:06 -050012SRC_URI[sha256sum] = "c12ac941fff9adaedf17367d5ce213789b98a0d314277bc22b3d71e10891f412"
Andrew Geissler517393d2023-01-13 08:55:19 -060013
14inherit autotools manpages pkgconfig ptest
15
16PACKAGECONFIG ?= "python readline json"
17PACKAGECONFIG[editline] = "--with-cli=editline, , libedit, , , linenoise readline"
18PACKAGECONFIG[json] = "--with-json, --without-json, jansson"
19PACKAGECONFIG[linenoise] = "--with-cli=linenoise, , linenoise, , , editline readline"
20PACKAGECONFIG[manpages] = "--enable-man-doc, --disable-man-doc, asciidoc-native"
21PACKAGECONFIG[mini-gmp] = "--with-mini-gmp, --without-mini-gmp"
Patrick Williams8e7b46e2023-05-01 14:19:06 -050022PACKAGECONFIG[python] = ",, python3-setuptools-native"
Andrew Geissler517393d2023-01-13 08:55:19 -060023PACKAGECONFIG[readline] = "--with-cli=readline, , readline, , , editline linenoise"
24PACKAGECONFIG[xtables] = "--with-xtables, --without-xtables, iptables"
25
Patrick Williams8e7b46e2023-05-01 14:19:06 -050026# Disable the python via autoconf so we can build it separately via setuptools3
27EXTRA_OECONF = "--disable-python \
28 ${@bb.utils.contains_any('PACKAGECONFIG', 'editline linenoise readline', '', '--without-cli', d)}"
Andrew Geissler517393d2023-01-13 08:55:19 -060029
Patrick Williams8e7b46e2023-05-01 14:19:06 -050030SETUPTOOLS_SETUP_PATH = "${S}/py"
31
32inherit ${@bb.utils.contains('PACKAGECONFIG', 'python', 'setuptools3', '', d)}
Andrew Geissler517393d2023-01-13 08:55:19 -060033
34RRECOMMENDS:${PN} += "kernel-module-nf-tables"
35
36PACKAGES =+ "${PN}-python"
Patrick Williams8e7b46e2023-05-01 14:19:06 -050037FILES:${PN}-python = "${PYTHON_SITEPACKAGES_DIR}"
Andrew Geissler517393d2023-01-13 08:55:19 -060038RDEPENDS:${PN}-python = "python3-core python3-json ${PN}"
39
Patrick Williams8e7b46e2023-05-01 14:19:06 -050040# Explicitly define do_configure, do_compile and do_install because both autotools and setuptools3
41# have EXPORT_FUNCTIONS do_configure do_compile do_install
42do_configure() {
43 autotools_do_configure
44 if ${@bb.utils.contains('PACKAGECONFIG', 'python', 'true', 'false', d)}; then
45 setuptools3_do_configure
46 fi
47}
48
49do_compile() {
50 autotools_do_compile
51 if ${@bb.utils.contains('PACKAGECONFIG', 'python', 'true', 'false', d)}; then
52 setuptools3_do_compile
53 fi
54}
55
56do_install() {
57 autotools_do_install
58 if ${@bb.utils.contains('PACKAGECONFIG', 'python', 'true', 'false', d)}; then
59 setuptools3_do_install
60 fi
61}
62
Andrew Geissler517393d2023-01-13 08:55:19 -060063RDEPENDS:${PN}-ptest += " ${PN}-python bash make iproute2 iputils-ping procps python3-core python3-ctypes python3-json python3-misc sed util-linux"
64
65TESTDIR = "tests"
66
Andrew Geisslerc5535c92023-01-27 16:10:19 -060067PRIVATE_LIBS:${PN}-ptest:append = " libnftables.so.1"
Andrew Geissler517393d2023-01-13 08:55:19 -060068
Andrew Geissler517393d2023-01-13 08:55:19 -060069do_install_ptest() {
70 cp -rf ${S}/build-aux ${D}${PTEST_PATH}
71 cp -rf ${S}/src ${D}${PTEST_PATH}
72 mkdir -p ${D}${PTEST_PATH}/src/.libs
73 cp -rf ${B}/src/.libs/* ${D}${PTEST_PATH}/src/.libs
74 cp -rf ${B}/src/.libs/nft ${D}${PTEST_PATH}/src/
75 cp -rf ${S}/${TESTDIR} ${D}${PTEST_PATH}/${TESTDIR}
76 sed -i 's#/usr/bin/python#/usr/bin/python3#' ${D}${PTEST_PATH}/${TESTDIR}/json_echo/run-test.py
77 sed -i 's#/usr/bin/env python#/usr/bin/env python3#' ${D}${PTEST_PATH}/${TESTDIR}/py/nft-test.py
78 # handle multilib
79 sed -i s:@libdir@:${libdir}:g ${D}${PTEST_PATH}/run-ptest
80}