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