From 1893ed54dc1ee7cef56be1c2ce7839c9523ba17e Mon Sep 17 00:00:00 2001 From: Mogria Date: Wed, 15 Mar 2017 11:32:44 +0100 Subject: [PATCH] sublime3: fix hardcoded /bin/bash when executing commands for build systems (#23561) * sublime3: replace hardcoded /bin/bash with /usr/bin/env exec.py in Default.package-sublime calls /bin/bash with subprocess. See Issue #12011. Because of this builds could not be started from withtin Sublime Text. * sublime3: use wrapped of bash to fix internal build system Without the wrapped version of bash (a symlink to $bash/bin/bash) with LD_PRELOAD to glibc an relocation error occurs when trying to run builds from within Sublime Text 3. See Issue #12011. --- .../applications/editors/sublime3/default.nix | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/editors/sublime3/default.nix b/pkgs/applications/editors/sublime3/default.nix index 8912aca0711d..0b8ecda62302 100644 --- a/pkgs/applications/editors/sublime3/default.nix +++ b/pkgs/applications/editors/sublime3/default.nix @@ -1,6 +1,6 @@ { fetchurl, stdenv, glib, xorg, cairo, gtk2, pango, makeWrapper, openssl, bzip2, pkexecPath ? "/run/wrappers/bin/pkexec", libredirect, - gksuSupport ? false, gksu}: + gksuSupport ? false, gksu, unzip, zip, bash }: assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux"; assert gksuSupport -> gksu != null; @@ -33,6 +33,21 @@ in let dontPatchELF = true; buildInputs = [ makeWrapper ]; + # make exec.py in Default.sublime-package use own bash with + # an LD_PRELOAD instead of "/bin/bash" + patchPhase = '' + mkdir Default.sublime-package-fix + ( cd Default.sublime-package-fix + ${unzip}/bin/unzip ../Packages/Default.sublime-package > /dev/null + substituteInPlace "exec.py" --replace \ + "[\"/bin/bash\"" \ + "[\"$out/sublime_bash\"" + ) + ${zip}/bin/zip -j Default.sublime-package.zip Default.sublime-package-fix/* > /dev/null + mv Default.sublime-package.zip Packages/Default.sublime-package + rm -r Default.sublime-package-fix + ''; + buildPhase = '' for i in sublime_text plugin_host crash_reporter; do patchelf \ @@ -52,6 +67,12 @@ in let mkdir -p $out cp -prvd * $out/ + # We can't just call /usr/bin/env bash because a relocation error occurs + # when trying to run a build from within Sublime Text + ln -s ${bash}/bin/bash $out/sublime_bash + wrapProgram $out/sublime_bash \ + --set LD_PRELOAD "${stdenv.cc.cc.lib}/lib${stdenv.lib.optionalString stdenv.is64bit "64"}/libgcc_s.so.1" + wrapProgram $out/sublime_text \ --set LD_PRELOAD "${libredirect}/lib/libredirect.so" \ --set NIX_REDIRECTS ${builtins.concatStringsSep ":" redirects}