lol

bcc: fix bashreadline

- we didn't provide the newly required elfutils python dependency,
but we're only dealing with newer bashes so just use the new symbol
- while here also default to using our libreadline as bash is configured
to use it on nixos; this can still be overriden

Link: https://github.com/iovisor/bcc/pull/4903
Fixes: #328743

authored by

Dominique Martinet and committed by
Jörg Thalheim
78a40d34 ba238f0e

+56 -1
+48
pkgs/by-name/bc/bcc/bashreadline.py-remove-dependency-on-elftools.patch
··· 1 + From 25c77bff079c331ae12d9e4499c82fdabf301610 Mon Sep 17 00:00:00 2001 2 + From: Dominique Martinet <asmadeus@codewreck.org> 3 + Date: Sun, 21 Jul 2024 20:59:51 +0900 4 + Subject: [PATCH] bashreadline.py: remove dependency on elftools 5 + 6 + This helper is only here to differentiate between very old bash 7 + versions or semi-recent ones; since we'll only catter to newer 8 + bash versions we don't need to bother with elftools here: 9 + just hardcode the newer symbol. 10 + --- 11 + tools/bashreadline.py | 14 +------------- 12 + 1 file changed, 1 insertion(+), 13 deletions(-) 13 + 14 + diff --git a/tools/bashreadline.py b/tools/bashreadline.py 15 + index 7e8324a2c0ea..e4b20aeb2371 100755 16 + --- a/tools/bashreadline.py 17 + +++ b/tools/bashreadline.py 18 + @@ -17,7 +17,6 @@ 19 + # 12-Feb-2016 Allan McAleavy migrated to BPF_PERF_OUTPUT 20 + 21 + from __future__ import print_function 22 + -from elftools.elf.elffile import ELFFile 23 + from bcc import BPF 24 + from time import strftime 25 + import argparse 26 + @@ -33,18 +32,7 @@ args = parser.parse_args() 27 + 28 + name = args.shared if args.shared else "/bin/bash" 29 + 30 + - 31 + -def get_sym(filename): 32 + - with open(filename, 'rb') as f: 33 + - elf = ELFFile(f) 34 + - symbol_table = elf.get_section_by_name(".dynsym") 35 + - for symbol in symbol_table.iter_symbols(): 36 + - if symbol.name == "readline_internal_teardown": 37 + - return "readline_internal_teardown" 38 + - return "readline" 39 + - 40 + - 41 + -sym = get_sym(name) 42 + +sym = "readline_internal_teardown" 43 + 44 + # load BPF program 45 + bpf_text = """ 46 + -- 47 + 2.45.2 48 +
+8 -1
pkgs/by-name/bc/bcc/package.nix
··· 15 15 netperf, 16 16 nixosTests, 17 17 python3Packages, 18 + readline, 18 19 stdenv, 19 20 zip, 20 21 }: ··· 50 51 # This is needed until we fix 51 52 # https://github.com/NixOS/nixpkgs/issues/40427 52 53 ./fix-deadlock-detector-import.patch 54 + # Quick & dirty fix for bashreadline 55 + # https://github.com/NixOS/nixpkgs/issues/328743 56 + ./bashreadline.py-remove-dependency-on-elftools.patch 53 57 ]; 54 58 55 59 propagatedBuildInputs = [ python3Packages.netaddr ]; ··· 85 89 86 90 # https://github.com/iovisor/bcc/issues/3996 87 91 substituteInPlace src/cc/libbcc.pc.in \ 88 - --replace '$'{exec_prefix}/@CMAKE_INSTALL_LIBDIR@ @CMAKE_INSTALL_FULL_LIBDIR@ 92 + --replace-fail '$'{exec_prefix}/@CMAKE_INSTALL_LIBDIR@ @CMAKE_INSTALL_FULL_LIBDIR@ 93 + 94 + substituteInPlace tools/bashreadline.py \ 95 + --replace-fail '/bin/bash' '${readline}/lib/libreadline.so' 89 96 ''; 90 97 91 98 preInstall = ''