CPack.RuntimeScript.in 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/sh
  2. #
  3. # Modified from: Aaron Voisine <aaron@voisine.org>
  4. CWD="`dirname \"$0\"`"
  5. TMP=/tmp/$(id -ru)/TemporaryItems
  6. version=`sw_vers -productVersion`
  7. if [ "$?" = "0" ]; then
  8. major=${version%%\.*}
  9. rest=${version#*\.}
  10. minor=${rest%%\.*}
  11. build=${rest#*\.}
  12. else
  13. major=10
  14. minor=4
  15. build=0
  16. fi
  17. echo $version
  18. echo "Major = $major"
  19. echo "Minor = $minor"
  20. echo "Build = $build"
  21. # if 10.5 or greater, then all the open-x11 stuff need not occur
  22. if [ "$major" -lt 10 ] || ([ "$major" -eq 10 ] && [ "$minor" -lt 5 ]); then
  23. version=`sw_vers -productVersion`
  24. if [ "$?" = "0" ]; then
  25. major=${version%%\.*}
  26. rest=${version#*\.}
  27. minor=${rest%%\.*}
  28. build=${rest#*\.}
  29. else
  30. major=10
  31. minor=4
  32. build=0
  33. fi
  34. echo $version
  35. echo "Major = $major"
  36. echo "Minor = $minor"
  37. echo "Build = $build"
  38. # if 10.5 or greater, then all the open-x11 stuff need not occur
  39. if [ "$major" -lt 10 ] || ([ "$major" -eq 10 ] && [ "$minor" -lt 5 ]); then
  40. ps -wx -ocommand | grep -e '[X]11.app' > /dev/null
  41. if [ "$?" != "0" -a ! -f ~/.xinitrc ]; then
  42. echo "rm -f ~/.xinitrc" > ~/.xinitrc
  43. sed 's/xterm/# xterm/' /usr/X11R6/lib/X11/xinit/xinitrc >> ~/.xinitrc
  44. fi
  45. mkdir -p $TMP
  46. cat << __END_OF_GETDISPLAY_SCRIPT__ > "$TMP/getdisplay.sh"
  47. #!/bin/sh
  48. mkdir -p "$TMP"
  49. if [ "\$DISPLAY"x = "x" ]; then
  50. echo :0 > "$TMP/display"
  51. else
  52. echo \$DISPLAY > "$TMP/display"
  53. fi
  54. __END_OF_GETDISPLAY_SCRIPT__
  55. fi
  56. chmod +x "$TMP/getdisplay.sh"
  57. rm -f $TMP/display
  58. open-x11 $TMP/getdisplay.sh || \
  59. open -a XDarwin $TMP/getdisplay.sh || \
  60. echo ":0" > $TMP/display
  61. while [ "$?" = "0" -a ! -f $TMP/display ];
  62. do
  63. #echo "Waiting for display $TMP/display"
  64. sleep 1;
  65. done
  66. export "DISPLAY=`cat $TMP/display`"
  67. ps -wx -ocommand | grep -e '[X]11' > /dev/null || exit 11
  68. cd ~/
  69. echo "$@" > /tmp/arguments.log
  70. if echo $1 | grep -- "^-psn_"; then
  71. shift
  72. fi
  73. fi
  74. exec "$CWD/bin/@CPACK_EXECUTABLE_NAME@" "$@" > /tmp/slicer.output 2>&1