Advertisement
Guest User

matlab builder.sh

a guest
Dec 7th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.46 KB | None | 0 0
  1. source $stdenv/setup
  2.  
  3. # Pre-installation tasks like unpacking, changing path names, and using
  4. # patchelf on binary files
  5. echo "Unpacking source..."
  6. tar -xzvf $src
  7. cd mat/
  8.  
  9. echo "Patching install files..."
  10. substituteInPlace install \
  11.    --replace /bin/pwd $(type -P pwd)
  12. substituteInPlace bin/glnxa64/install_unix \
  13.    --replace /bin/pwd $(type -P pwd)
  14.  
  15. # Create the silent installer files
  16. _input_file=$(pwd)/_installer_input.txt
  17. _activation_file=$(pwd)/_activation.ini
  18.  
  19. echo "
  20. destinationFolder=$out
  21. agreeToLicense=yes
  22. mode=silent
  23. fileInstallationKey=$fileInstallationKey
  24. activationPropertiesFile=$_activation_file
  25. " >> $_input_file
  26.  
  27. for product in $activatedProducts; do
  28.     echo product.$product >> $_input_file
  29. done
  30.  
  31. echo "
  32. isSilent=True
  33. activateCommand=activateOffline
  34. licenseFile=$licenseFile
  35. installLicenseFileDir=$out/licenses
  36. installLicenseFileName=license.lic
  37. " >> $_activation_file
  38.  
  39. echo "Patching java..."
  40. chmod a+w sys/java/jre/glnxa64/jre/bin/java
  41. patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
  42.   --set-rpath "$libPath:$(patchelf --print-rpath sys/java/jre/glnxa64/jre/bin/java)"\
  43.   --force-rpath "sys/java/jre/glnxa64/jre/bin/java"
  44. chmod a-w sys/java/jre/glnxa64/jre/bin/java
  45.  
  46. # Run the installer with the generated input file
  47. echo "Running installer..."
  48. export MATLAB_ARCH=glnxa64
  49. ./install -inputFile $_input_file
  50.  
  51. # Run patchelf and substituteInPlace on various files in the output
  52. echo "Patching output..."
  53.  
  54. REPLACE_FILES=(
  55.     $out/bin/activate_matlab.sh
  56.     $out/bin/matlab
  57.     $out/bin/mbuild
  58.     $out/bin/mcc
  59.     $out/bin/mex
  60. )
  61.  
  62. for f in ${REPLACE_FILES[*]}; do
  63.     substituteInPlace $f\
  64.         --replace /bin/pwd $(type -P pwd)\
  65.         --replace /bin/echo $(type -P echo)
  66.     wrapProgram $f --set MATLAB_ARCH glnxa64
  67. done
  68.  
  69. PATCH_FILES=(
  70.     $out/bin/glnxa64/MATLAB
  71.     $out/bin/glnxa64/matlab_helper
  72.     $out/bin/glnxa64/mcc
  73.     $out/bin/glnxa64/mbuildHelp
  74.     $out/bin/glnxa64/mex
  75.     $out/bin/glnxa64/need_softwareopengl
  76.     $out/sys/java/jre/glnxa64/jre/bin/java
  77. )
  78.  
  79. for f in ${PATCH_FILES[*]}; do
  80.     chmod a+w $f
  81.     patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
  82.        --set-rpath "$libPath:$(patchelf --print-rpath $f)"\
  83.        --force-rpath $f
  84.     chmod a-w $f
  85. done
  86.  
  87.  
  88. # Set the correct path to gcc
  89. CC_FILES=(
  90.     $out/bin/mexopts.sh
  91. )
  92. for f in ${CC_FILES[*]}; do
  93.     substituteInPlace $f\
  94.         --replace "CC='gcc'" "CC='${gcc48}/bin/gcc'"
  95. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement