git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commit1893ed54dc1ee7cef56be1c2ce7839c9523ba17e authorMogria <m0gr14@gmail.com> dateWed 15 Mar 2017, 11:32 (10 years ago) parentada3bcd
1 file changed+22−1
pkgs/applications/editors/sublime3/default.nix+22−1
pkgs/applications/editors/sublime3/default.nix+22−1
@@ -1,6 +1,6 @@
11{ fetchurl, stdenv, glib, xorg, cairo, gtk2, pango, makeWrapper, openssl, bzip2,
22 pkexecPath ? "/run/wrappers/bin/pkexec", libredirect,
3− gksuSupport ? false, gksu}:
3+ gksuSupport ? false, gksu, unzip, zip, bash }:
44
55assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
66assert gksuSupport -> gksu != null;
@@ -33,6 +33,21 @@ in let
3333 dontPatchELF = true;
3434 buildInputs = [ makeWrapper ];
3535
36+ # make exec.py in Default.sublime-package use own bash with
37+ # an LD_PRELOAD instead of "/bin/bash"
38+ patchPhase = ''
39+ mkdir Default.sublime-package-fix
40+ ( cd Default.sublime-package-fix
41+ ${unzip}/bin/unzip ../Packages/Default.sublime-package > /dev/null
42+ substituteInPlace "exec.py" --replace \
43+ "[\"/bin/bash\"" \
44+ "[\"$out/sublime_bash\""
45+ )
46+ ${zip}/bin/zip -j Default.sublime-package.zip Default.sublime-package-fix/* > /dev/null
47+ mv Default.sublime-package.zip Packages/Default.sublime-package
48+ rm -r Default.sublime-package-fix
49+ '';
50+
3651 buildPhase = ''
3752 for i in sublime_text plugin_host crash_reporter; do
3853 patchelf \
@@ -52,6 +67,12 @@ in let
5267 mkdir -p $out
5368 cp -prvd * $out/
5469
70+ # We can't just call /usr/bin/env bash because a relocation error occurs
71+ # when trying to run a build from within Sublime Text
72+ ln -s ${bash}/bin/bash $out/sublime_bash
73+ wrapProgram $out/sublime_bash \
74+ --set LD_PRELOAD "${stdenv.cc.cc.lib}/lib${stdenv.lib.optionalString stdenv.is64bit "64"}/libgcc_s.so.1"
75+
5576 wrapProgram $out/sublime_text \
5677 --set LD_PRELOAD "${libredirect}/lib/libredirect.so" \
5778 --set NIX_REDIRECTS ${builtins.concatStringsSep ":" redirects}