Update ooo320-m1
[ooovba.git] / setup_native / scripts / osx_install_languagepack.applescript
blob33d376adec1b8b6c37557b159007c2d05f50fc9b
1 (*
2 This script is meant to
3 1) Identify installed instances of the product
4 2) check whether the user has write-access (and if not
5 ask for authentification)
6 3) install the shipped tarball
7 *)
9 -- strings for localisations - to be meant to be replaced
10 -- by a makefile or similar
11 set OKLabel to "[OKLabel]"
12 set InstallLabel to "[InstallLabel]"
13 set AbortLabel to "[AbortLabel]"
14 set intro to "[IntroText1]
16 [IntroText2]
18 [IntroText3]"
19 set chooseMyOwn to "[ChooseMyOwnText]"
20 set listPrompt to "[ListPromptText]"
21 set chooseManual to "[ChooseManualText]"
22 set listOKLabel to "[ListOKLabelText]"
23 set listCancelLabel to "[ListCancelLabel]"
24 set appInvalid to "[AppInvalidText1]
26 [AppInvalidText2]" -- string will begin with the chosen application's name
27 set startInstall to "[StartInstallText1]
29 [StartInstallText2]"
30 set IdentifyQ to "[IdentifyQText]
32 [IdentifyQText2]"
33 set IdentifyYES to "[IdentifyYES]"
34 set IdentifyNO to "[IdentifyNO]"
35 set installFailed to "[InstallFailedText]"
36 set installComplete to "[InstallCompleteText]
38 [InstallCompleteText2]"
40 set sourcedir to (do shell script "dirname " & quoted form of POSIX path of (path to of me))
42 display dialog intro buttons {AbortLabel, InstallLabel} default button 2
44 if (button returned of result) is AbortLabel then
45 return 2
46 end if
48 set the found_ooos to (do shell script "mdfind \"kMDItemContentType == 'com.apple.application-bundle' && kMDItemDisplayName == '[PRODUCTNAME]*' && kMDItemDisplayName != '[FULLPRODUCTNAME].app'\"") & "
49 " & chooseMyOwn
51 -- the choice returned is of type "list"
52 -- Show selection dialog only if more than one or no product was found
53 if (get first paragraph of found_ooos) is "" then
54 set the choice to (choose from list of paragraphs in found_ooos default items (get last paragraph of found_ooos) with prompt listPrompt OK button name listOKLabel cancel button name listCancelLabel)
55 if choice is false then
56 -- do nothing, the user cancelled the installation
57 return 2 --aborted by user
58 else if (choice as string) is chooseMyOwn then
59 -- yeah, one needs to use "choose file", otherwise
60 -- the user would not be able to select the .app
61 set the choice to POSIX path of (choose file with prompt chooseManual of type "com.apple.application-bundle" without showing package contents and invisibles)
62 end if
63 else if (get second paragraph of found_ooos) is chooseMyOwn then
64 -- set choice to found installation
65 set the choice to (get first paragraph of found_ooos)
66 else
67 set the choice to (choose from list of paragraphs in found_ooos default items (get first paragraph of found_ooos) with prompt listPrompt OK button name listOKLabel cancel button name listCancelLabel)
68 if choice is false then
69 -- do nothing, the user cancelled the installation
70 return 2 --aborted by user
71 else if (choice as string) is chooseMyOwn then
72 -- yeah, one needs to use "choose file", otherwise
73 -- the user would not be able to select the .app
74 set the choice to POSIX path of (choose file with prompt chooseManual of type "com.apple.application-bundle" without showing package contents and invisibles)
75 end if
76 end if
78 -- now only check whether the path is really from [PRODUCTNAME]
79 try
80 do shell script "grep '<string>[PRODUCTNAME] [PRODUCTVERSION]' " & quoted form of (choice as string) & "/Contents/Info.plist"
81 on error
82 display dialog (choice as string) & appInvalid buttons {InstallLabel} default button 1 with icon 0
83 return 3 --wrong target-directory
84 end try
87 display dialog startInstall buttons {AbortLabel, InstallLabel} default button 2
89 if (button returned of result) is AbortLabel then
90 return 2
91 end if
94 set tarCommand to "/usr/bin/tar -C " & quoted form of (choice as string) & " -xjf " & quoted form of sourcedir & "/tarball.tar.bz2"
95 try
96 do shell script tarCommand
98 on error errMSG number errNUM
99 display dialog IdentifyQ buttons {IdentifyYES, IdentifyNO} with icon 2
100 if (button returned of result) is IdentifyYES then
102 do shell script tarCommand with administrator privileges
103 on error errMSG number errNUM
104 display dialog installFailed buttons {OKLabel} default button 1 with icon 0
105 -- -60005 username/password wrong
106 -- -128 aborted by user
107 -- 2 error from tar - tarball not found (easy to test)
108 return errNUM
109 end try
110 else
111 return 2 -- aborted by user
112 end if
113 end try
115 display dialog installComplete buttons {OKLabel} default button 1