CPack.RuntimeScript.in 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/sh
  2. #
  3. # Modified from: Aaron Voisine <[email protected]>
  4. CWD="`dirname \"$0\"`"
  5. TMP=/tmp/$UID/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 < 10 )) || ((( $major == 10)) && (( $minor < 5 )))); then
  23. ps -wx -ocommand | grep -e '[X]11.app' > /dev/null
  24. if [ "$?" != "0" -a ! -f ~/.xinitrc ]; then
  25. echo "rm -f ~/.xinitrc" > ~/.xinitrc
  26. sed 's/xterm/# xterm/' /usr/X11R6/lib/X11/xinit/xinitrc >> ~/.xinitrc
  27. fi
  28. mkdir -p $TMP
  29. cat << __END_OF_GETDISPLAY_SCRIPT__ > "$TMP/getdisplay.sh"
  30. #!/bin/sh
  31. mkdir -p "$TMP"
  32. if [ "\$DISPLAY"x = "x" ]; then
  33. echo :0 > "$TMP/display"
  34. else
  35. echo \$DISPLAY > "$TMP/display"
  36. fi
  37. __END_OF_GETDISPLAY_SCRIPT__
  38. chmod +x "$TMP/getdisplay.sh"
  39. rm -f $TMP/display
  40. open-x11 $TMP/getdisplay.sh || \
  41. open -a XDarwin $TMP/getdisplay.sh || \
  42. echo ":0" > $TMP/display
  43. while [ "$?" = "0" -a ! -f $TMP/display ];
  44. do
  45. #echo "Waiting for display $TMP/display"
  46. sleep 1;
  47. done
  48. export "DISPLAY=`cat $TMP/display`"
  49. ps -wx -ocommand | grep -e '[X]11' > /dev/null || exit 11
  50. cd ~/
  51. echo "$@" > /tmp/arguments.log
  52. if echo $1 | grep -- "^-psn_"; then
  53. shift
  54. fi
  55. fi
  56. exec "$CWD/bin/@CPACK_EXECUTABLE_NAME@" "$@" > /tmp/slicer.output 2>&1