2023-04-12 12:48:02 +00:00
|
|
|
{ lib, stdenv, linuxHeaders
|
2022-09-09 14:08:57 +00:00
|
|
|
, libopcodes, libopcodes_2_38
|
|
|
|
, libbfd, libbfd_2_38
|
|
|
|
, elfutils, readline
|
2022-09-22 12:36:57 +00:00
|
|
|
, zlib
|
2021-05-03 20:48:10 +00:00
|
|
|
, python3, bison, flex
|
|
|
|
}:
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2021-05-03 20:48:10 +00:00
|
|
|
pname = "bpftools";
|
2022-09-22 12:36:57 +00:00
|
|
|
|
2023-04-12 12:48:02 +00:00
|
|
|
inherit (linuxHeaders) version src;
|
|
|
|
|
|
|
|
separateDebugInfo = true;
|
2021-05-03 20:48:10 +00:00
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
patches = [
|
|
|
|
# fix unknown type name '__vector128' on ppc64le
|
|
|
|
./include-asm-types-for-ppc64le.patch
|
|
|
|
];
|
2022-10-30 15:09:59 +00:00
|
|
|
|
2021-05-03 20:48:10 +00:00
|
|
|
nativeBuildInputs = [ python3 bison flex ];
|
2022-09-09 14:08:57 +00:00
|
|
|
buildInputs = (if (lib.versionAtLeast version "5.20")
|
|
|
|
then [ libopcodes libbfd ]
|
|
|
|
else [ libopcodes_2_38 libbfd_2_38 ])
|
|
|
|
++ [ elfutils zlib readline ];
|
2021-05-03 20:48:10 +00:00
|
|
|
|
|
|
|
preConfigure = ''
|
2021-07-04 02:40:35 +00:00
|
|
|
patchShebangs scripts/bpf_doc.py
|
2021-05-03 20:48:10 +00:00
|
|
|
|
|
|
|
cd tools/bpf
|
|
|
|
substituteInPlace ./bpftool/Makefile \
|
|
|
|
--replace '/usr/local' "$out" \
|
|
|
|
--replace '/usr' "$out" \
|
|
|
|
--replace '/sbin' '/bin'
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildFlags = [ "bpftool" "bpf_asm" "bpf_dbg" ];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
make -C bpftool install
|
|
|
|
install -Dm755 -t $out/bin bpf_asm
|
|
|
|
install -Dm755 -t $out/bin bpf_dbg
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Debugging/program analysis tools for the eBPF subsystem";
|
|
|
|
license = [ licenses.gpl2 licenses.bsd2 ];
|
|
|
|
platforms = platforms.linux;
|
|
|
|
maintainers = with maintainers; [ thoughtpolice ];
|
|
|
|
};
|
|
|
|
}
|