1 dnl `uname -m` quoting is a nightmare
2 dnl <sander> TTimo: You could do: `uname -a`
9 # TTimo - run in fink environement
10 # I am not entirely sure this is needed
11 # but in any case, it doesn't hurt
12 ifdef([[M4_OSX]], [[source /sw/bin/init.sh]])
13 # Go to the proper setup directory (if not already there)
17 FATAL_ERROR="Fatal error, no tech support email configured in this setup"
18 # try to get root prior to running setup?
20 # 1: prompt, but run anyway if fails
21 # 2: require, abort if root fails
24 # You may want to set USE_XHOST to 1 if you want an X11 application to
25 # be launched with root privileges right after installation
27 # this is the message for su call, printf
28 SU_MESSAGE="You need to run this installation as the super user.\nPlease enter the root password."
31 # See if we have the XPG4 utilities (Solaris)
32 if test -d /usr/xpg4/bin; then
33 PATH=/usr/xpg4/bin:$PATH
36 # Return the appropriate architecture string
53 arch=`uname -p 2> /dev/null || uname -m`
54 if test "$arch" = powerpc; then
65 # Return the appropriate version string
69 if [ `uname -s` != Linux ]; then
73 if [ -f `echo /lib/libc.so.6* | tail -1` ]; then
74 if fgrep GLIBC_2.1 /lib/libc.so.6* 2> $NULL >> $NULL; then
81 elif [ -f /lib/libc.so.5 ]; then
93 if test "$os" = "OpenUNIX"; then
101 # Detect the environment
106 # Import preferences from a secondary script
107 if [ -f setup.data/config.sh ]; then
108 . setup.data/config.sh
109 elif [ -f SETUP.DAT/CONFIG.SH\;1 ]; then
110 # HP-UX and other systems unable to get LFN correctly
111 . SETUP.DAT/CONFIG.SH\;1
114 # Add some standard paths for compatibility
117 # call setup with -auth when ran through su/xsu
119 if [ "$1" = "-auth" ]
127 # if root is absolutely required
128 # this happens if xsu/su execs setup.sh but it still doesn't have root rights
129 if [ "$GET_ROOT" -eq 2 ]
131 # NOTE TTimo: this causes the following error message in some cases:
132 # return: can only `return' from a function or sourced script
133 # BUT: in other cases, the return is legit, if you replace by an exit call, it's broken
138 # Feel free to add some additional command-line arguments for setup here.
141 # Find the installation program
142 # try_run [-absolute] [-fatal] INSTALLER_NAME [PARAMETERS_PASSED]
143 # -absolute option: if what you are trying to execute has an absolute path
144 # NOTE: maybe try_run_absolute would be easier
145 # -fatal option: if you want verbose messages in case
146 # - the script could not be found
147 # - it's execution would fail
148 # INSTALLER_NAME: setup.gtk or setup
149 # PARAMETERS_PASSED: additional arguments passed to the setup script
153 if [ "$1" = "-absolute" ]; then
159 # older bash < 2.* don't like == operator, using =
160 if [ "$1" = "-fatal" ]; then
169 # First find the binary we want to run
171 if [ "$absolute" -eq 0 ]
173 setup_bin="setup.data/bin/$os/$arch/$libc/$setup"
175 if [ ! -f "$setup_bin" ]; then
176 setup_bin="setup.data/bin/$os/$arch/$setup"
177 # libc dependant version failed, trying again
178 if [ ! -f "$setup_bin" ]; then
182 if [ "$failed" -eq 1 ]; then
183 if [ "$fatal" -eq 1 ]; then
185 This installation doesn't support $libc on $os / $arch
186 (tried to run $setup)
193 # Try to run the binary ($setup_bin)
194 # The executable is here but we can't execute it from CD
195 # NOTE TTimo: this is dangerous, we also use $setup to store the name of the try_run
196 setup="$HOME/.setup$$"
198 cp "$setup_bin" "$setup"
201 # echo Running "$setup" "$@"
202 if [ "$fatal" -eq 0 ]; then
206 "$setup" "$@" 2>> $NULL
209 if [ "$absolute" -eq 0 ]
211 # don't attempt removal when we are passed an absolute path
212 # no, I don't want to imagine a faulty try_run as root on /bin/su
218 # if we have not been through the auth yet, and if we need to get root, then prompt
219 if [ "$auth" -eq 0 ] && [ "$GET_ROOT" -ne 0 ]
222 if [ "$GOT_ROOT" != "0" ]
225 if [ "$USE_XHOST" -eq 1 ]; then
226 xhost +127.0.0.1 2> $NULL > $NULL
228 try_run xsu -e -a -u root -c "sh `pwd`/setup.sh -auth" $XSU_ICON
231 # if try_run successfully executed xsu, it will return xsu's exit code
232 # xsu returns 2 if ran and cancelled (i.e. the user 'doesn't want' to auth)
233 # it will return 0 if the command was executed correctly
234 # summing up, if we get 1, something failed
235 if [ "$status" -eq 0 ]
237 # the auth command was properly executed
239 elif [ "$status" -eq 1 ]
241 ifdef([[M4_OSX]], [[echo "You need to run the installer as root" ; exit 1]])
242 # xsu wasn't found, or failed to run
243 # if xsu actually ran and the auth was cancelled, $status is 2
245 printf "$SU_MESSAGE\n"
246 try_run -absolute /bin/su root -c "export DISPLAY=$DISPLAY;sh `pwd`/setup.sh -auth"
248 elif [ "$status" -eq 3 ]
250 # the auth failed or was canceled
251 # we don't want to even start the setup if not root
252 echo "Please run this installation as the super user"
255 # continue running as is
259 # Try to run the setup program
260 # TTimo - setup.gtk only
261 # try_run setup.gtk $args $*
263 # if [ $status -eq 2 ]; then # setup.gtk couldn't connect to X11 server - ignore
264 try_run -fatal setup.gtk $args $* || {
266 echo "setup.gtk failed to start?"
267 echo "DISPLAY: $DISPLAY"
268 echo "Do you need to issue an xhost + command to let root access X11?"
269 ifdef([[M4_OSX]], [[echo "See http://www.qeradiant.com/wikifaq/index.php?OSX%20fink%20installer%20known%20issues for details"]])
270 echo "The setup program seems to have failed on $arch/$libc"