From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-commits+bounces-1684956-garchives=archives.gentoo.org@lists.gentoo.org> Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id A12D5158042 for <garchives@archives.gentoo.org>; Wed, 30 Oct 2024 22:29:28 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D23E7E07A7; Wed, 30 Oct 2024 22:29:27 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id BAFCCE07A7 for <gentoo-commits@lists.gentoo.org>; Wed, 30 Oct 2024 22:29:27 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 03A13342F97 for <gentoo-commits@lists.gentoo.org>; Wed, 30 Oct 2024 22:29:27 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 6C64DB03 for <gentoo-commits@lists.gentoo.org>; Wed, 30 Oct 2024 22:29:25 +0000 (UTC) From: "Sam James" <sam@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org> Message-ID: <1730327314.62f540484b263a6b31edb273cf5665ead1e9f0d1.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: dev-util/bpftool/ X-VCS-Repository: repo/gentoo X-VCS-Files: dev-util/bpftool/bpftool-9999.ebuild dev-util/bpftool/metadata.xml X-VCS-Directories: dev-util/bpftool/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 62f540484b263a6b31edb273cf5665ead1e9f0d1 X-VCS-Branch: master Date: Wed, 30 Oct 2024 22:29:25 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 36810dde-14b5-4ac5-b0ce-6aed5c1c2032 X-Archives-Hash: b72d7f276ff6c2f7c9955c85f39b447a commit: 62f540484b263a6b31edb273cf5665ead1e9f0d1 Author: Holger Hoffstätte <holger <AT> applied-asynchrony <DOT> com> AuthorDate: Wed Oct 23 13:03:29 2024 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Wed Oct 30 22:28:34 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=62f54048 dev-util/bpftool: add rewritten live ebuild for Github-based bpftool mirror This new ebuild for bpftool gets rid of the fragile kernel-tree based build and uses the Github-based mirror repository. Unlike the previous ebuilds it allows well-defined version upgrades and optionally makes bundling a newer, properly versioned libbpf easy and reproducible. No more mystery meat! Closes: https://bugs.gentoo.org/941248 Signed-off-by: Holger Hoffstätte <holger <AT> applied-asynchrony.com> Signed-off-by: Sam James <sam <AT> gentoo.org> dev-util/bpftool/bpftool-9999.ebuild | 121 +++++++++++++++++++++++++++++++++++ dev-util/bpftool/metadata.xml | 3 + 2 files changed, 124 insertions(+) diff --git a/dev-util/bpftool/bpftool-9999.ebuild b/dev-util/bpftool/bpftool-9999.ebuild new file mode 100644 index 000000000000..03f97becf881 --- /dev/null +++ b/dev-util/bpftool/bpftool-9999.ebuild @@ -0,0 +1,121 @@ +# 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 optfeature 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 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 +" + +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 + + # 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() { + 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 +} + +pkg_postinst() { + optfeature "clang-bpf-co-re support" sys-devel/clang[llvm_targets_BPF] +} diff --git a/dev-util/bpftool/metadata.xml b/dev-util/bpftool/metadata.xml index a09ffc7b9425..1e8c354ad0e2 100644 --- a/dev-util/bpftool/metadata.xml +++ b/dev-util/bpftool/metadata.xml @@ -13,4 +13,7 @@ <flag name="caps">Use <pkg>sys-libs/libcap</pkg> to enable unprivileged run 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> + <remote-id type="github">libbpf/bpftool</remote-id> + </upstream> </pkgmetadata>