diff --git a/pkgs/development/libraries/gobject-introspection/default.nix b/pkgs/development/libraries/gobject-introspection/default.nix index 82be84e1f1d..bfcb9a44014 100644 --- a/pkgs/development/libraries/gobject-introspection/default.nix +++ b/pkgs/development/libraries/gobject-introspection/default.nix @@ -27,7 +27,7 @@ # it may be worth thinking about using multiple derivation outputs # In that case its about 6MB which could be separated -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "gobject-introspection"; version = "1.72.0"; @@ -37,7 +37,7 @@ stdenv.mkDerivation rec { outputBin = "dev"; src = fetchurl { - url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz"; + url = "mirror://gnome/sources/gobject-introspection/${lib.versions.majorMinor finalAttrs.version}/gobject-introspection-${finalAttrs.version}.tar.xz"; sha256 = "Av6OWQhh2I+DBg3TnNpcyqYLLaHSHQ+VSZMBsYa+qrw="; }; @@ -68,7 +68,7 @@ stdenv.mkDerivation rec { docbook-xsl-nons docbook_xml_dtd_45 python3 - setupHook # move .gir files + finalAttrs.setupHook # move .gir files ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ gobject-introspection-unwrapped ]; buildInputs = [ @@ -105,6 +105,10 @@ stdenv.mkDerivation rec { postInstall = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' cp -r ${buildPackages.gobject-introspection-unwrapped.devdoc} $devdoc + # these are uncompiled c and header files which aren't installed when cross-compiling because + # code that installs them is in tests/meson.build which is only run when not cross-compiling + # pygobject3 needs them + cp -r ${buildPackages.gobject-introspection-unwrapped.dev}/share/gobject-introspection-1.0/tests $dev/share/gobject-introspection-1.0/tests ''; preCheck = '' @@ -120,11 +124,21 @@ stdenv.mkDerivation rec { rm $out/lib/libregress-1.0${stdenv.targetPlatform.extensions.sharedLibrary} ''; + # when cross-compiling and using the wrapper then when a package looks up the g_ir_X + # variable with pkg-config they'll get the host version which can't be run + # switch the variables to use g_ir_X from path instead of an absolute path + postFixup = lib.optionalString (!lib.hasSuffix "wrapped" finalAttrs.pname) '' + find "''${!outputDev}/lib/pkgconfig" -name '*.pc' | while read pc; do + substituteInPlace "$pc" \ + --replace '=''${bindir}/g-ir' '=g-ir' + done + ''; + setupHook = ./setup-hook.sh; passthru = { updateScript = gnome.updateScript { - packageName = pname; + packageName = "gobject-introspection"; versionPolicy = "odd-unstable"; }; }; @@ -144,4 +158,4 @@ stdenv.mkDerivation rec { automatically provide bindings to call into the C library. ''; }; -} +}) diff --git a/pkgs/development/libraries/gobject-introspection/giscanner-ignore-error-return-codes-from-ldd-wrapper.patch b/pkgs/development/libraries/gobject-introspection/giscanner-ignore-error-return-codes-from-ldd-wrapper.patch new file mode 100644 index 00000000000..bf1c1f1b713 --- /dev/null +++ b/pkgs/development/libraries/gobject-introspection/giscanner-ignore-error-return-codes-from-ldd-wrapper.patch @@ -0,0 +1,32 @@ +From e0fc4a2a5161a36483ddc518be9bb14390f11b19 Mon Sep 17 00:00:00 2001 +From: Alexander Kanavin +Date: Wed, 5 Sep 2018 16:46:52 +0200 +Subject: [PATCH] giscanner: ignore error return codes from ldd-wrapper + +prelink-rtld, which we use instead of ldd returns 127 when it can't find a library. +It is not an error per se, but it breaks subprocess.check_output(). + +Upstream-Status: Inappropriate [oe-core specific] +Signed-off-by: Alexander Kanavin +Signed-off-by: Adam Duskett +--- + giscanner/shlibs.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/giscanner/shlibs.py b/giscanner/shlibs.py +index 9f8ab5df..7a1a72fe 100644 +--- a/giscanner/shlibs.py ++++ b/giscanner/shlibs.py +@@ -103,7 +103,7 @@ def _resolve_non_libtool(options, binary, libraries): + args.extend(['otool', '-L', binary.args[0]]) + else: + args.extend(['ldd', binary.args[0]]) +- output = subprocess.check_output(args) ++ output = subprocess.run(args, check=False, stdout=subprocess.PIPE).stdout + if isinstance(output, bytes): + output = output.decode("utf-8", "replace") + +-- +2.25.1 + + diff --git a/pkgs/development/libraries/gobject-introspection/wrapper.nix b/pkgs/development/libraries/gobject-introspection/wrapper.nix index 44d31540e64..e71f2f2fb46 100644 --- a/pkgs/development/libraries/gobject-introspection/wrapper.nix +++ b/pkgs/development/libraries/gobject-introspection/wrapper.nix @@ -7,9 +7,13 @@ # to build, run # `nix build ".#pkgsCross.aarch64-multiplatform.buildPackages.gobject-introspection"` -gobject-introspection-unwrapped.overrideAttrs (_previousAttrs: { +gobject-introspection-unwrapped.overrideAttrs (previousAttrs: { pname = "gobject-introspection-wrapped"; - postFixup = '' + depsTargetTargetPropagated = [ gobject-introspection-unwrapped ]; + # failure in e.g. pkgsCross.aarch64-multiplatform.polkit + # subprocess.CalledProcessError: Command '['/nix/store/...-prelink-unstable-2019-06-24/bin/prelink-rtld', '/build/source/build/tmp-introspectzp2ldkyk/PolkitAgent-1.0']' returned non-zero exit status 127. + patches = previousAttrs.patches ++ [ ./giscanner-ignore-error-return-codes-from-ldd-wrapper.patch ]; + postFixup = (previousAttrs.postFixup or "") + '' mv $dev/bin/g-ir-compiler $dev/bin/.g-ir-compiler-wrapped mv $dev/bin/g-ir-scanner $dev/bin/.g-ir-scanner-wrapped diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6508ddc8b2f..ac44da1d0c3 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -17899,7 +17899,7 @@ with pkgs; gns3-gui = gns3Packages.guiStable; gns3-server = gns3Packages.serverStable; - gobject-introspection = if (stdenv.hostPlatform != stdenv.targetPlatform) + gobject-introspection = if (!stdenv.hostPlatform.canExecute stdenv.targetPlatform) then callPackage ../development/libraries/gobject-introspection/wrapper.nix { } else gobject-introspection-unwrapped; gobject-introspection-unwrapped = callPackage ../development/libraries/gobject-introspection {