Update ooo320-m1
[ooovba.git] / instsetoo_native / res / osx_langpackinstall.applescript
bloba92314f3ff1af90a95965f25d7dc7b5324c76108
1 (*
2 This script is meant to
3 1) Identify installed instances of OOo
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 "OK"
12 set AbortLabel to "Abort"
13 set intro to "Welcome to the OpenOffice.org Languagepack Installer
15 The next step will try to detect installed versions of OpenOffice.org
16 This might take a moment"
17 set chooseMyOwn to "not listed (choose location in an extra step)"
18 set listPrompt to "Choose the installation for which you want to install the languagepack"
19 set chooseManual to "Point the dialog to your OOo installation"
20 set listOKLabel to "Continue"
21 set listCancelLabel to "Abort installation"
22 set appInvalid to " doesn't look like an OpenOffice.org installation
23 If the chosen application really is OpenOffice.org, please contact the developers. Otherwise just run the installer again and choose a valid OpenOffice.org installation" -- string will begin with the chosen application's name
24 set startInstall to "Click " & OKLabel & " to start the installation
26 (installation might take a minute...)"
27 set IdentifyQ to "Installation failed, most likely your account doesn't have the necessary privileges. Do you want to identify as administrator and try again?"
28 set IdentifyYES to "Yes, identify"
29 set IdentifyNO to "No, abort installation"
30 set installFailed to "Installation failed"
31 set installComplete to "Installation is completed - you should now be able to switch the UI language"
33 set sourcedir to (do shell script "dirname " & quoted form of POSIX path of (path to of me))
35 display dialog intro buttons {AbortLabel, OKLabel} default button 2
37 if (button returned of result) is AbortLabel then
38 return 2
39 end if
41 set the found_ooos to (do shell script "mdfind \"kMDItemContentType == 'com.apple.application-bundle' && kMDItemDisplayName == 'OpenOffice.org*' && kMDItemDisplayName != 'OpenOffice.org Languagepack.app'\"") & "
42 " & chooseMyOwn
44 -- the choice returned is of type "list"
45 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)
47 if choice is false then
48 -- do nothing, the user cancelled the installation
49 return 2 --aborted by user
50 else if (choice as string) is chooseMyOwn then
51 -- yeah, one needs to use "choose file", otherwise
52 -- the user would not be able to select the .app
53 set the choice to POSIX path of (choose file with prompt chooseManual of type "com.apple.application-bundle" without showing package contents and invisibles)
54 end if
56 -- now only check whether the path is really from OOo
58 try
59 do shell script "grep '<string>org.openoffice.script</string>' " & quoted form of (choice as string) & "/Contents/Info.plist"
60 on error
61 display dialog (choice as string) & appInvalid buttons {OKLabel} default button 1 with icon 0
62 return 3 --wrong target-directory
63 end try
65 display dialog startInstall buttons {AbortLabel, OKLabel} default button 2
67 if (button returned of result) is AbortLabel then
68 return 2
69 end if
71 set tarCommand to "/usr/bin/tar -C " & quoted form of (choice as string) & " -xjf " & quoted form of sourcedir & "/tarball.tar.bz2"
72 try
73 do shell script tarCommand
75 on error errMSG number errNUM
76 display dialog IdentifyQ buttons {IdentifyYES, IdentifyNO} with icon 2
77 if (button returned of result) is IdentifyYES then
78 try
79 do shell script tarCommand with administrator privileges
80 on error errMSG number errNUM
81 display dialog installFailed buttons {OKLabel} default button 1 with icon 0
82 -- -60005 username/password wrong
83 -- -128 aborted by user
84 -- 2 error from tar - tarball not found (easy to test)
85 return errNUM
86 end try
87 else
88 return 2 -- aborted by user
89 end if
90 end try
92 display dialog installComplete buttons {OKLabel} default button 1