Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / CPack.RuntimeScript.in
1 #!/bin/sh
2 #
3 # Modified from: Aaron Voisine <aaron@voisine.org>
4
5 CWD="`dirname \"$0\"`"
6 TMP=/tmp/$(id -ru)/TemporaryItems
7
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
18 fi
19
20 echo $version
21 echo "Major = $major"
22 echo "Minor = $minor"
23 echo "Build = $build"
24
25
26 # 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   major=${version%%\.*}
31   rest=${version#*\.}
32   minor=${rest%%\.*}
33   build=${rest#*\.}
34 else
35   major=10
36   minor=4
37   build=0
38 fi
39
40 echo $version
41 echo "Major = $major"
42 echo "Minor = $minor"
43 echo "Build = $build"
44
45
46 # 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 ps -wx -ocommand | grep -e '[X]11.app' > /dev/null
49 if [ "$?" != "0" -a ! -f ~/.xinitrc ]; then
50     echo "rm -f ~/.xinitrc" > ~/.xinitrc
51     sed 's/xterm/# xterm/' /usr/X11R6/lib/X11/xinit/xinitrc >> ~/.xinitrc
52 fi
53
54 mkdir -p $TMP
55 cat << __END_OF_GETDISPLAY_SCRIPT__ > "$TMP/getdisplay.sh"
56 #!/bin/sh
57 mkdir -p "$TMP"
58
59 if [ "\$DISPLAY"x = "x" ]; then
60     echo :0 > "$TMP/display"
61 else
62     echo \$DISPLAY > "$TMP/display"
63 fi
64 __END_OF_GETDISPLAY_SCRIPT__
65 fi
66 chmod +x "$TMP/getdisplay.sh"
67 rm -f $TMP/display
68 open-x11 $TMP/getdisplay.sh || \
69 open -a XDarwin $TMP/getdisplay.sh || \
70 echo ":0" > $TMP/display
71
72 while [ "$?" = "0" -a ! -f $TMP/display ];
73 do
74   #echo "Waiting for display $TMP/display"
75   sleep 1;
76 done
77 export "DISPLAY=`cat $TMP/display`"
78
79 ps -wx -ocommand | grep -e '[X]11' > /dev/null || exit 11
80
81 cd ~/
82 echo "$@" > /tmp/arguments.log
83 if echo $1 | grep -- "^-psn_"; then
84   shift
85 fi
86 fi
87 exec "$CWD/bin/@CPACK_EXECUTABLE_NAME@" "$@" > /tmp/slicer.output 2>&1