CPack.RuntimeScript.in 1.85 KB
Newer Older
1 2 3 4 5
#!/bin/sh
#
# Modified from: Aaron Voisine <aaron@voisine.org>

CWD="`dirname \"$0\"`"
6
TMP=/tmp/$(id -ru)/TemporaryItems
7

8
version=`sw_vers -productVersion`
9
if [ "$?" = "0" ]; then
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
  major=${version%%\.*}
  rest=${version#*\.}
  minor=${rest%%\.*}
  build=${rest#*\.}
else
  major=10
  minor=4
  build=0
fi

echo $version
echo "Major = $major"
echo "Minor = $minor"
echo "Build = $build"


# if 10.5 or greater, then all the open-x11 stuff need not occur
27
if [ "$major" -lt 10 ] || ([ "$major" -eq 10 ] && [ "$minor" -lt 5 ]); then
28
version=`sw_vers -productVersion`
29
if [ "$?" = "0" ]; then
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
  major=${version%%\.*}
  rest=${version#*\.}
  minor=${rest%%\.*}
  build=${rest#*\.}
else
  major=10
  minor=4
  build=0
fi

echo $version
echo "Major = $major"
echo "Minor = $minor"
echo "Build = $build"


# if 10.5 or greater, then all the open-x11 stuff need not occur
47
if [ "$major" -lt 10 ] || ([ "$major" -eq 10 ] && [ "$minor" -lt 5 ]); then
48 49 50 51 52 53 54 55 56 57 58
ps -wx -ocommand | grep -e '[X]11.app' > /dev/null
if [ "$?" != "0" -a ! -f ~/.xinitrc ]; then
    echo "rm -f ~/.xinitrc" > ~/.xinitrc
    sed 's/xterm/# xterm/' /usr/X11R6/lib/X11/xinit/xinitrc >> ~/.xinitrc
fi

mkdir -p $TMP
cat << __END_OF_GETDISPLAY_SCRIPT__ > "$TMP/getdisplay.sh"
#!/bin/sh
mkdir -p "$TMP"

59
if [ "\$DISPLAY"x = "x" ]; then
60 61 62 63 64
    echo :0 > "$TMP/display"
else
    echo \$DISPLAY > "$TMP/display"
fi
__END_OF_GETDISPLAY_SCRIPT__
65
fi
66
chmod +x "$TMP/getdisplay.sh"
67 68 69 70 71
rm -f $TMP/display
open-x11 $TMP/getdisplay.sh || \
open -a XDarwin $TMP/getdisplay.sh || \
echo ":0" > $TMP/display

72
while [ "$?" = "0" -a ! -f $TMP/display ];
73 74 75 76
do
  #echo "Waiting for display $TMP/display"
  sleep 1;
done
77 78 79 80 81 82 83 84 85
export "DISPLAY=`cat $TMP/display`"

ps -wx -ocommand | grep -e '[X]11' > /dev/null || exit 11

cd ~/
echo "$@" > /tmp/arguments.log
if echo $1 | grep -- "^-psn_"; then
  shift
fi
86
fi
87
exec "$CWD/bin/@CPACK_EXECUTABLE_NAME@" "$@" > /tmp/slicer.output 2>&1