summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno JOFRET <bruno.jofret@scilab.org>2011-05-10 14:12:25 +0200
committerSylvestre Ledru <sylvestre.ledru@scilab.org>2011-05-10 14:41:20 +0200
commit58c8c65f6056add83e6905a6178d0eef2cf9d291 (patch)
tree293a20eb30412e3e7dbb988036f2eb5f1dd78227
parent8a49f7457e431f4e25e181f768a29a66d6ea6651 (diff)
downloadscilab-58c8c65f6056add83e6905a6178d0eef2cf9d291.zip
scilab-58c8c65f6056add83e6905a6178d0eef2cf9d291.tar.gz
Call Applescript only when needed. Fix BUG #9433
Change-Id: Id279ca16c34afd53f527021a2f56d8aaa6952bb7
-rw-r--r--scilab/bin/checkmacosx.applescript85
-rwxr-xr-xscilab/bin/scilab50
2 files changed, 65 insertions, 70 deletions
diff --git a/scilab/bin/checkmacosx.applescript b/scilab/bin/checkmacosx.applescript
index 542b109..e4ce7ca 100644
--- a/scilab/bin/checkmacosx.applescript
+++ b/scilab/bin/checkmacosx.applescript
@@ -1,76 +1,29 @@
1(************************************************************************* 1(*************************************************************************
2 * 2 *
3 * This code comes from the Openoffice project and has been adapted for 3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Scilab. 4 * Copyright (C) DIGITEO - 2011 - Sylvestre Ledru
5 * For now, this script checks the minimal version of Mac OS X 5 * Copyright (C) DIGITEO - 2011 - Bruno JOFRET
6 * 6 * This file must be used under the terms of the CeCILL.
7 * Copyright (C) 2011 - DIGITEO - Sylvestre LEDRU 7 * This source file is licensed as described in the file COPYING, which
8 * 8 * you should have received as part of this distribution. The terms
9 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9 * are also available at
10 * 10 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
11 * Copyright 2008 by Sun Microsystems, Inc. 11
12 * 12 * For now, this script displays a message if the version of mac os x
13 * OpenOffice.org - a multi-platform office productivity suite 13 * is wrong.
14 *
15 * $RCSfile: main.applescript,v $
16 * $Revision: 1.5 $
17 *
18 * This file is part of OpenOffice.org.
19 *
20 * OpenOffice.org is free software: you can redistribute it and/or modify
21 * it under the terms of the GNU Lesser General Public License version 3
22 * only, as published by the Free Software Foundation.
23 *
24 * OpenOffice.org is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU Lesser General Public License version 3 for more details
28 * (a copy is included in the LICENSE file that accompanied this code).
29 *
30 * You should have received a copy of the GNU Lesser General Public License
31 * version 3 along with OpenOffice.org. If not, see
32 * <http://www.openoffice.org/license.html>
33 * for a copy of the LGPLv3 License.
34 * 14 *
35 *************************************************************************) 15 *************************************************************************)
36 16
37on run() 17on run argv
38 -- Check for the required version of Mac OS X 18 tell application "System Events" -- Mandatory to use tell application otherwis, osascript complains
39 if (not atLeastOSXVersion(10, 6, 4) and not atLeastOSXVersion(10, 5, 8)) then 19 activate
40 tell application "System Events" -- Mandatory to use tell application otherwis, osascript complains 20 display dialog "This version of Scilab will probably fail on this system (" & item 1 of argv & "): Scilab requires " & item 2 of argv & "." buttons {"Try anyway", "Quit"} default button "Try anyway"
41 activate 21 if the button returned of the result is "Quit" then
42 display dialog "This version of Scilab will probably fail on this system: requires MacOSX 10.5.8 (Leopard) or 10.6.5 (Snow Leopard) or newer system" buttons {"Try anyway", "Quit"} default button "Try anyway" 22 error number 128
43 if the button returned of the result is "Quit" then
44 error number 128
45 return false 23 return false
46 else 24 else
47 return true 25 return true
48 end if 26 end if
49 end tell 27 end tell
50 end if
51end run 28end run
52 29
53-- Test for a minimum version of Mac OS X
54on atLeastOSXVersion(verMajor, verMinor, verStep)
55 -- The StandardAdditions's 'system attribute' used to be the Finder's 'computer' command.
56 tell application "Finder" to set sysv to (system attribute "sysv")
57
58 -- Generate sysv-compatible number from given version
59 set reqVer to ((verMajor div 10) * 4096 + (verMajor mod 10) * 256 + verMinor * 16 + verStep)
60
61 -- DEBUGGING:
62 -- display dialog ("RV:" & reqVer & " < " & sysv as string)
63
64 -- set major to ((sysv div 4096) * 10 + (sysv mod 4096 div 256))
65 -- set minor to (sysv mod 256 div 16)
66 -- set step to (sysv mod 16)
67 --display dialog ("Your Mac OS X version: " & major & "." & minor & "." & step)
68
69 if (reqVer > sysv) then
70 return false
71 else
72 return true
73 end if
74end atLeastOSXVersion
75
76
diff --git a/scilab/bin/scilab b/scilab/bin/scilab
index e3335bb..3de9757 100755
--- a/scilab/bin/scilab
+++ b/scilab/bin/scilab
@@ -4,7 +4,7 @@
4# Copyright (C) INRIA - 2006-2008 - Sylvestre Ledru 4# Copyright (C) INRIA - 2006-2008 - Sylvestre Ledru
5# Copyright (C) INRIA - 2008 - Simon Lipp 5# Copyright (C) INRIA - 2008 - Simon Lipp
6# Copyright (C) DIGITEO - 2009-2011 - Sylvestre Ledru 6# Copyright (C) DIGITEO - 2009-2011 - Sylvestre Ledru
7# Copyright (C) DIGITEO - 2010 - Bruno JOFRET 7# Copyright (C) DIGITEO - 2010-2011 - Bruno JOFRET
8# This file must be used under the terms of the CeCILL. 8# This file must be used under the terms of the CeCILL.
9# This source file is licensed as described in the file COPYING, which 9# This source file is licensed as described in the file COPYING, which
10# you should have received as part of this distribution. The terms 10# you should have received as part of this distribution. The terms
@@ -290,7 +290,7 @@ set_macosx_java_vm () {
290 JAVA_SHLIB="libjava.jnilib" 290 JAVA_SHLIB="libjava.jnilib"
291 JAVA_HOME=$(/usr/libexec/java_home --arch x86_64 --failfast --version 1.6+) 291 JAVA_HOME=$(/usr/libexec/java_home --arch x86_64 --failfast --version 1.6+)
292 DYLD_LIBRARY_PATH="$JAVA_HOME/../Libraries${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}" 292 DYLD_LIBRARY_PATH="$JAVA_HOME/../Libraries${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}"
293 293
294} 294}
295 295
296set_embedded_java_vm () { 296set_embedded_java_vm () {
@@ -623,6 +623,49 @@ cd "$LOCALOLDPWD"
623#fi 623#fi
624#export PVM_ARCH 624#export PVM_ARCH
625 625
626
627#
628# Scilab will not work on some Mac OSX version
629# Check version number and ask user if he wants to go on.
630#
631check_macosx_version()
632{
633 macosxVersion=`sw_vers | grep '^ProductVersion:' | grep -o '[0-9]*\.[0-9]*\.[0-9]*'`
634 macosxMajorVersion=`echo $macosxVersion | cut -d . -f 1`
635 macosxMinorVersion=`echo $macosxVersion | cut -d . -f 2`
636 macosxBuildVersion=`echo $macosxVersion | cut -d . -f 3`
637
638 if test $SCIVERBOSE -ne 0; then
639 echo "Found MacOSX Version: $macosxVersion"
640 fi
641
642 case $macosxMajorVersion in
643 10)
644 case $macosxMinorVersion in
645 6)
646 if test $macosxBuildVersion -le 4; then
647 # Version <= 10.6.4
648 osascript $BINPATH/checkmacosx.applescript $macosxVersion "10.6.5 (Snow Leopard) or newer system" || exit 128
649 fi
650 ;;
651# Does not work under 10.5 binary for now. Fail by default
652# 5)
653# if test $macosxBuildVersion -ge 8; then
654# # Version <= 10.5.8
655# osascript $BINPATH/checkmacosx.applescript $macosxVersion "10.5.8 (Leopard) or newer system" || exit 128
656# fi
657# ;;
658 *)
659 osascript $BINPATH/checkmacosx.applescript $macosxVersion "10.6.5 (Snow Leopard) or newer system" || exit 128
660 ;;
661 esac
662 ;;
663 *)
664 osascript $BINPATH/checkmacosx.applescript $macosxVersion "10.6.5 (Snow Leopard) or newer system" || exit 128
665 ;;
666 esac
667}
668
626SCILIB=$SCI/bin:$SCI/lib/scilab/:$SCI/lib64/scilab/ 669SCILIB=$SCI/bin:$SCI/lib/scilab/:$SCI/lib64/scilab/
627LD_LIBRARY_PATH=$SCILIB${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH} 670LD_LIBRARY_PATH=$SCILIB${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
628 671
@@ -649,7 +692,7 @@ case $OS in
649 BINPATH=$(dirname $0) 692 BINPATH=$(dirname $0)
650 # Do not perform the check with Scilab is started in CLI mode 693 # Do not perform the check with Scilab is started in CLI mode
651 if test "$SCILAB_MODE" = "gui"; then 694 if test "$SCILAB_MODE" = "gui"; then
652 osascript $BINPATH/checkmacosx.applescript || exit 128 695 check_macosx_version
653 fi 696 fi
654 ;; 697 ;;
655 *) 698 *)
@@ -673,7 +716,6 @@ fi
673do_scilex() 716do_scilex()
674{ 717{
675 "$SCILABBIN" "$@" 718 "$SCILABBIN" "$@"
676
677} 719}
678 720
679do_help() 721do_help()