2021-01-15 14:45:37 +00:00
|
|
|
{ lib, stdenv, fetchurl, bash, flex, bison, valgrind }:
|
2014-04-01 06:10:28 +00:00
|
|
|
|
2014-04-09 00:21:06 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "lockdep";
|
2014-04-09 00:21:06 +00:00
|
|
|
|
2020-09-16 21:53:19 +00: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 00:21:06 +00:00
|
|
|
src = fetchurl {
|
2020-09-16 21:53:19 +00:00
|
|
|
url = "mirror://kernel/linux/kernel/v5.x/linux-${version}.tar.xz";
|
|
|
|
sha256 = "1my2m9hvnvdrvzcg0fgqgaga59y2cd5zlpv7xrfj2nn98sjhglwq";
|
2014-04-09 00:21:06 +00:00
|
|
|
};
|
2014-04-01 06:10:28 +00:00
|
|
|
|
2020-09-16 21:53:19 +00: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 06:10:28 +00:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin $out/lib $out/include
|
|
|
|
|
|
|
|
cp -R include/liblockdep $out/include
|
|
|
|
make install DESTDIR=$out prefix=""
|
|
|
|
|
2014-10-09 21:56:09 +00:00
|
|
|
substituteInPlace $out/bin/lockdep --replace "./liblockdep.so" "$out/lib/liblockdep.so.$fullver"
|
2014-04-01 06:10:28 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
2016-06-20 10:53:46 +00:00
|
|
|
description = "Userspace locking validation tool built on the Linux kernel";
|
2014-04-01 06:10:28 +00:00
|
|
|
homepage = "https://kernel.org/";
|
2021-01-15 14:45:37 +00:00
|
|
|
license = lib.licenses.gpl2;
|
|
|
|
platforms = lib.platforms.linux;
|
|
|
|
maintainers = [ lib.maintainers.thoughtpolice ];
|
2014-04-01 06:10:28 +00:00
|
|
|
};
|
|
|
|
}
|