2020-09-16 22:53:19 +01:00
|
|
|
{ stdenv, fetchurl, bash, flex, bison, valgrind }:
|
2014-04-01 07:10:28 +01:00
|
|
|
|
2014-04-09 01:21:06 +01:00
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "lockdep";
|
2014-04-09 01:21:06 +01:00
|
|
|
|
2020-09-16 22:53:19 +01:00
|
|
|
# it would be nice to be able to pick a kernel version in sync with something
|
|
|
|
# else we already ship, but it seems userspace lockdep isn't very well maintained
|
|
|
|
# and appears broken in many kernel releases
|
|
|
|
version = "5.0.21";
|
|
|
|
fullver = "5.0.21";
|
2014-04-09 01:21:06 +01:00
|
|
|
src = fetchurl {
|
2020-09-16 22:53:19 +01:00
|
|
|
url = "mirror://kernel/linux/kernel/v5.x/linux-${version}.tar.xz";
|
|
|
|
sha256 = "1my2m9hvnvdrvzcg0fgqgaga59y2cd5zlpv7xrfj2nn98sjhglwq";
|
2014-04-09 01:21:06 +01:00
|
|
|
};
|
2014-04-01 07:10:28 +01:00
|
|
|
|
2020-09-16 22:53:19 +01:00
|
|
|
# ensure *this* kernel's userspace-headers are picked up before we
|
|
|
|
# fall back to those in glibc, as they will be from a mismatched
|
|
|
|
# kernel version
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace tools/lib/lockdep/Makefile \
|
|
|
|
--replace 'CONFIG_INCLUDES =' $'CONFIG_INCLUDES = -I../../../usr/include\n#'
|
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [ flex bison ];
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
make defconfig
|
|
|
|
make headers_install
|
|
|
|
cd tools/lib/lockdep
|
|
|
|
make
|
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
checkInputs = [ valgrind ];
|
|
|
|
checkPhase = ''
|
|
|
|
# there are more /bin/bash references than just shebangs
|
|
|
|
for f in lockdep run_tests.sh tests/*.sh; do
|
|
|
|
substituteInPlace $f \
|
|
|
|
--replace '/bin/bash' '${bash}/bin/bash'
|
|
|
|
done
|
|
|
|
|
|
|
|
./run_tests.sh
|
|
|
|
'';
|
|
|
|
|
2014-04-01 07:10:28 +01:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin $out/lib $out/include
|
|
|
|
|
|
|
|
cp -R include/liblockdep $out/include
|
|
|
|
make install DESTDIR=$out prefix=""
|
|
|
|
|
2014-10-09 22:56:09 +01:00
|
|
|
substituteInPlace $out/bin/lockdep --replace "./liblockdep.so" "$out/lib/liblockdep.so.$fullver"
|
2014-04-01 07:10:28 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
2016-06-20 11:53:46 +01:00
|
|
|
description = "Userspace locking validation tool built on the Linux kernel";
|
2014-04-01 07:10:28 +01:00
|
|
|
homepage = "https://kernel.org/";
|
|
|
|
license = stdenv.lib.licenses.gpl2;
|
|
|
|
platforms = stdenv.lib.platforms.linux;
|
|
|
|
maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
|
|
|
|
};
|
|
|
|
}
|