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