linuxPackages.bcc: make it useable as a python library
This commit is contained in:
parent
510efa7248
commit
c52dff6d84
@ -1,9 +1,9 @@
|
|||||||
{ stdenv, fetchFromGitHub, fetchpatch, makeWrapper, cmake, llvmPackages, kernel
|
{ 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
|
, systemtap
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
python.pkgs.buildPythonApplication rec {
|
||||||
version = "0.5.0";
|
version = "0.5.0";
|
||||||
name = "bcc-${version}";
|
name = "bcc-${version}";
|
||||||
|
|
||||||
@ -14,9 +14,11 @@ stdenv.mkDerivation rec {
|
|||||||
sha256 = "0bb3244xll5sqx0lvrchg71qy2zg0yj6r5h4v5fvrg1fjhaldys9";
|
sha256 = "0bb3244xll5sqx0lvrchg71qy2zg0yj6r5h4v5fvrg1fjhaldys9";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
format = "other";
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
llvmPackages.llvm llvmPackages.clang-unwrapped kernel
|
llvmPackages.llvm llvmPackages.clang-unwrapped kernel
|
||||||
elfutils python pythonPackages.netaddr luajit netperf iperf
|
elfutils luajit netperf iperf
|
||||||
systemtap.stapBuild
|
systemtap.stapBuild
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -26,18 +28,31 @@ stdenv.mkDerivation rec {
|
|||||||
url = "https://github.com/iovisor/bcc/commit/bd7fa55bb39b8978dafd0b299e35616061e0a368.patch";
|
url = "https://github.com/iovisor/bcc/commit/bd7fa55bb39b8978dafd0b299e35616061e0a368.patch";
|
||||||
sha256 = "1sgxhsq174iihyk1x08py73q8fh78d7y3c90k5nh8vcw2pf1xbnf";
|
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 ]
|
nativeBuildInputs = [ makeWrapper cmake flex bison ]
|
||||||
# libelf is incompatible with elfutils-libelf
|
# libelf is incompatible with elfutils-libelf
|
||||||
++ stdenv.lib.filter (x: x != libelf) kernel.moduleBuildDependencies;
|
++ stdenv.lib.filter (x: x != libelf) kernel.moduleBuildDependencies;
|
||||||
|
|
||||||
cmakeFlags =
|
cmakeFlags = [
|
||||||
[ "-DBCC_KERNEL_MODULES_DIR=${kernel.dev}/lib/modules"
|
"-DBCC_KERNEL_MODULES_DIR=${kernel.dev}/lib/modules"
|
||||||
"-DREVISION=${version}"
|
"-DREVISION=${version}"
|
||||||
"-DENABLE_USDT=ON"
|
"-DENABLE_USDT=ON"
|
||||||
"-DENABLE_CPP_API=ON"
|
"-DENABLE_CPP_API=ON"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
|
substituteAll ${./libbcc-path.patch} ./libbcc-path.patch
|
||||||
|
patch -p1 < libbcc-path.patch
|
||||||
|
'';
|
||||||
|
|
||||||
|
propagatedBuildInputs = [
|
||||||
|
python.pkgs.netaddr
|
||||||
|
];
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
mkdir -p $out/bin $out/share
|
mkdir -p $out/bin $out/share
|
||||||
@ -47,12 +62,17 @@ stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
find $out/share/bcc/tools -type f -executable -print0 | \
|
find $out/share/bcc/tools -type f -executable -print0 | \
|
||||||
while IFS= read -r -d ''$'\0' f; do
|
while IFS= read -r -d ''$'\0' f; do
|
||||||
pythonLibs="$out/lib/python2.7/site-packages:${pythonPackages.netaddr}/lib/${python.libPrefix}/site-packages"
|
bin=$out/bin/$(basename $f)
|
||||||
rm -f $out/bin/$(basename $f)
|
if [ ! -e $bin ]; then
|
||||||
makeWrapper $f $out/bin/$(basename $f) \
|
ln -s $f $bin
|
||||||
--prefix LD_LIBRARY_PATH : $out/lib \
|
fi
|
||||||
--prefix PYTHONPATH : "$pythonLibs"
|
|
||||||
done
|
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; {
|
meta = with stdenv.lib; {
|
||||||
|
@ -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
|
11
pkgs/os-specific/linux/bcc/libbcc-path.patch
Normal file
11
pkgs/os-specific/linux/bcc/libbcc-path.patch
Normal file
@ -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
|
@ -13548,7 +13548,9 @@ with pkgs;
|
|||||||
|
|
||||||
batman_adv = callPackage ../os-specific/linux/batman-adv {};
|
batman_adv = callPackage ../os-specific/linux/batman-adv {};
|
||||||
|
|
||||||
bcc = callPackage ../os-specific/linux/bcc { };
|
bcc = callPackage ../os-specific/linux/bcc {
|
||||||
|
python = python3;
|
||||||
|
};
|
||||||
|
|
||||||
bbswitch = callPackage ../os-specific/linux/bbswitch {};
|
bbswitch = callPackage ../os-specific/linux/bbswitch {};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user