nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix

umockdev: Make library path references absolute

This simplifies consumers a lot.

+90
+21
pkgs/development/libraries/umockdev/default.nix
··· 28 28 sha256 = "sha256-FEmWjJVmKKckC30zULGI/mZ3VNtirnweZq2gKh/Y5VE="; 29 29 }; 30 30 31 + patches = [ 32 + # Hardcode absolute paths to libraries so that consumers 33 + # do not need to set LD_LIBRARY_PATH themselves. 34 + ./hardcode-paths.patch 35 + ]; 36 + 31 37 nativeBuildInputs = [ 32 38 docbook-xsl-nons 33 39 gobject-introspection ··· 62 56 ]; 63 57 64 58 doCheck = true; 59 + 60 + postPatch = '' 61 + # Substitute the path to this derivation in the patch we apply. 62 + substituteInPlace src/umockdev-wrapper \ 63 + --subst-var-by 'LIBDIR' "''${!outputLib}/lib" 64 + ''; 65 + 66 + preCheck = '' 67 + # Our patch makes the path to the `LD_PRELOAD`ed library absolute. 68 + # When running tests, the library is not yet installed, though, 69 + # so we need to replace the absolute path with a local one during build. 70 + # We are using a symlink that will be overridden during installation. 71 + mkdir -p "$out/lib" 72 + ln -s "$PWD/libumockdev-preload.so.0" "$out/lib/libumockdev-preload.so.0" 73 + ''; 65 74 66 75 meta = with lib; { 67 76 description = "Mock hardware devices for creating unit tests";
+69
pkgs/development/libraries/umockdev/hardcode-paths.patch
··· 1 + diff --git a/meson.build b/meson.build 2 + index 2ed9027..1f6bbf2 100644 3 + --- a/meson.build 4 + +++ b/meson.build 5 + @@ -38,6 +38,7 @@ g_ir_compiler = find_program('g-ir-compiler', required: false) 6 + 7 + conf.set('PACKAGE_NAME', meson.project_name()) 8 + conf.set_quoted('VERSION', meson.project_version()) 9 + +conf.set_quoted('LIBDIR', get_option('prefix') / get_option('libdir')) 10 + 11 + # glibc versions somewhere between 2.28 and 2.34 12 + if cc.has_function('__fxstatat', prefix: '#include <sys/stat.h>') 13 + @@ -148,7 +149,7 @@ hacked_gir = custom_target('UMockdev-1.0 hacked gir', 14 + 15 + if g_ir_compiler.found() 16 + umockdev_typelib = custom_target('UMockdev-1.0 typelib', 17 + - command: [g_ir_compiler, '--output', '@OUTPUT@', '-l', 'libumockdev.so.0', '@INPUT@'], 18 + + command: [g_ir_compiler, '--output', '@OUTPUT@', '-l', get_option('prefix') / get_option('libdir') / 'libumockdev.so.0', '@INPUT@'], 19 + input: hacked_gir, 20 + output: 'UMockdev-1.0.typelib', 21 + install: true, 22 + diff --git a/src/config.vapi b/src/config.vapi 23 + index 5269dd0..a2ec46d 100644 24 + --- a/src/config.vapi 25 + +++ b/src/config.vapi 26 + @@ -2,5 +2,6 @@ 27 + namespace Config { 28 + public const string PACKAGE_NAME; 29 + public const string VERSION; 30 + + public const string LIBDIR; 31 + } 32 + 33 + diff --git a/src/umockdev-record.vala b/src/umockdev-record.vala 34 + index 8434d32..68c7f8e 100644 35 + --- a/src/umockdev-record.vala 36 + +++ b/src/umockdev-record.vala 37 + @@ -435,7 +435,7 @@ main (string[] args) 38 + preload = ""; 39 + else 40 + preload = preload + ":"; 41 + - Environment.set_variable("LD_PRELOAD", preload + "libumockdev-preload.so.0", true); 42 + + Environment.set_variable("LD_PRELOAD", preload + Config.LIBDIR + "/libumockdev-preload.so.0", true); 43 + 44 + try { 45 + root_dir = DirUtils.make_tmp("umockdev.XXXXXX"); 46 + diff --git a/src/umockdev-run.vala b/src/umockdev-run.vala 47 + index 9a1ba10..6df2522 100644 48 + --- a/src/umockdev-run.vala 49 + +++ b/src/umockdev-run.vala 50 + @@ -95,7 +95,7 @@ main (string[] args) 51 + preload = ""; 52 + else 53 + preload = preload + ":"; 54 + - Environment.set_variable ("LD_PRELOAD", preload + "libumockdev-preload.so.0", true); 55 + + Environment.set_variable ("LD_PRELOAD", preload + Config.LIBDIR + "/libumockdev-preload.so.0", true); 56 + 57 + var testbed = new UMockdev.Testbed (); 58 + 59 + diff --git a/src/umockdev-wrapper b/src/umockdev-wrapper 60 + index 6ce4dcd..706c49a 100755 61 + --- a/src/umockdev-wrapper 62 + +++ b/src/umockdev-wrapper 63 + @@ -1,5 +1,5 @@ 64 + #!/bin/sh 65 + # Wrapper program to preload the libumockdev library, so that test programs can 66 + # set $UMOCKDEV_DIR for redirecting sysfs and other queries to a test bed. 67 + -exec env LD_PRELOAD=libumockdev-preload.so.0:$LD_PRELOAD "$@" 68 + +exec env LD_PRELOAD=@LIBDIR@/libumockdev-preload.so.0:$LD_PRELOAD "$@" 69 +