1{ lib, stdenv, fetchurl, fetchgit, autoreconfHook, dejagnu, elfutils }:
2
3stdenv.mkDerivation rec {
4 pname = "ltrace";
5 version = "0.7.91";
6
7 src = fetchurl {
8 url = "https://src.fedoraproject.org/repo/pkgs/ltrace/ltrace-0.7.91.tar.bz2/9db3bdee7cf3e11c87d8cc7673d4d25b/ltrace-0.7.91.tar.bz2";
9 sha256 = "sha256-HqellbKh2ZDHxslXl7SSIXtpjV1sodtgVwh8hgTC3Dc=";
10 };
11
12 nativeBuildInputs = [ autoreconfHook ]; # Some patches impact ./configure.
13 buildInputs = [ elfutils ];
14 nativeCheckInputs = [ dejagnu ];
15
16 # Import Fedora's (very) large patch series: bug fixes, architecture support,
17 # etc. RH/Fedora are currently working with upstream to merge all these
18 # patches for the next major branch.
19 prePatch = let
20 fedora = fetchgit {
21 url = "https://src.fedoraproject.org/rpms/ltrace.git";
22 rev = "00f430ccbebdbd13bdd4d7ee6303b091cf005542";
23 sha256 = "sha256-FBGEgmaslu7xrJtZ2WsYwu9Cw1ZQrWRV1+Eu9qLXO4s=";
24 };
25 in ''
26 # Order matters, read the patch list from the RPM spec. Our own patches
27 # are applied on top of the Fedora baseline.
28 fedorapatches=""
29 for p in $(grep '^Patch[0-9]\+:' ${fedora}/ltrace.spec | awk '{ print $2 }'); do
30 fedorapatches="$fedorapatches ${fedora}/$p"
31 done
32 patches="$fedorapatches $patches"
33 '';
34
35 # Cherry-pick extra patches for recent glibc support in the test suite.
36 patches = [
37 # https://gitlab.com/cespedes/ltrace/-/merge_requests/14
38 ./testsuite-newfstatat.patch
39 # https://gitlab.com/cespedes/ltrace/-/merge_requests/15
40 ./sysdeps-x86.patch
41 ];
42
43 doCheck = true;
44 checkPhase = ''
45 # Hardening options interfere with some of the low-level expectations in
46 # the test suite (e.g. printf ends up redirected to __printf_chk).
47 NIX_HARDENING_ENABLE="" \
48 # Disable test that requires ptrace-ing a non-child process, this might be
49 # forbidden by YAMA ptrace policy on the build host.
50 RUNTESTFLAGS="--host=${stdenv.hostPlatform.config} \
51 --target=${stdenv.targetPlatform.config} \
52 --ignore attach-process.exp" \
53 make check
54 '';
55
56 meta = with lib; {
57 description = "Library call tracer";
58 homepage = "https://www.ltrace.org/";
59 platforms = platforms.linux;
60 license = licenses.gpl2Plus;
61 maintainers = with maintainers; [ delroth ];
62 };
63}