linuxPackages.bcc: make it useable as a python library

This commit is contained in:
Jörg Thalheim
2018-05-29 14:30:00 +01:00
parent 510efa7248
commit c52dff6d84
4 changed files with 62 additions and 15 deletions
+34 -14
View File
@@ -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; {