Skip to content

Commit 5ba8460

Browse files
mogriaMic92
authored andcommittedJun 1, 2017
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. (cherry picked from commit 1893ed5)
1 parent 149b025 commit 5ba8460

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed
 

‎pkgs/applications/editors/sublime3/default.nix

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{ fetchurl, stdenv, glib, xorg, cairo, gtk, pango, makeWrapper, openssl, bzip2,
22
pkexecPath ? "/var/setuid-wrappers/pkexec", libredirect,
3-
gksuSupport ? false, gksu}:
3+
gksuSupport ? false, gksu, bash}:
44

55
assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
66
assert 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}

0 commit comments

Comments
 (0)
Please sign in to comment.