summaryrefslogtreecommitdiffstats
path: root/pkgs/test/buildFHSEnv
diff options
context:
space:
mode:
authorDoron Behar <doron.behar@gmail.com>2024-01-09 15:51:59 +0200
committerDoron Behar <doron.behar@gmail.com>2024-01-10 08:17:07 +0200
commitd3332be38c681b9087511acfc4553816e33ebcad (patch)
tree76c14ea3bccfc3701c28f2e0e2a643a28f3ec3bf /pkgs/test/buildFHSEnv
parent526a39a14012ec0ea3e3addd77e9d3364a084d5f (diff)
tests.buildFHSEnv.liblzma: init
Do so in a generalized manner.
Diffstat (limited to 'pkgs/test/buildFHSEnv')
-rw-r--r--pkgs/test/buildFHSEnv/default.nix69
1 files changed, 69 insertions, 0 deletions
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
+ ]);
+}