dev-util/bpftool: import from Gentoo

Import a new package dev-util/bpftool from Gentoo, to provide bpftool
in the production images.
This commit is contained in:
Dongsu Park 2022-02-17 12:13:39 +01:00
parent f9c6c3fc09
commit 11a2a85b79
5 changed files with 367 additions and 0 deletions

View File

@ -0,0 +1,5 @@
DIST linux-5.15.tar.xz 121913744 BLAKE2B 3921274b23f7938abdf3ed9334534b4581e13d7484303d3a5280eddb038999aaa8b836666a487472d9c4a219af0f06b9fecccaf348fb5510ab8762f4ef4b7e83 SHA512 d25ad40b5bcd6a4c6042fd0fd84e196e7a58024734c3e9a484fd0d5d54a0c1d87db8a3c784eff55e43b6f021709dc685eb0efa18d2aec327e4f88a79f405705a
DIST linux-5.16.tar.xz 123114100 BLAKE2B 07a90cc640ff89e1359c06cee8c38abd33e51f9b9a89833e31a1d2750526fda4a59e8884db3c1ea63df0a37f0d3de6b5a922b014b7313d8abce20d90ac08adcb SHA512 7a257dd576bc8493595ec7d6f3c9cb6e22c772a8b2dbe735d2485c4f5c56e26a08695546e7e0f1f1cd04a533f25e829361958d4da0b98bf0ba8094dd57a85aaf
DIST patch-5.15.8.xz 537596 BLAKE2B 0f431804d406c4bbb09c44826fe1018b0bca94018337b73387d44ff3e25e6b90e2ec10cf9935847786e4dac6e1523e8e7daeaedb4f854d20a155bd13b29a0c72 SHA512 ef6d0841033fecba7c4aa25f5249a1e532a0d95f4b7e7048357ff00277d9abc11897f92d05d4a2cb90372da9cec8aa6664ce1058f71a6cae6bc647649787667d
DIST patch-5.16.2.xz 20432 BLAKE2B 9c9f697e4dd0a78a94ac0bd361ec69683c6904d9af02da55c3001394e6a6efcc1fccd5d44747fff6ea47271b7655bd7866d161a90196cecaddde1c630ef5c425 SHA512 50d3c386e391603fbfe86780bbfa69c3a7caa83a7eea6c239af133dde3a7aa4746f4a3f1483589018d5ac27caa7ee69d869f8f64f4b5121ddab52224f5302222
DIST patch-5.16.4.xz 343964 BLAKE2B 1fa1b90cecafe11ea0be1c099c4e2b4775ab87fd204a3ab2985e1ed479866763663db62a4de15c6aae243c0c34356f72c51df7437ce9a8fa8e257c4b3bc6cf20 SHA512 504d02a825dc9e06f2f6802567f179d5b956f3be4ccf3dae97ec31eefb0826f784292215e85fbb51ea98198288db9735de8d87f84551ff85f389cb713ee1cff5

View File

@ -0,0 +1,117 @@
# Copyright 2021-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{8..10} )
inherit estack linux-info optfeature python-any-r1 toolchain-funcs
MY_PV="${PV/_/-}"
MY_PV="${MY_PV/-pre/-git}"
DESCRIPTION="Tool for inspection and simple manipulation of eBPF programs and maps"
HOMEPAGE="https://kernel.org/"
LINUX_V="${PV:0:1}.x"
LINUX_VER=$(ver_cut 1-2)
LINUX_PATCH=patch-${PV}.xz
SRC_URI="https://www.kernel.org/pub/linux/kernel/v${LINUX_V}/${LINUX_PATCH}"
LINUX_SOURCES="linux-${LINUX_VER}.tar.xz"
SRC_URI+=" https://www.kernel.org/pub/linux/kernel/v${LINUX_V}/${LINUX_SOURCES}"
S_K="${WORKDIR}/linux-${LINUX_VER}"
S="${S_K}/tools/bpf/bpftool"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="amd64 ~x86"
IUSE="caps"
RDEPEND="
sys-libs/binutils-libs:=
sys-libs/zlib:=
virtual/libelf:=
caps? ( sys-libs/libcap:= )
"
DEPEND="
${RDEPEND}
>=sys-kernel/linux-headers-5.8
"
BDEPEND="
${LINUX_PATCH+dev-util/patchutils}
${PYTHON_DEPS}
dev-python/docutils
"
CONFIG_CHECK="~DEBUG_INFO_BTF"
# src_unpack and src_prepare are copied from dev-util/perf since
# it's building from the same tarball, please keep it in sync with perf
src_unpack() {
local paths=(
tools/bpf kernel/bpf
tools/{arch,build,include,lib,perf,scripts} {scripts,include,lib} "arch/*/lib"
)
# We expect the tar implementation to support the -j option (both
# GNU tar and libarchive's tar support that).
echo ">>> Unpacking ${LINUX_SOURCES} (${paths[*]}) to ${PWD}"
tar --wildcards -xpf "${DISTDIR}"/${LINUX_SOURCES} \
"${paths[@]/#/linux-${LINUX_VER}/}" || die
if [[ -n ${LINUX_PATCH} ]] ; then
eshopts_push -o noglob
ebegin "Filtering partial source patch"
filterdiff -p1 ${paths[@]/#/-i } -z "${DISTDIR}"/${LINUX_PATCH} \
> ${P}.patch
eend $? || die "filterdiff failed"
eshopts_pop
fi
local a
for a in ${A}; do
[[ ${a} == ${LINUX_SOURCES} ]] && continue
[[ ${a} == ${LINUX_PATCH} ]] && continue
unpack ${a}
done
}
src_prepare() {
default
if [[ -n ${LINUX_PATCH} ]] ; then
pushd "${S_K}" >/dev/null || die
eapply "${WORKDIR}"/${P}.patch
popd || die
fi
# dev-python/docutils installs rst2man.py, not rst2man
sed -i -e 's/rst2man/rst2man.py/g' Documentation/Makefile || die
}
bpftool_make() {
local arch=$(tc-arch-kernel)
tc-export AR CC LD
emake V=1 VF=1 \
HOSTCC="$(tc-getBUILD_CC)" HOSTLD="$(tc-getBUILD_LD)" \
EXTRA_CFLAGS="${CFLAGS}" ARCH="${arch}" BPFTOOL_VERSION="${MY_PV}" \
prefix="${EPREFIX}"/usr \
feature-libcap="$(usex caps 1 0)" \
"$@"
}
src_compile() {
bpftool_make
bpftool_make -C Documentation
}
src_install() {
bpftool_make DESTDIR="${D}" install
bpftool_make mandir="${ED}"/usr/share/man -C Documentation install
}
pkg_postinst() {
optfeature "clang-bpf-co-re support" sys-devel/clang[llvm_targets_BPF]
}

View File

@ -0,0 +1,117 @@
# Copyright 2021-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{8..10} )
inherit estack linux-info optfeature python-any-r1 toolchain-funcs
MY_PV="${PV/_/-}"
MY_PV="${MY_PV/-pre/-git}"
DESCRIPTION="Tool for inspection and simple manipulation of eBPF programs and maps"
HOMEPAGE="https://kernel.org/"
LINUX_V="${PV:0:1}.x"
LINUX_VER=$(ver_cut 1-2)
LINUX_PATCH=patch-${PV}.xz
SRC_URI="https://www.kernel.org/pub/linux/kernel/v${LINUX_V}/${LINUX_PATCH}"
LINUX_SOURCES="linux-${LINUX_VER}.tar.xz"
SRC_URI+=" https://www.kernel.org/pub/linux/kernel/v${LINUX_V}/${LINUX_SOURCES}"
S_K="${WORKDIR}/linux-${LINUX_VER}"
S="${S_K}/tools/bpf/bpftool"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="caps"
RDEPEND="
sys-libs/binutils-libs:=
sys-libs/zlib:=
virtual/libelf:=
caps? ( sys-libs/libcap:= )
"
DEPEND="
${RDEPEND}
>=sys-kernel/linux-headers-5.8
"
BDEPEND="
${LINUX_PATCH+dev-util/patchutils}
${PYTHON_DEPS}
dev-python/docutils
"
CONFIG_CHECK="~DEBUG_INFO_BTF"
# src_unpack and src_prepare are copied from dev-util/perf since
# it's building from the same tarball, please keep it in sync with perf
src_unpack() {
local paths=(
tools/bpf kernel/bpf
tools/{arch,build,include,lib,perf,scripts} {scripts,include,lib} "arch/*/lib"
)
# We expect the tar implementation to support the -j option (both
# GNU tar and libarchive's tar support that).
echo ">>> Unpacking ${LINUX_SOURCES} (${paths[*]}) to ${PWD}"
tar --wildcards -xpf "${DISTDIR}"/${LINUX_SOURCES} \
"${paths[@]/#/linux-${LINUX_VER}/}" || die
if [[ -n ${LINUX_PATCH} ]] ; then
eshopts_push -o noglob
ebegin "Filtering partial source patch"
filterdiff -p1 ${paths[@]/#/-i } -z "${DISTDIR}"/${LINUX_PATCH} \
> ${P}.patch
eend $? || die "filterdiff failed"
eshopts_pop
fi
local a
for a in ${A}; do
[[ ${a} == ${LINUX_SOURCES} ]] && continue
[[ ${a} == ${LINUX_PATCH} ]] && continue
unpack ${a}
done
}
src_prepare() {
default
if [[ -n ${LINUX_PATCH} ]] ; then
pushd "${S_K}" >/dev/null || die
eapply "${WORKDIR}"/${P}.patch
popd || die
fi
# dev-python/docutils installs rst2man.py, not rst2man
sed -i -e 's/rst2man/rst2man.py/g' Documentation/Makefile || die
}
bpftool_make() {
local arch=$(tc-arch-kernel)
tc-export AR CC LD
emake V=1 VF=1 \
HOSTCC="$(tc-getBUILD_CC)" HOSTLD="$(tc-getBUILD_LD)" \
EXTRA_CFLAGS="${CFLAGS}" ARCH="${arch}" BPFTOOL_VERSION="${MY_PV}" \
prefix="${EPREFIX}"/usr \
feature-libcap="$(usex caps 1 0)" \
"$@"
}
src_compile() {
bpftool_make
bpftool_make -C Documentation
}
src_install() {
bpftool_make DESTDIR="${D}" install
bpftool_make mandir="${ED}"/usr/share/man -C Documentation install
}
pkg_postinst() {
optfeature "clang-bpf-co-re support" sys-devel/clang[llvm_targets_BPF]
}

View File

@ -0,0 +1,117 @@
# Copyright 2021-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{8..10} )
inherit estack linux-info optfeature python-any-r1 toolchain-funcs
MY_PV="${PV/_/-}"
MY_PV="${MY_PV/-pre/-git}"
DESCRIPTION="Tool for inspection and simple manipulation of eBPF programs and maps"
HOMEPAGE="https://kernel.org/"
LINUX_V="${PV:0:1}.x"
LINUX_VER=$(ver_cut 1-2)
LINUX_PATCH=patch-${PV}.xz
SRC_URI="https://www.kernel.org/pub/linux/kernel/v${LINUX_V}/${LINUX_PATCH}"
LINUX_SOURCES="linux-${LINUX_VER}.tar.xz"
SRC_URI+=" https://www.kernel.org/pub/linux/kernel/v${LINUX_V}/${LINUX_SOURCES}"
S_K="${WORKDIR}/linux-${LINUX_VER}"
S="${S_K}/tools/bpf/bpftool"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="caps"
RDEPEND="
sys-libs/binutils-libs:=
sys-libs/zlib:=
virtual/libelf:=
caps? ( sys-libs/libcap:= )
"
DEPEND="
${RDEPEND}
>=sys-kernel/linux-headers-5.8
"
BDEPEND="
${LINUX_PATCH+dev-util/patchutils}
${PYTHON_DEPS}
dev-python/docutils
"
CONFIG_CHECK="~DEBUG_INFO_BTF"
# src_unpack and src_prepare are copied from dev-util/perf since
# it's building from the same tarball, please keep it in sync with perf
src_unpack() {
local paths=(
tools/bpf kernel/bpf
tools/{arch,build,include,lib,perf,scripts} {scripts,include,lib} "arch/*/lib"
)
# We expect the tar implementation to support the -j option (both
# GNU tar and libarchive's tar support that).
echo ">>> Unpacking ${LINUX_SOURCES} (${paths[*]}) to ${PWD}"
tar --wildcards -xpf "${DISTDIR}"/${LINUX_SOURCES} \
"${paths[@]/#/linux-${LINUX_VER}/}" || die
if [[ -n ${LINUX_PATCH} ]] ; then
eshopts_push -o noglob
ebegin "Filtering partial source patch"
filterdiff -p1 ${paths[@]/#/-i } -z "${DISTDIR}"/${LINUX_PATCH} \
> ${P}.patch
eend $? || die "filterdiff failed"
eshopts_pop
fi
local a
for a in ${A}; do
[[ ${a} == ${LINUX_SOURCES} ]] && continue
[[ ${a} == ${LINUX_PATCH} ]] && continue
unpack ${a}
done
}
src_prepare() {
default
if [[ -n ${LINUX_PATCH} ]] ; then
pushd "${S_K}" >/dev/null || die
eapply "${WORKDIR}"/${P}.patch
popd || die
fi
# dev-python/docutils installs rst2man.py, not rst2man
sed -i -e 's/rst2man/rst2man.py/g' Documentation/Makefile || die
}
bpftool_make() {
local arch=$(tc-arch-kernel)
tc-export AR CC LD
emake V=1 VF=1 \
HOSTCC="$(tc-getBUILD_CC)" HOSTLD="$(tc-getBUILD_LD)" \
EXTRA_CFLAGS="${CFLAGS}" ARCH="${arch}" BPFTOOL_VERSION="${MY_PV}" \
prefix="${EPREFIX}"/usr \
feature-libcap="$(usex caps 1 0)" \
"$@"
}
src_compile() {
bpftool_make
bpftool_make -C Documentation
}
src_install() {
bpftool_make DESTDIR="${D}" install
bpftool_make mandir="${ED}"/usr/share/man -C Documentation install
}
pkg_postinst() {
optfeature "clang-bpf-co-re support" sys-devel/clang[llvm_targets_BPF]
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="person">
<email>jsmolic@gentoo.org</email>
<name>Jakov Smolić</name>
</maintainer>
<use>
<flag name="caps">Use <pkg>sys-libs/libcap</pkg> to enable unprivileged run support</flag>
</use>
</pkgmetadata>