summary refs log tree commit diff
path: root/pkgs/os-specific/linux/bpftools
diff options
context:
space:
mode:
authorVladimír Čunát <v@cunat.cz>2022-10-14 10:16:56 +0200
committerVladimír Čunát <v@cunat.cz>2022-10-14 10:19:12 +0200
commitf831be559a62a58fe9d2a02ea383894bbc028f10 (patch)
treec18158b3acb5c922ad055af029786c73e1a3d372 /pkgs/os-specific/linux/bpftools
parentd700d8e8a26427388cbe59149232ee104cf36644 (diff)
downloadnixpkgs-f831be559a62a58fe9d2a02ea383894bbc028f10.tar
nixpkgs-f831be559a62a58fe9d2a02ea383894bbc028f10.tar.gz
nixpkgs-f831be559a62a58fe9d2a02ea383894bbc028f10.tar.bz2
nixpkgs-f831be559a62a58fe9d2a02ea383894bbc028f10.tar.lz
nixpkgs-f831be559a62a58fe9d2a02ea383894bbc028f10.tar.xz
nixpkgs-f831be559a62a58fe9d2a02ea383894bbc028f10.tar.zst
nixpkgs-f831be559a62a58fe9d2a02ea383894bbc028f10.zip
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'.
Diffstat (limited to 'pkgs/os-specific/linux/bpftools')
-rw-r--r--pkgs/os-specific/linux/bpftools/default.nix2
-rw-r--r--pkgs/os-specific/linux/bpftools/strip-binary-name.patch15
2 files changed, 17 insertions, 0 deletions
diff --git a/pkgs/os-specific/linux/bpftools/default.nix b/pkgs/os-specific/linux/bpftools/default.nix
index ec109753c20..d3bb96afb3e 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 00000000000..623e90963bd
--- /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];
++	}