From d3332be38c681b9087511acfc4553816e33ebcad Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Tue, 9 Jan 2024 15:51:59 +0200 Subject: [PATCH 1/3] tests.buildFHSEnv.liblzma: init Do so in a generalized manner. --- pkgs/test/buildFHSEnv/default.nix | 69 +++++++++++++++++++++++++++++++ pkgs/test/default.nix | 2 + 2 files changed, 71 insertions(+) create mode 100644 pkgs/test/buildFHSEnv/default.nix diff --git a/pkgs/test/buildFHSEnv/default.nix b/pkgs/test/buildFHSEnv/default.nix new file mode 100644 index 000000000000..2f17e50a1582 --- /dev/null +++ b/pkgs/test/buildFHSEnv/default.nix @@ -0,0 +1,69 @@ +{ lib +, buildFHSEnv +, runCommand +, stdenv +, fetchurl +, dpkg +, glibc +, callPackage +}: + +let + getSharedObjectFromDebian = sharedObjectName: src: stdenv.mkDerivation { + name = "${sharedObjectName}-fetcher"; + inherit src; + nativeBuildInputs = [ + dpkg + ]; + dontBuild = true; + dontConfigure = true; + dontFixup = true; + installPhase = '' + echo shared objects found are: + ls -l usr/lib/*/ + cp usr/lib/*/${sharedObjectName} $out + ''; + }; + + makeSharedObjectTest = sharedObject: targetPkgs: let + lddFHSEnv = buildFHSEnv { + name = "ldd-with-ncurses-FHS-env"; + inherit targetPkgs; + runScript = "ldd"; + }; + ldd-in-FHS = "${lddFHSEnv}/bin/${lddFHSEnv.name}"; + ldd = "${lib.getBin glibc}/bin/ldd"; + find_libFHSEnv = buildFHSEnv { + name = "ls-with-ncurses-FHS-env"; + targetPkgs = p: [ + p.ncurses5 + ]; + runScript = "find /lib/ -executable"; + }; + find_lib-in-FHS = "${find_libFHSEnv}/bin/${find_libFHSEnv.name}"; + in runCommand "FHS-lib-test" {} '' + echo original ldd output is: + ${ldd} ${sharedObject} + lddOutput="$(${ldd-in-FHS} ${sharedObject})" + echo ldd output inside FHS is: + echo "$lddOutput" + if echo $lddOutput | grep -q "not found"; then + echo "shared object could not find all dependencies in the FHS!" + echo The libraries below where found in the FHS: + ${find_lib-in-FHS} + exit 1 + else + echo $lddOutput > $out + fi + ''; + +in { + liblzma = makeSharedObjectTest (getSharedObjectFromDebian "libxml2.so.2.9.14" (fetchurl { + url = "mirror://debian/pool/main/libx/libxml2/libxml2_2.9.14+dfsg-1.3~deb12u1_amd64.deb"; + hash = "sha256-NbdstwOPwclAIEpPBfM/+3nQJzU85Gk5fZrc+Pmz4ac="; + })) (p: [ + p.xz + p.zlib + p.icu72 + ]); +} diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix index 1459e9c310da..aa16c0f97858 100644 --- a/pkgs/test/default.nix +++ b/pkgs/test/default.nix @@ -168,5 +168,7 @@ with pkgs; pkgs-lib = recurseIntoAttrs (import ../pkgs-lib/tests { inherit pkgs; }); + buildFHSEnv = recurseIntoAttrs (callPackages ./buildFHSEnv { }); + nixpkgs-check-by-name = callPackage ./nixpkgs-check-by-name { }; } From 92a0043ecfca662725666a0d29e574d6c3e60a2e Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Wed, 10 Jan 2024 08:16:31 +0200 Subject: [PATCH 2/3] tests.buildFHSEnv.libtinfo: init --- pkgs/test/buildFHSEnv/default.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkgs/test/buildFHSEnv/default.nix b/pkgs/test/buildFHSEnv/default.nix index 2f17e50a1582..3a97359c6f33 100644 --- a/pkgs/test/buildFHSEnv/default.nix +++ b/pkgs/test/buildFHSEnv/default.nix @@ -58,6 +58,16 @@ let ''; in { + # This test proves an issue with buildFHSEnv - don't expect it to succeed, + # this is discussed in https://github.com/NixOS/nixpkgs/pull/279844 . + libtinfo = makeSharedObjectTest (getSharedObjectFromDebian "libedit.so.2.0.70" (fetchurl { + url = "mirror://debian/pool/main/libe/libedit/libedit2_3.1-20221030-2_amd64.deb"; + hash = "sha256-HPFKvycW0yedsS0GV6VzfPcAdKHnHTvfcyBmJePInOY="; + })) (p: [ + p.ncurses + p.libbsd + ]); + liblzma = makeSharedObjectTest (getSharedObjectFromDebian "libxml2.so.2.9.14" (fetchurl { url = "mirror://debian/pool/main/libx/libxml2/libxml2_2.9.14+dfsg-1.3~deb12u1_amd64.deb"; hash = "sha256-NbdstwOPwclAIEpPBfM/+3nQJzU85Gk5fZrc+Pmz4ac="; From 3b6e224d123b2c3ab84b5e6fa5b056ee4c629c23 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Tue, 16 Jan 2024 10:19:46 +0200 Subject: [PATCH 3/3] tests.buildFHSEnv.libtinfo: fix by using overriden ncurses --- pkgs/test/buildFHSEnv/default.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/test/buildFHSEnv/default.nix b/pkgs/test/buildFHSEnv/default.nix index 3a97359c6f33..0a355e1aeeac 100644 --- a/pkgs/test/buildFHSEnv/default.nix +++ b/pkgs/test/buildFHSEnv/default.nix @@ -63,8 +63,13 @@ in { libtinfo = makeSharedObjectTest (getSharedObjectFromDebian "libedit.so.2.0.70" (fetchurl { url = "mirror://debian/pool/main/libe/libedit/libedit2_3.1-20221030-2_amd64.deb"; hash = "sha256-HPFKvycW0yedsS0GV6VzfPcAdKHnHTvfcyBmJePInOY="; - })) (p: [ - p.ncurses + })) (p: let + ncurses' = p.ncurses.overrideAttrs (old: { + configureFlags = old.configureFlags ++ [ "--with-termlib" ]; + postFixup = ""; + }); + in [ + (ncurses'.override { unicodeSupport = false; }) p.libbsd ]);