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