Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 buildFHSEnv,
4 runCommand,
5 stdenv,
6 fetchurl,
7 dpkg,
8 glibc,
9 callPackage,
10}:
11
12let
13 getSharedObjectFromDebian =
14 sharedObjectName: src:
15 stdenv.mkDerivation {
16 name = "${sharedObjectName}-fetcher";
17 inherit src;
18 nativeBuildInputs = [
19 dpkg
20 ];
21 dontBuild = true;
22 dontConfigure = true;
23 dontFixup = true;
24 installPhase = ''
25 echo shared objects found are:
26 ls -l usr/lib/*/
27 cp usr/lib/*/${sharedObjectName} $out
28 '';
29 };
30
31 makeSharedObjectTest =
32 sharedObject: targetPkgs:
33 let
34 lddFHSEnv = buildFHSEnv {
35 name = "ldd-with-ncurses-FHS-env";
36 inherit targetPkgs;
37 runScript = "ldd";
38 };
39 ldd-in-FHS = "${lddFHSEnv}/bin/${lddFHSEnv.name}";
40 ldd = "${lib.getBin glibc}/bin/ldd";
41 find_libFHSEnv = buildFHSEnv {
42 name = "ls-with-ncurses-FHS-env";
43 targetPkgs = p: [
44 p.ncurses5
45 ];
46 runScript = "find /lib/ -executable";
47 };
48 find_lib-in-FHS = "${find_libFHSEnv}/bin/${find_libFHSEnv.name}";
49 in
50 runCommand "FHS-lib-test"
51 {
52 meta = {
53 # Downloads an x86_64-linux only binary
54 platforms = [ "x86_64-linux" ];
55 };
56 }
57 ''
58 echo original ldd output is:
59 ${ldd} ${sharedObject}
60 lddOutput="$(${ldd-in-FHS} ${sharedObject})"
61 echo ldd output inside FHS is:
62 echo "$lddOutput"
63 if echo $lddOutput | grep -q "not found"; then
64 echo "shared object could not find all dependencies in the FHS!"
65 echo The libraries below where found in the FHS:
66 ${find_lib-in-FHS}
67 exit 1
68 else
69 echo $lddOutput > $out
70 fi
71 '';
72
73in
74{
75 # This test proves an issue with buildFHSEnv - don't expect it to succeed,
76 # this is discussed in https://github.com/NixOS/nixpkgs/pull/279844 .
77 libtinfo =
78 makeSharedObjectTest
79 (getSharedObjectFromDebian "libedit.so.2.0.70" (fetchurl {
80 url = "mirror://debian/pool/main/libe/libedit/libedit2_3.1-20221030-2_amd64.deb";
81 hash = "sha256-HPFKvycW0yedsS0GV6VzfPcAdKHnHTvfcyBmJePInOY=";
82 }))
83 (p: [
84 p.libtinfo
85 p.libbsd
86 ]);
87
88 liblzma =
89 makeSharedObjectTest
90 (getSharedObjectFromDebian "libxml2.so.2.9.14" (fetchurl {
91 url = "mirror://debian/pool/main/libx/libxml2/libxml2_2.9.14+dfsg-1.3~deb12u1_amd64.deb";
92 hash = "sha256-NbdstwOPwclAIEpPBfM/+3nQJzU85Gk5fZrc+Pmz4ac=";
93 }))
94 (p: [
95 p.xz
96 p.zlib
97 p.icu72
98 ]);
99}