Skip to content

Commit

Permalink
sublime3: fix hardcoded /bin/bash when executing commands for build s…
Browse files Browse the repository at this point in the history
…ystems (#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)
  • Loading branch information
mogria authored and globin committed Mar 15, 2017
1 parent 8ab7043 commit 15e0502
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion 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;
Expand Down Expand Up @@ -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 \
Expand All @@ -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}
Expand Down

0 comments on commit 15e0502

Please sign in to comment.