source: AE/Setup/Mac/Run AE Installer/Run AE Installer/AppDelegate.applescript@ 1029

Last change on this file since 1029 was 1029, checked in by iritscen, 9 years ago

AE Setup v1.1.7. Replacing simple AppleScript versions of AE Setup and Run AE Installer with AppleScriptObjC ports (Xcode projects) in order to produce a product that is more compatible with 10.6-10.11.

File size: 4.6 KB
RevLine 
[1029]1-- Run AE Installer
2-- for Anniversary Edition Seven
3-- by Iritscen
4-- Serves as a forking alias which opens either the AE Installer, or, if the AEI is
5-- not found, the AEI Updater so it can install the Installer. Used as both a
6-- shortcut for the user and as a part of the AE Setup process.
7-- History:
8-- 1.0.7 - Now an AppleScriptObjC application to ensure signing integrity and OS
9-- compatibility for 10.6 through 10.11.
10-- 1.0.6 - The previous method fails sometimes, e.g. in 10.7 with Apple Java
11-- installed, so now we are just looking in either place and calling Java
12-- when we find it.
13-- 1.0.5 - Removing "which java" as "smart" method for finding Java, as it can now
14-- return a value like "/usr/bin/java" even when Java is not really
15-- there; now calling Java using a fixed path for 10.6 and another fixed
16-- path for 10.7+.
17-- 1.0.4 - Calling Java through command-line again before falling back to Internet
18-- Plug-Ins location, to restore 10.6 compatibility.
19-- 1.0.3 - Instead of escaping only space characters in paths, put paths in quotes
20-- to avoid need for escaping entirely.
21-- 1.0.2 - Calling Java at Internet plug-in location instead of using basic command-
22-- line "java", as only the JDK installs command-line Java.
23-- 1.0.1 - Now setting environment to UTF-8 in order to avoid 'ƒ' problem in Java 7.
24-- 1.0 - Initial release.
25
26script AppDelegate
27 property parent : class "NSObject"
28 global parentPathUnixNS
29 global parentPathUnixStr
30 global parentPathASAlias
31 global parentPathASStr
32
33 -- IBOutlets
34 property theWindow : missing value
35
36 on applicationWillFinishLaunching_(aNotification)
37 tell application "Finder"
38 tell current application's class "NSBundle"
39 tell its mainBundle()
40 set parentPathUnixNS to bundlePath()'s stringByDeletingLastPathComponent
41 set parentPathUnixStr to parentPathUnixNS as string
42 end tell
43 end tell
44 set parentPathASAlias to POSIX file parentPathUnixStr as alias
45 set parentPathASStr to parentPathASAlias as string
46 set success to true
47
48 -- Test for Java at the two standard locations
49 set javaPath to "/Library/Internet\\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java"
50 set javaExistsTest to ("if [ -f " & javaPath & " ]; then echo okay; fi") as string
51 set javaExists to do shell script javaExistsTest without altering line endings
52 if (javaExists is "") then
53 -- Test for Java at old location (Apple Java)
54 set javaPath to "/usr/bin/java"
55 set javaExistsTest to ("if [ -f " & javaPath & " ]; then echo okay; fi") as string
56 set javaExists to do shell script javaExistsTest without altering line endings
57 if (javaExists is "") then
58 display alert "Could not find Java!"
59 set success to false
60 end if
61 end if
62
63 if (success is true) then
64 set AEIUfolder to parentPathASStr & "AEInstaller"
65 set AEIU to AEIUfolder & ":AEInstaller2Updater.jar"
66 set AEIU_CLI to POSIX path of AEIU
67 set run_AEIU to "export LC_CTYPE=\"UTF-8\";" & javaPath & " -jar \"" & AEIU_CLI & "\" &> /dev/null &"
68
69 set AEIfolder to parentPathASStr & "AEInstaller:bin"
70 set AEI to AEIfolder & ":AEInstaller2.jar"
71 set AEI_CLI to POSIX path of AEI
72 set run_AEI to "export LC_CTYPE=\"UTF-8\";" & javaPath & " -jar \"" & AEI_CLI & "\" &> /dev/null &"
73 if not (parentPathUnixNS's lastPathComponent as string is "AE") then
74 display alert "Please put \"Run AE Installer\" in the AE/ folder so I can find the Installer."
75 else if (AEI exists) then
76 do shell script run_AEI
77 else if (AEIU exists) then
78 do shell script run_AEIU
79 else
80 display alert "Could not find AE Installer *or* AE Installer Updater! You may need to re-install the AE."
81 end if
82 end if
83 end tell
84 tell me
85 quit
86 end tell
87 end applicationWillFinishLaunching_
88
89 on applicationShouldTerminate_(sender)
90 -- Insert code here to do any housekeeping before your application quits
91 return current application's NSTerminateNow
92 end applicationShouldTerminate_
93
94end script
Note: See TracBrowser for help on using the repository browser.