dev-util/bpftool: Sync with Gentoo

It's from Gentoo commit 43976a379d0df9a41910594f7aa3803066f19439.
This commit is contained in:
Flatcar Buildbot 2024-11-25 07:06:17 +00:00 committed by Krzesimir Nowak
parent 342ee29fe4
commit c01f16901c
5 changed files with 162 additions and 5 deletions

View File

@ -1,4 +1,5 @@
DIST bpftool-7.4.0.tar.gz 472915 BLAKE2B ae7b6bc6cb742712981ba8972bcecccc63d440b2a77c5a14f91ba5106c013774313d65fd3f42b843ba4027ab17cf9d44d256270f7f8ad11907714f16f3149078 SHA512 08a3095b37a9b897400f2be7dbb9de10d129ae4eef193d03955fdf84017cd3a5d7419e856aa68a425e609419868e8b1dd5409b4f218cc24feeb059c1898cdff4
DIST bpftool-libbpf-v7.5.0-sources.tar.gz 1510032 BLAKE2B cc9beac4034317f89ae3c1088d1b1a1948778bcdb51d7ed7f566e4e5ab720c1128ca467d51d0bc3ffe7b1f69800249362baef5dfaf858275050f96b744fdbca6 SHA512 db12c305b77fea3689dbc1ce94527f0f21fa9de21fcdb36385e3fe492137335bb393f90e456c06601495ccc984230a531c432709db6514b545e0aeeda7ca3c99
DIST libbpf-1.4.7.tar.gz 1016441 BLAKE2B 10be52c7e97b2f08edd33cb263c4737bb52edfd2226f0c5b86d4f95b584b81f8f6b1ede469e9ad6c231e55b6d6b9a038160662606c3f30dc79b1336aaaa90e74 SHA512 f09ff28ac75b0d0c1bfe7d233aee6a00e5c21f185646b2afe11b7bd048d74962f893237437dd81a762768f9235b9f2a2a33cb297201b2aa3e98f7c6f58e5b365
DIST linux-6.10.tar.xz 145142812 BLAKE2B bb243ea7493b9d63aa2df2050a3f1ae2b89ee84a20015239cf157e3f4f51c7ac5efedc8a51132b2d7482f9276ac418de6624831c8a3b806130d9c2d2124c539b SHA512 baa2487954044f991d2ae254d77d14a1f0185dd62c9f0fcaff69f586c9f906823017b8db1c4588f27b076dfa3ebb606929fec859f60ea419e7974330b9289cc2
DIST linux-6.11.tar.xz 146900704 BLAKE2B e7750c0878d71a56a0ce52d4c4c912199dad5bf5e2e8f872585a6494afbb37cbd852e612a6858936d2dc9b7776a3933818f540db408d57e90d18ea5249bba7ab SHA512 329c1f94008742e3f0c2ce7e591a16316d1b2cb9ea4596d4f45604097e07b7aa2f64afa40630a07f321a858455c77aa32ba57b271932ddcf4dc27863f9081cea

View File

@ -7,7 +7,7 @@ LLVM_COMPAT=( {15..19} )
LLVM_OPTIONAL=1
PYTHON_COMPAT=( python3_{10..13} )
inherit bash-completion-r1 linux-info llvm-r1 optfeature python-any-r1 toolchain-funcs
inherit bash-completion-r1 linux-info llvm-r1 python-any-r1 toolchain-funcs
DESCRIPTION="Tool for inspection and simple manipulation of eBPF programs and maps"
HOMEPAGE="https://github.com/libbpf/bpftool"

View File

@ -0,0 +1,137 @@
# Copyright 2021-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
LLVM_COMPAT=( {15..19} )
LLVM_OPTIONAL=1
PYTHON_COMPAT=( python3_{10..13} )
inherit bash-completion-r1 linux-info llvm-r1 python-any-r1 toolchain-funcs
DESCRIPTION="Tool for inspection and simple manipulation of eBPF programs and maps"
HOMEPAGE="https://github.com/libbpf/bpftool"
if [[ ${PV} == *9999* ]] ; then
inherit git-r3
EGIT_REPO_URI="https://github.com/libbpf/bpftool.git"
EGIT_SUBMODULES=(libbpf)
else
# bpftool typically vendors whatever libbpf is current at the time
# of a release, while libbpf publishes minor updates more frequently.
# Uncomment the following to bundle an updated libbpf e.g. in case of
# security or crasher bugs in libbpf and to keep the two synchronized.
# This allows us to quickly update the vendored lib with a revbump.
# Currently bpftool-x.y vendors libbpf-1.y; DO NOT mix different y versions.
# See the libbpf repo (https://github.com/libbpf/libbpf) for possible updates.
# LIBBPF_VERSION=1.5.0
if [[ ! -z ${LIBBPF_VERSION} ]] ; then
SRC_URI="https://github.com/libbpf/bpftool/archive/refs/tags/v${PV}.tar.gz -> bpftool-${PV}.tar.gz
https://github.com/libbpf/libbpf/archive/refs/tags/v${LIBBPF_VERSION}.tar.gz
-> libbpf-${LIBBPF_VERSION}.tar.gz"
else
# use tarball with bundled libbpf
SRC_URI="https://github.com/libbpf/bpftool/releases/download/v${PV}/bpftool-libbpf-v${PV}-sources.tar.gz"
S="${WORKDIR}/bpftool-libbpf-v${PV}-sources"
fi
KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~x86"
fi
LICENSE="|| ( GPL-2 BSD-2 )"
SLOT="0"
IUSE="caps +clang llvm"
REQUIRED_USE="llvm? ( ${LLVM_REQUIRED_USE} )"
RDEPEND="
caps? ( sys-libs/libcap:= )
llvm? ( $(llvm_gen_dep 'sys-devel/llvm:${LLVM_SLOT}') )
!llvm? ( sys-libs/binutils-libs:= )
sys-libs/zlib:=
virtual/libelf:=
"
DEPEND="
${RDEPEND}
>=sys-kernel/linux-headers-5.8
"
BDEPEND="
${PYTHON_DEPS}
app-arch/tar
dev-python/docutils
clang? ( $(llvm_gen_dep 'sys-devel/clang:${LLVM_SLOT}[llvm_targets_BPF]') )
!clang? ( sys-devel/bpf-toolchain )
"
CONFIG_CHECK="~DEBUG_INFO_BTF"
pkg_setup() {
python-any-r1_pkg_setup
use llvm && llvm-r1_pkg_setup
}
src_prepare() {
default
# prepare libbpf if necessary
if [[ ! -z ${LIBBPF_VERSION} ]] ; then
rm -rf libbpf || die
ln -s "${WORKDIR}/libbpf-${LIBBPF_VERSION}" libbpf || die
fi
# remove -Werror from libbpf (bug 887981)
sed -i -e 's/\-Werror//g' libbpf/src/Makefile || die
# remove -Werror from bpftool feature detection
sed -i -e 's/-Werror//g' src/Makefile.feature || die
# remove hardcoded/unhelpful flags from bpftool
sed -i -e '/CFLAGS += -O2/d' -e 's/-W //g' -e 's/-Wextra //g' src/Makefile || die
if ! use clang; then
# remove bpf target & add assembly annotations to fix CO-RE feature detection
sed -i -e 's/-target bpf/-dA/' src/Makefile.feature || die
# remove bpf target from skeleton build
sed -i -e 's/--target=bpf//g' src/Makefile || die
fi
# Use rst2man or rst2man.py depending on which one exists (#930076)
type -P rst2man >/dev/null || sed -i -e 's/rst2man/rst2man.py/g' docs/Makefile || die
}
bpftool_make() {
# which BPF compiler should we use?
if use clang; then
export CLANG="$(get_llvm_prefix -b)/bin/clang"
export LLVM_STRIP="$(get_llvm_prefix -b)/bin/llvm-strip"
else
# use bpf-toolchain
export CLANG="bpf-unknown-none-gcc"
export LLVM_STRIP="bpf-unknown-none-strip"
fi
tc-export AR CC LD
emake \
ARCH="$(tc-arch-kernel)" \
HOSTAR="$(tc-getBUILD_AR)" \
HOSTCC="$(tc-getBUILD_CC)" \
HOSTLD="$(tc-getBUILD_LD)" \
bash_compdir="$(get_bashcompdir)" \
feature-libcap="$(usex caps 1 0)" \
feature-llvm="$(usex llvm 1 0)" \
prefix="${EPREFIX}"/usr \
V=1 \
"$@"
}
src_compile() {
bpftool_make -C src
bpftool_make -C docs
}
src_install() {
bpftool_make DESTDIR="${D}" -C src install
bpftool_make mandir="${ED}"/usr/share/man -C docs install
}

View File

@ -7,7 +7,7 @@ LLVM_COMPAT=( {15..19} )
LLVM_OPTIONAL=1
PYTHON_COMPAT=( python3_{10..13} )
inherit bash-completion-r1 linux-info llvm-r1 optfeature python-any-r1 toolchain-funcs
inherit bash-completion-r1 linux-info llvm-r1 python-any-r1 toolchain-funcs
DESCRIPTION="Tool for inspection and simple manipulation of eBPF programs and maps"
HOMEPAGE="https://github.com/libbpf/bpftool"
@ -41,7 +41,7 @@ fi
LICENSE="|| ( GPL-2 BSD-2 )"
SLOT="0"
IUSE="caps llvm"
IUSE="caps +clang llvm"
REQUIRED_USE="llvm? ( ${LLVM_REQUIRED_USE} )"
RDEPEND="
@ -59,7 +59,8 @@ BDEPEND="
${PYTHON_DEPS}
app-arch/tar
dev-python/docutils
$(llvm_gen_dep 'sys-devel/clang:${LLVM_SLOT}[llvm_targets_BPF]')
clang? ( $(llvm_gen_dep 'sys-devel/clang:${LLVM_SLOT}[llvm_targets_BPF]') )
!clang? ( sys-devel/bpf-toolchain )
"
CONFIG_CHECK="~DEBUG_INFO_BTF"
@ -87,16 +88,33 @@ src_prepare() {
# remove hardcoded/unhelpful flags from bpftool
sed -i -e '/CFLAGS += -O2/d' -e 's/-W //g' -e 's/-Wextra //g' src/Makefile || die
if ! use clang; then
# remove bpf target & add assembly annotations to fix CO-RE feature detection
sed -i -e 's/-target bpf/-dA/' src/Makefile.feature || die
# remove bpf target from skeleton build
sed -i -e 's/--target=bpf//g' src/Makefile || die
fi
# Use rst2man or rst2man.py depending on which one exists (#930076)
type -P rst2man >/dev/null || sed -i -e 's/rst2man/rst2man.py/g' docs/Makefile || die
}
bpftool_make() {
# which BPF compiler should we use?
if use clang; then
export CLANG="$(get_llvm_prefix -b)/bin/clang"
export LLVM_STRIP="$(get_llvm_prefix -b)/bin/llvm-strip"
else
# use bpf-toolchain
export CLANG="bpf-unknown-none-gcc"
export LLVM_STRIP="bpf-unknown-none-strip"
fi
tc-export AR CC LD
emake \
ARCH="$(tc-arch-kernel)" \
CLANG="$(get_llvm_prefix -b)/bin/clang" \
HOSTAR="$(tc-getBUILD_AR)" \
HOSTCC="$(tc-getBUILD_CC)" \
HOSTLD="$(tc-getBUILD_LD)" \

View File

@ -11,6 +11,7 @@
</maintainer>
<use>
<flag name="caps">Use <pkg>sys-libs/libcap</pkg> to enable unprivileged run support</flag>
<flag name="clang">Use <pkg>sys-devel/clang</pkg> instead of <pkg>sys-devel/bpf-toolchain</pkg> for BPF CO-RE support</flag>
<flag name="llvm">Use <pkg>sys-devel/llvm</pkg> instead of libbfd (<pkg>sys-libs/binutils-libs</pkg>) for JIT disassembly</flag>
</use>
<upstream>