2022-09-22 12:36:57 +00:00
|
|
|
{ lib, stdenv, fetchurl
|
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-10-30 15:09:59 +00:00
|
|
|
version = "5.19.12";
|
2022-09-22 12:36:57 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "mirror://kernel/linux/kernel/v5.x/linux-${version}.tar.xz";
|
2022-10-30 15:09:59 +00:00
|
|
|
sha256 = "sha256-xDalSMcxLOb8WjRyy+rYle749ShB++fHH9jki9/isLo=";
|
2022-09-22 12:36:57 +00:00
|
|
|
};
|
2021-05-03 20:48:10 +00:00
|
|
|
|
2022-10-30 15:09:59 +00:00
|
|
|
patches = [ ./strip-binary-name.patch ];
|
|
|
|
|
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 ];
|
|
|
|
};
|
|
|
|
}
|