tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
linuxPackages.bcc: make it useable as a python library
Jörg Thalheim
7 years ago
c52dff6d
510efa72
+62
-15
4 changed files
expand all
collapse all
unified
split
pkgs
os-specific
linux
bcc
default.nix
fix-deadlock-detector-import.patch
libbcc-path.patch
top-level
all-packages.nix
+34
-14
pkgs/os-specific/linux/bcc/default.nix
···
1
1
{ stdenv, fetchFromGitHub, fetchpatch, makeWrapper, cmake, llvmPackages, kernel
2
2
-
, flex, bison, elfutils, python, pythonPackages, luajit, netperf, iperf, libelf
2
2
+
, flex, bison, elfutils, python, luajit, netperf, iperf, libelf
3
3
, systemtap
4
4
}:
5
5
6
6
-
stdenv.mkDerivation rec {
6
6
+
python.pkgs.buildPythonApplication rec {
7
7
version = "0.5.0";
8
8
name = "bcc-${version}";
9
9
···
13
13
rev = "v${version}";
14
14
sha256 = "0bb3244xll5sqx0lvrchg71qy2zg0yj6r5h4v5fvrg1fjhaldys9";
15
15
};
16
16
+
17
17
+
format = "other";
16
18
17
19
buildInputs = [
18
20
llvmPackages.llvm llvmPackages.clang-unwrapped kernel
19
19
-
elfutils python pythonPackages.netaddr luajit netperf iperf
21
21
+
elfutils luajit netperf iperf
20
22
systemtap.stapBuild
21
23
];
22
24
···
26
28
url = "https://github.com/iovisor/bcc/commit/bd7fa55bb39b8978dafd0b299e35616061e0a368.patch";
27
29
sha256 = "1sgxhsq174iihyk1x08py73q8fh78d7y3c90k5nh8vcw2pf1xbnf";
28
30
})
31
31
+
32
32
+
# This is needed until we fix
33
33
+
# https://github.com/NixOS/nixpkgs/issues/40427
34
34
+
./fix-deadlock-detector-import.patch
29
35
];
30
36
31
37
nativeBuildInputs = [ makeWrapper cmake flex bison ]
32
38
# libelf is incompatible with elfutils-libelf
33
39
++ stdenv.lib.filter (x: x != libelf) kernel.moduleBuildDependencies;
34
40
35
35
-
cmakeFlags =
36
36
-
[ "-DBCC_KERNEL_MODULES_DIR=${kernel.dev}/lib/modules"
37
37
-
"-DREVISION=${version}"
38
38
-
"-DENABLE_USDT=ON"
39
39
-
"-DENABLE_CPP_API=ON"
40
40
-
];
41
41
+
cmakeFlags = [
42
42
+
"-DBCC_KERNEL_MODULES_DIR=${kernel.dev}/lib/modules"
43
43
+
"-DREVISION=${version}"
44
44
+
"-DENABLE_USDT=ON"
45
45
+
"-DENABLE_CPP_API=ON"
46
46
+
];
47
47
+
48
48
+
postPatch = ''
49
49
+
substituteAll ${./libbcc-path.patch} ./libbcc-path.patch
50
50
+
patch -p1 < libbcc-path.patch
51
51
+
'';
52
52
+
53
53
+
propagatedBuildInputs = [
54
54
+
python.pkgs.netaddr
55
55
+
];
41
56
42
57
postInstall = ''
43
58
mkdir -p $out/bin $out/share
···
47
62
48
63
find $out/share/bcc/tools -type f -executable -print0 | \
49
64
while IFS= read -r -d ''$'\0' f; do
50
50
-
pythonLibs="$out/lib/python2.7/site-packages:${pythonPackages.netaddr}/lib/${python.libPrefix}/site-packages"
51
51
-
rm -f $out/bin/$(basename $f)
52
52
-
makeWrapper $f $out/bin/$(basename $f) \
53
53
-
--prefix LD_LIBRARY_PATH : $out/lib \
54
54
-
--prefix PYTHONPATH : "$pythonLibs"
65
65
+
bin=$out/bin/$(basename $f)
66
66
+
if [ ! -e $bin ]; then
67
67
+
ln -s $f $bin
68
68
+
fi
55
69
done
70
70
+
71
71
+
sed -i -e "s!lib=.*!lib=$out/bin!" $out/bin/{java,ruby,node,python}gc
72
72
+
'';
73
73
+
74
74
+
postFixup = ''
75
75
+
wrapPythonProgramsIn "$out/share/bcc/tools" "$out $pythonPath"
56
76
'';
57
77
58
78
meta = with stdenv.lib; {
+14
pkgs/os-specific/linux/bcc/fix-deadlock-detector-import.patch
···
1
1
+
--- source.org/tools/deadlock_detector.py 1980-01-02 00:00:00.000000000 +0000
2
2
+
+++ source/tools/deadlock_detector.py 2018-05-29 13:57:11.807126673 +0100
3
3
+
@@ -44,9 +44,8 @@
4
4
+
#
5
5
+
# 01-Feb-2017 Kenny Yu Created this.
6
6
+
7
7
+
-from __future__ import (
8
8
+
- absolute_import, division, unicode_literals, print_function
9
9
+
-)
10
10
+
+from __future__ import absolute_import, division, unicode_literals, print_function
11
11
+
+
12
12
+
from bcc import BPF
13
13
+
from collections import defaultdict
14
14
+
import argparse
+11
pkgs/os-specific/linux/bcc/libbcc-path.patch
···
1
1
+
--- source.org/src/python/bcc/libbcc.py 2018-05-13 08:35:06.850522883 +0100
2
2
+
+++ source/src/python/bcc/libbcc.py 2018-05-13 08:36:24.602733151 +0100
3
3
+
@@ -14,7 +14,7 @@
4
4
+
5
5
+
import ctypes as ct
6
6
+
7
7
+
-lib = ct.CDLL("libbcc.so.0", use_errno=True)
8
8
+
+lib = ct.CDLL("@out@/lib/libbcc.so.0", use_errno=True)
9
9
+
10
10
+
# keep in sync with bpf_common.h
11
11
+
lib.bpf_module_create_b.restype = ct.c_void_p
+3
-1
pkgs/top-level/all-packages.nix
···
13548
13548
13549
13549
batman_adv = callPackage ../os-specific/linux/batman-adv {};
13550
13550
13551
13551
-
bcc = callPackage ../os-specific/linux/bcc { };
13551
13551
+
bcc = callPackage ../os-specific/linux/bcc {
13552
13552
+
python = python3;
13553
13553
+
};
13552
13554
13553
13555
bbswitch = callPackage ../os-specific/linux/bbswitch {};
13554
13556