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