about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/misc/ltrace/default.nix
blob: c9ba073f6b34c3858c9b1718a8c838df97a16370 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{ lib, stdenv, fetchurl, fetchgit, autoreconfHook, dejagnu, elfutils }:

stdenv.mkDerivation rec {
  pname = "ltrace";
  version = "0.7.91";

  src = fetchurl {
    url = "https://src.fedoraproject.org/repo/pkgs/ltrace/ltrace-0.7.91.tar.bz2/9db3bdee7cf3e11c87d8cc7673d4d25b/ltrace-0.7.91.tar.bz2";
    sha256 = "sha256-HqellbKh2ZDHxslXl7SSIXtpjV1sodtgVwh8hgTC3Dc=";
  };

  nativeBuildInputs = [ autoreconfHook ];  # Some patches impact ./configure.
  buildInputs = [ elfutils ];
  nativeCheckInputs = [ dejagnu ];

  # Import Fedora's (very) large patch series: bug fixes, architecture support,
  # etc. RH/Fedora are currently working with upstream to merge all these
  # patches for the next major branch.
  prePatch = let
      fedora = fetchgit {
        url = "https://src.fedoraproject.org/rpms/ltrace.git";
        rev = "00f430ccbebdbd13bdd4d7ee6303b091cf005542";
        sha256 = "sha256-FBGEgmaslu7xrJtZ2WsYwu9Cw1ZQrWRV1+Eu9qLXO4s=";
      };
    in ''
      # Order matters, read the patch list from the RPM spec. Our own patches
      # are applied on top of the Fedora baseline.
      fedorapatches=""
      for p in $(grep '^Patch[0-9]\+:' ${fedora}/ltrace.spec | awk '{ print $2 }'); do
        fedorapatches="$fedorapatches ${fedora}/$p"
      done
      patches="$fedorapatches $patches"
    '';

  # Cherry-pick extra patches for recent glibc support in the test suite.
  patches = [
    # https://gitlab.com/cespedes/ltrace/-/merge_requests/14
    ./testsuite-newfstatat.patch
    # https://gitlab.com/cespedes/ltrace/-/merge_requests/15
    ./sysdeps-x86.patch
  ];

  doCheck = true;
  checkPhase = ''
    # Hardening options interfere with some of the low-level expectations in
    # the test suite (e.g. printf ends up redirected to __printf_chk).
    NIX_HARDENING_ENABLE="" \
    # Disable test that requires ptrace-ing a non-child process, this might be
    # forbidden by YAMA ptrace policy on the build host.
    RUNTESTFLAGS="--host=${stdenv.hostPlatform.config} \
                  --target=${stdenv.targetPlatform.config} \
                  --ignore attach-process.exp" \
      make check
  '';

  meta = with lib; {
    description = "Library call tracer";
    mainProgram = "ltrace";
    homepage = "https://www.ltrace.org/";
    platforms = platforms.linux;
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ delroth ];
  };
}