aboutsummaryrefslogtreecommitdiff
path: root/pkgs/os-specific/linux/bcc
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2018-05-13 10:05:54 +0100
committerJörg Thalheim <joerg@thalheim.io>2018-05-29 14:30:00 +0100
commitc52dff6d841361071804fb66ed58ba1cf4d59aeb (patch)
tree1fecb4d82237f31e1318d775dd5c7740a85cbce2 /pkgs/os-specific/linux/bcc
parent510efa72488827937fb59763dae8e86735850679 (diff)
linuxPackages.bcc: make it useable as a python library
Diffstat (limited to 'pkgs/os-specific/linux/bcc')
-rw-r--r--pkgs/os-specific/linux/bcc/default.nix48
-rw-r--r--pkgs/os-specific/linux/bcc/fix-deadlock-detector-import.patch14
-rw-r--r--pkgs/os-specific/linux/bcc/libbcc-path.patch11
3 files changed, 59 insertions, 14 deletions
diff --git a/pkgs/os-specific/linux/bcc/default.nix b/pkgs/os-specific/linux/bcc/default.nix
index 2e2c872fb18..4f0a423600f 100644
--- a/pkgs/os-specific/linux/bcc/default.nix
+++ b/pkgs/os-specific/linux/bcc/default.nix
@@ -1,9 +1,9 @@
{ stdenv, fetchFromGitHub, fetchpatch, makeWrapper, cmake, llvmPackages, kernel
-, flex, bison, elfutils, python, pythonPackages, luajit, netperf, iperf, libelf
+, flex, bison, elfutils, python, luajit, netperf, iperf, libelf
, systemtap
}:
-stdenv.mkDerivation rec {
+python.pkgs.buildPythonApplication rec {
version = "0.5.0";
name = "bcc-${version}";
@@ -14,9 +14,11 @@ stdenv.mkDerivation rec {
sha256 = "0bb3244xll5sqx0lvrchg71qy2zg0yj6r5h4v5fvrg1fjhaldys9";
};
+ format = "other";
+
buildInputs = [
llvmPackages.llvm llvmPackages.clang-unwrapped kernel
- elfutils python pythonPackages.netaddr luajit netperf iperf
+ elfutils luajit netperf iperf
systemtap.stapBuild
];
@@ -26,18 +28,31 @@ stdenv.mkDerivation rec {
url = "https://github.com/iovisor/bcc/commit/bd7fa55bb39b8978dafd0b299e35616061e0a368.patch";
sha256 = "1sgxhsq174iihyk1x08py73q8fh78d7y3c90k5nh8vcw2pf1xbnf";
})
+
+ # This is needed until we fix
+ # https://github.com/NixOS/nixpkgs/issues/40427
+ ./fix-deadlock-detector-import.patch
];
nativeBuildInputs = [ makeWrapper cmake flex bison ]
# libelf is incompatible with elfutils-libelf
++ stdenv.lib.filter (x: x != libelf) kernel.moduleBuildDependencies;
- cmakeFlags =
- [ "-DBCC_KERNEL_MODULES_DIR=${kernel.dev}/lib/modules"
- "-DREVISION=${version}"
- "-DENABLE_USDT=ON"
- "-DENABLE_CPP_API=ON"
- ];
+ cmakeFlags = [
+ "-DBCC_KERNEL_MODULES_DIR=${kernel.dev}/lib/modules"
+ "-DREVISION=${version}"
+ "-DENABLE_USDT=ON"
+ "-DENABLE_CPP_API=ON"
+ ];
+
+ postPatch = ''
+ substituteAll ${./libbcc-path.patch} ./libbcc-path.patch
+ patch -p1 < libbcc-path.patch
+ '';
+
+ propagatedBuildInputs = [
+ python.pkgs.netaddr
+ ];
postInstall = ''
mkdir -p $out/bin $out/share
@@ -47,12 +62,17 @@ stdenv.mkDerivation rec {
find $out/share/bcc/tools -type f -executable -print0 | \
while IFS= read -r -d ''$'\0' f; do
- pythonLibs="$out/lib/python2.7/site-packages:${pythonPackages.netaddr}/lib/${python.libPrefix}/site-packages"
- rm -f $out/bin/$(basename $f)
- makeWrapper $f $out/bin/$(basename $f) \
- --prefix LD_LIBRARY_PATH : $out/lib \
- --prefix PYTHONPATH : "$pythonLibs"
+ bin=$out/bin/$(basename $f)
+ if [ ! -e $bin ]; then
+ ln -s $f $bin
+ fi
done
+
+ sed -i -e "s!lib=.*!lib=$out/bin!" $out/bin/{java,ruby,node,python}gc
+ '';
+
+ postFixup = ''
+ wrapPythonProgramsIn "$out/share/bcc/tools" "$out $pythonPath"
'';
meta = with stdenv.lib; {
diff --git a/pkgs/os-specific/linux/bcc/fix-deadlock-detector-import.patch b/pkgs/os-specific/linux/bcc/fix-deadlock-detector-import.patch
new file mode 100644
index 00000000000..87ce618a0dd
--- /dev/null
+++ b/pkgs/os-specific/linux/bcc/fix-deadlock-detector-import.patch
@@ -0,0 +1,14 @@
+--- source.org/tools/deadlock_detector.py 1980-01-02 00:00:00.000000000 +0000
++++ source/tools/deadlock_detector.py 2018-05-29 13:57:11.807126673 +0100
+@@ -44,9 +44,8 @@
+ #
+ # 01-Feb-2017 Kenny Yu Created this.
+
+-from __future__ import (
+- absolute_import, division, unicode_literals, print_function
+-)
++from __future__ import absolute_import, division, unicode_literals, print_function
++
+ from bcc import BPF
+ from collections import defaultdict
+ import argparse
diff --git a/pkgs/os-specific/linux/bcc/libbcc-path.patch b/pkgs/os-specific/linux/bcc/libbcc-path.patch
new file mode 100644
index 00000000000..187bb3aadd0
--- /dev/null
+++ b/pkgs/os-specific/linux/bcc/libbcc-path.patch
@@ -0,0 +1,11 @@
+--- source.org/src/python/bcc/libbcc.py 2018-05-13 08:35:06.850522883 +0100
++++ source/src/python/bcc/libbcc.py 2018-05-13 08:36:24.602733151 +0100
+@@ -14,7 +14,7 @@
+
+ import ctypes as ct
+
+-lib = ct.CDLL("libbcc.so.0", use_errno=True)
++lib = ct.CDLL("@out@/lib/libbcc.so.0", use_errno=True)
+
+ # keep in sync with bpf_common.h
+ lib.bpf_module_create_b.restype = ct.c_void_p