2016-09-16 21:09:39 +01:00
|
|
|
{ fetchgit, pkgconfig, gettext, runCommand, makeWrapper
|
2018-02-20 15:11:12 +00:00
|
|
|
, elfutils, kernel, gnumake, python2, python2Packages
|
2017-10-11 00:01:42 +01:00
|
|
|
}:
|
|
|
|
|
2016-09-16 00:08:36 +01:00
|
|
|
let
|
|
|
|
## fetchgit info
|
|
|
|
url = git://sourceware.org/git/systemtap.git;
|
2018-03-03 16:59:28 +00:00
|
|
|
rev = "4051c70c9318c837981384cbb23f3e9eb1bd0892";
|
|
|
|
sha256 = "0sd8n3j3rishks3gyqj2jyqhps7hmlfjyz8i0w8v98cczhhh04rq";
|
|
|
|
version = "2017.10.18";
|
2016-09-16 00:08:36 +01:00
|
|
|
|
2016-09-16 21:09:39 +01:00
|
|
|
inherit (kernel) stdenv;
|
|
|
|
inherit (stdenv) lib;
|
2016-09-16 00:08:36 +01:00
|
|
|
|
|
|
|
## stap binaries
|
2016-09-16 21:09:39 +01:00
|
|
|
stapBuild = stdenv.mkDerivation {
|
2016-09-16 00:08:36 +01:00
|
|
|
name = "systemtap-${version}";
|
|
|
|
src = fetchgit { inherit url rev sha256; };
|
2018-03-03 16:59:28 +00:00
|
|
|
nativeBuildInputs = [ pkgconfig ];
|
2018-02-20 15:11:12 +00:00
|
|
|
buildInputs = [ elfutils gettext python2 python2Packages.setuptools ];
|
2017-02-05 05:43:35 +00:00
|
|
|
# FIXME: Workaround for bug in kbuild, where quoted -I"/foo" flags would get mangled in out-of-tree kbuild dirs
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace buildrun.cxx --replace \
|
|
|
|
'o << "EXTRA_CFLAGS += -I\"" << s.runtime_path << "\"" << endl;' \
|
|
|
|
'o << "EXTRA_CFLAGS += -I" << s.runtime_path << endl;'
|
|
|
|
'';
|
2016-09-16 00:08:36 +01:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
## a kernel build dir as expected by systemtap
|
2016-09-16 21:09:39 +01:00
|
|
|
kernelBuildDir = runCommand "kbuild-${kernel.version}-merged" { } ''
|
2016-09-16 00:08:36 +01:00
|
|
|
mkdir -p $out
|
2016-09-16 21:09:39 +01:00
|
|
|
for f in \
|
|
|
|
${kernel}/System.map \
|
|
|
|
${kernel.dev}/vmlinux \
|
|
|
|
${kernel.dev}/lib/modules/${kernel.modDirVersion}/build/{*,.*}
|
|
|
|
do
|
|
|
|
ln -s $(readlink -f $f) $out
|
|
|
|
done
|
2016-09-16 00:08:36 +01:00
|
|
|
'';
|
|
|
|
|
2018-02-20 15:11:12 +00:00
|
|
|
pypkgs = with python2Packages; makePythonPath [ pyparsing ];
|
|
|
|
|
2016-09-16 00:08:36 +01:00
|
|
|
in runCommand "systemtap-${kernel.version}-${version}" {
|
|
|
|
inherit stapBuild kernelBuildDir;
|
|
|
|
buildInputs = [ makeWrapper ];
|
2016-09-16 21:09:39 +01:00
|
|
|
meta = {
|
2016-09-16 00:08:36 +01:00
|
|
|
homepage = https://sourceware.org/systemtap/;
|
2016-09-16 21:09:39 +01:00
|
|
|
repositories.git = url;
|
|
|
|
description = "Provides a scripting language for instrumentation on a live kernel plus user-space";
|
|
|
|
license = lib.licenses.gpl2;
|
|
|
|
platforms = lib.platforms.linux;
|
2016-09-16 00:08:36 +01:00
|
|
|
};
|
|
|
|
} ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
for bin in $stapBuild/bin/*; do # hello emacs */
|
2016-09-16 21:09:39 +01:00
|
|
|
ln -s $bin $out/bin
|
2016-09-16 00:08:36 +01:00
|
|
|
done
|
2018-02-20 15:11:12 +00:00
|
|
|
rm $out/bin/stap $out/bin/dtrace
|
2016-09-16 00:08:36 +01:00
|
|
|
makeWrapper $stapBuild/bin/stap $out/bin/stap \
|
|
|
|
--add-flags "-r $kernelBuildDir" \
|
2017-10-11 00:01:42 +01:00
|
|
|
--prefix PATH : ${lib.makeBinPath [ stdenv.cc.cc stdenv.cc.bintools elfutils gnumake ]}
|
2018-02-20 15:11:12 +00:00
|
|
|
makeWrapper $stapBuild/bin/dtrace $out/bin/dtrace \
|
|
|
|
--prefix PYTHONPATH : ${pypkgs}
|
2016-09-16 00:08:36 +01:00
|
|
|
''
|