From f831be559a62a58fe9d2a02ea383894bbc028f10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Fri, 14 Oct 2022 10:16:56 +0200 Subject: [PATCH] bpftools: strip path to the binary from prints Otherwise meson's find_program() can get confused by the output; now in case of systemd build: meson.build:1059:16: ERROR: Invalid version of program, need 'bpftool' ['>= 5.6.0'] found '01'. --- pkgs/os-specific/linux/bpftools/default.nix | 2 ++ .../linux/bpftools/strip-binary-name.patch | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 pkgs/os-specific/linux/bpftools/strip-binary-name.patch diff --git a/pkgs/os-specific/linux/bpftools/default.nix b/pkgs/os-specific/linux/bpftools/default.nix index ec109753c208..d3bb96afb3e7 100644 --- a/pkgs/os-specific/linux/bpftools/default.nix +++ b/pkgs/os-specific/linux/bpftools/default.nix @@ -15,6 +15,8 @@ stdenv.mkDerivation rec { sha256 = "sha256-xDalSMcxLOb8WjRyy+rYle749ShB++fHH9jki9/isLo="; }; + patches = [ ./strip-binary-name.patch ]; + nativeBuildInputs = [ python3 bison flex ]; buildInputs = (if (lib.versionAtLeast version "5.20") then [ libopcodes libbfd ] diff --git a/pkgs/os-specific/linux/bpftools/strip-binary-name.patch b/pkgs/os-specific/linux/bpftools/strip-binary-name.patch new file mode 100644 index 000000000000..623e90963bd9 --- /dev/null +++ b/pkgs/os-specific/linux/bpftools/strip-binary-name.patch @@ -0,0 +1,15 @@ +Strip path to the binary from prints. + +I see no sense in including the full path in outputs like bpftool --version +Especially as argv[0] may not include it, based on calling via $PATH or not. +--- a/tools/bpf/bpftool/main.c ++++ b/tools/bpf/bpftool/main.c +@@ -443 +443,7 @@ +- bin_name = argv[0]; ++ /* Strip the path if any. */ ++ const char *bin_name_slash = strrchr(argv[0], '/'); ++ if (bin_name_slash) { ++ bin_name = bin_name_slash + 1; ++ } else { ++ bin_name = argv[0]; ++ }