1{ lib, stdenv, fetchFromGitHub, fetchpatch, bash, coreutils, gdb, zlib }:
2
3stdenv.mkDerivation rec {
4 pname = "procdump";
5 version = "1.2";
6
7 src = fetchFromGitHub {
8 owner = "Microsoft";
9 repo = "ProcDump-for-Linux";
10 rev = version;
11 sha256 = "sha256-gVswAezHl7E2cBTJEQhPFXhHkzhWVHSpPF8m0s8+ekc=";
12 };
13
14 patches = [
15 # Pull upstream patch to fix parallel builds:
16 # https://github.com/Sysinternals/ProcDump-for-Linux/pull/133
17 (fetchpatch {
18 name = "parallel.patch";
19 url = "https://github.com/Sysinternals/ProcDump-for-Linux/commit/0d735836f11281cc6134be93eac8acb302f2055e.patch";
20 sha256 = "sha256-zsqllPHF8ZuXAIDSAPvbzdKa43uSSx9ilUKM1vFVW90=";
21 })
22 ];
23
24 nativeBuildInputs = [ zlib ];
25 buildInputs = [ bash coreutils gdb ];
26
27 postPatch = ''
28 substituteInPlace src/CoreDumpWriter.c \
29 --replace '"gcore ' '"${gdb}/bin/gcore ' \
30 --replace '"rm ' '"${coreutils}/bin/rm ' \
31 --replace '/bin/bash' '${bash}/bin/bash'
32 '';
33
34 makeFlags = [
35 "DESTDIR=${placeholder "out"}"
36 "INSTALLDIR=/bin"
37 "MANDIR=/share/man/man1"
38 ];
39
40 enableParallelBuilding = true;
41
42 doCheck = false; # needs sudo root
43
44 doInstallCheck = true;
45 installCheckPhase = ''
46 runHook preInstallCheck
47 set +o pipefail
48 ($out/bin/procdump -h | grep "ProcDump v${version}") ||
49 (echo "ERROR: ProcDump is not the expected version or does not run properly" ; exit 1)
50 set -o pipefail
51 runHook postInstallCheck
52 '';
53
54 meta = with lib; {
55 description = "A Linux version of the ProcDump Sysinternals tool";
56 homepage = "https://github.com/Microsoft/ProcDump-for-Linux";
57 license = licenses.mit;
58 maintainers = with maintainers; [ c0bw3b ];
59 platforms = platforms.linux;
60 };
61}