gerbil: simplify shebang patching

fixes #26338
This commit is contained in:
Jörg Thalheim 2017-06-03 10:17:44 +01:00
parent 7cbdb10576
commit de0d0da1fd
1 changed files with 21 additions and 40 deletions

View File

@ -9,60 +9,41 @@ stdenv.mkDerivation rec {
sha256 = "14wzdnifr99g1mvm2xwks97nhaq62hfx43pxcw9gs647i7cymbly"; sha256 = "14wzdnifr99g1mvm2xwks97nhaq62hfx43pxcw9gs647i7cymbly";
}; };
#version = "v0.7-49-g767926d"; buildInputs = [ gambit openssl zlib coreutils rsync bash ];
#src = fetchgit {
# url = "https://github.com/vyzo/gerbil.git";
# rev = "767926d7d6dde7e717cc51307f07e21859c79989";
# sha256 = "089lzsjmb43nns70pvn3kqg1gx6alsarbphvmh2a6qimnscdgv5z";
#};
# src = /home/fare/src/scheme/gerbil ;
buildInputs = [ gambit openssl zlib coreutils rsync ]; postPatch = ''
patchShebangs .
patchPhase = '' find . -type f -executable -print0 | while IFS= read -r -d ''$'\0' f; do
SCRIPTS=(
src/*.sh
src/gerbil/gx?
src/gerbil/runtime/build.scm
src/lang/build*ss
src/std/build*.ss
src/std/run-tests.ss
src/std/web/fastcgi-test.ss
src/std/web/rack-test.ss
src/tutorial/lang/build.ss
)
for f in "''${SCRIPTS[@]}" ; do
substituteInPlace "$f" --replace '#!/usr/bin/env bash' '#!${bash}/bin/bash'
substituteInPlace "$f" --replace '#!/usr/bin/env gsi-script' '#!${gambit}/bin/gsi-script'
substituteInPlace "$f" --replace '#!/usr/bin/env' '#!${coreutils}/bin/env' substituteInPlace "$f" --replace '#!/usr/bin/env' '#!${coreutils}/bin/env'
done done
''; '';
buildPhase = '' buildPhase = ''
runHook preBuild
( cd src && sh build.sh ) ( cd src && sh build.sh )
runHook postBuild
''; '';
installPhase = '' installPhase = ''
( mkdir -p $out/ runHook preInstall
cp -fa bin lib etc doc $out/ mkdir -p $out/
cd $out/bin cp -fa bin lib etc doc $out/
for f in "''${SCRIPTS[@]}" ; do
substituteInPlace gxc --replace "${coreutils}/bin/env gxi" "$out/bin/gxi" cat > $out/bin/gxi <<EOF
done #!${bash}/bin/bash -e
( echo '#!${bash}/bin/bash -e' export GERBIL_HOME=$out
echo "GERBIL_HOME=$out" case "\$1" in -:*) GSIOPTIONS=\$1 ; shift ;; esac
echo 'export GERBIL_HOME' if [[ \$# = 0 ]] ; then
echo 'case "$1" in -:*) GSIOPTIONS=$1 ; shift ;; esac' ${gambit}/bin/gsi \$GSIOPTIONS \$GERBIL_HOME/lib/gxi-init \$GERBIL_HOME/lib/gxi-interactive - ;
echo 'if [[ $# = 0 ]] ; then ' else
echo ' ${gambit}/bin/gsi $GSIOPTIONS $GERBIL_HOME/lib/gxi-init $GERBIL_HOME/lib/gxi-interactive - ;' ${gambit}/bin/gsi \$GSIOPTIONS \$GERBIL_HOME/lib/gxi-init "\$@"
echo 'else' fi
echo ' ${gambit}/bin/gsi $GSIOPTIONS $GERBIL_HOME/lib/gxi-init "$@"' EOF
echo 'fi' ) > $out/bin/gxi runHook postInstall
)
''; '';
dontStrip = true; dontStrip = true;
#dontFixup = true;
meta = { meta = {
description = "Gerbil"; description = "Gerbil";