ENH: fix advanced bug
[cmake.git] / Modules / CPack.RuntimeScript.in
blob1ce43bc7774fb45469dd60bbc689c2be5318b7cc
1 #!/bin/sh
3 # Modified from: Aaron Voisine <aaron@voisine.org>
5 CWD="`dirname \"$0\"`"
6 TMP=/tmp/$UID/TemporaryItems
8 ps -wx -ocommand | grep -e '[X]11.app' > /dev/null
9 if [ "$?" != "0" -a ! -f ~/.xinitrc ]; then
10 echo "rm -f ~/.xinitrc" > ~/.xinitrc
11 sed 's/xterm/# xterm/' /usr/X11R6/lib/X11/xinit/xinitrc >> ~/.xinitrc
14 mkdir -p $TMP
15 cat << __END_OF_GETDISPLAY_SCRIPT__ > "$TMP/getdisplay.sh"
16 #!/bin/sh
17 mkdir -p "$TMP"
19 if [ "\$DISPLAY"x == "x" ]; then
20 echo :0 > "$TMP/display"
21 else
22 echo \$DISPLAY > "$TMP/display"
24 __END_OF_GETDISPLAY_SCRIPT__
25 chmod +x "$TMP/getdisplay.sh"
26 rm -f $TMP/display
27 open-x11 $TMP/getdisplay.sh || \
28 open -a XDarwin $TMP/getdisplay.sh || \
29 echo ":0" > $TMP/display
31 while [ "$?" == "0" -a ! -f $TMP/display ];
33 #echo "Waiting for display $TMP/display"
34 sleep 1;
35 done
36 export "DISPLAY=`cat $TMP/display`"
38 ps -wx -ocommand | grep -e '[X]11' > /dev/null || exit 11
40 cd ~/
41 echo "$@" > /tmp/arguments.log
42 if echo $1 | grep -- "^-psn_"; then
43 shift
45 exec "$CWD/bin/@CPACK_EXECUTABLE_NAME@" "$@" > /tmp/slicer.output 2>&1