(* This script is meant to 1) Identify installed instances of the product 2) check whether the user has write-access (and if not ask for authentification) 3) install the shipped tarball *) -- strings for localisations - to be meant to be replaced -- by a makefile or similar set OKLabel to "OK" set InstallLabel to "Installer" set AbortLabel to "Abandonner" set intro to "Bienvenue dans l'assistant d'installation de LibreOffice 3.3 Language Pack Cette installation va mettre à jour vos versions installées de LibreOffice Cela peut prendre un moment." set chooseMyOwn to "Non listé (choisissez l'emplacement lors d'une étape supplémentaire)" set listPrompt to "Choisissez l'installation LibreOffice 3.3 pour laquelle vous voulez installer LibreOffice 3.3 Language Pack" set chooseManual to "Pointez la boîte de dialogue vers l'installation LibreOffice 3.3." set listOKLabel to "Installer" set listCancelLabel to "Abandonner" set appInvalid to "Ce n'est pas une installation valide de LibreOffice 3.3. Exécutez de nouveau l'installeur et choisissez une version valide de 3.3 LibreOffice" -- string will begin with the chosen application's name set startInstall to "Cliquez sur Installer pour démarrer l'installation L'installation prendra une minute..." set IdentifyQ to "L'installation a échoué, très certainement parce que votre compte n'a pas les privilèges nécessaires. Souhaitez-vous vous identifier comme administrateur et essayer de nouveau ?" set IdentifyYES to "Oui, s'identifier" set IdentifyNO to "Non, abandonner l'installation" set installFailed to "L'installation a échoué." set installComplete to "Installation du pack de langue LibreOffice terminée. Appelez 'LibreOffice'-Préférences-Paramètres linguistiques-Langues' pour modifier la langue de l'interface utilisateur." set sourcedir to (do shell script "dirname " & quoted form of POSIX path of (path to of me)) activate display dialog intro buttons {AbortLabel, InstallLabel} default button 2 if (button returned of result) is AbortLabel then return 2 end if set the found_ooos to (do shell script "mdfind \"kMDItemContentType == 'com.apple.application-bundle' && kMDItemDisplayName == 'LibreOffice*' && kMDItemDisplayName != 'LibreOffice 3.3 Language Pack.app'\"") & " " & chooseMyOwn -- the choice returned is of type "list" -- Show selection dialog only if more than one or no product was found if (get first paragraph of found_ooos) is "" then 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) if choice is false then -- do nothing, the user cancelled the installation return 2 --aborted by user else if (choice as string) is chooseMyOwn then -- yeah, one needs to use "choose file", otherwise -- the user would not be able to select the .app set the choice to POSIX path of (choose file with prompt chooseManual of type "com.apple.application-bundle" without showing package contents and invisibles) end if else if (get second paragraph of found_ooos) is chooseMyOwn then -- set choice to found installation set the choice to (get first paragraph of found_ooos) else 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) if choice is false then -- do nothing, the user cancelled the installation return 2 --aborted by user else if (choice as string) is chooseMyOwn then -- yeah, one needs to use "choose file", otherwise -- the user would not be able to select the .app set the choice to POSIX path of (choose file with prompt chooseManual of type "com.apple.application-bundle" without showing package contents and invisibles) end if end if -- now only check whether the path is really from LibreOffice try do shell script "grep 'LibreOffice 3.3' " & quoted form of (choice as string) & "/Contents/Info.plist" on error display dialog (choice as string) & appInvalid buttons {InstallLabel} default button 1 with icon 0 return 3 --wrong target-directory end try (* display dialog startInstall buttons {AbortLabel, InstallLabel} default button 2 if (button returned of result) is AbortLabel then return 2 end if *) set tarCommand to "/usr/bin/tar -C " & quoted form of (choice as string) & " -xjf " & quoted form of sourcedir & "/tarball.tar.bz2" try do shell script tarCommand on error errMSG number errNUM display dialog IdentifyQ buttons {IdentifyYES, IdentifyNO} with icon 2 if (button returned of result) is IdentifyYES then try do shell script tarCommand with administrator privileges on error errMSG number errNUM display dialog installFailed buttons {OKLabel} default button 1 with icon 0 -- -60005 username/password wrong -- -128 aborted by user -- 2 error from tar - tarball not found (easy to test) return errNUM end try else return 2 -- aborted by user end if end try display dialog installComplete buttons {OKLabel} default button 1