; ooodSetup.nsi !include "Sections.nsh" ;SetCompress off SetCompressor /SOLID lzma ; MUI 1.67 compatible ------ !include "MUI.nsh" ; MUI Settings !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" ; Directory page !define MUI_PAGE_HEADER_TEXT "OpenOffice Location" !define MUI_PAGE_HEADER_SUBTEXT "Choose the folder of your OpenOffice installation" !define MUI_PAGE_CUSTOMFUNCTION_LEAVE leaveDir !insertmacro MUI_PAGE_DIRECTORY ; Instfiles page !define MUI_PAGE_HEADER_SUBTEXT "Please wait while setting up oood" !insertmacro MUI_PAGE_INSTFILES ; Uninstaller pages ;!insertmacro MUI_UNPAGE_INSTFILES ; Language files !insertmacro MUI_LANGUAGE "English" ; Reserve files !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS ; MUI end ------ Name "oood" OutFile "..\Install\ooodSetup.exe" ; The default installation directory InstallDir "$PROGRAMFILES\OpenOffice.org 2.0" ; The text to prompt the user to enter a directory DirText "OpenOffice.org-2.0.3 is needed for oood. Oood will be configured to \ use the OpenOffice.org installation specified in the 'Destination folder' field. \ If OpenOffice.org is already installed on your system, \ the path is normally detected automatically. You can change the path to point to another \ OpenOffice.org Installation. If OpenOffice.org isn't installed on your system you can \ specify the folder where OpenOffice.org should be installed to. Then OpenOffice will be \ downloaded and installed automatically." "" "" \ "Choose the folder of your OpenOffice.org installation" InstallButtonText "OK" ; automatically close the installer when done. AutoCloseWindow true ShowInstDetails hide Section openOffice AddSize 485750 ReadRegStr $3 HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\ERP5" "" IfFileExists "$3\Install\OpenOfficeInstall.exe" haveFile Call MakeSureIGotOpenOffice haveFile: ExecWait '"$3\Install\OpenOfficeInstall.exe" /D=$INSTDIR' SectionEnd Section site-packages SetOutPath $INSTDIR\program File /r /x *.pyc ..\program\*.* SectionEnd Section configure_oood DetailPrint "Applying openoffice.org-2.0.3-skip-registration.patch..." ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\ERP5" "" nsExec::ExecToLog '"$0\external\patch.exe" -tNi "$0\Install\openoffice.org-2.0.3-skip-registration.patch" "$INSTDIR\share\registry\data\org\openoffice\Setup.xcu"' DetailPrint "Configuring oood" WriteINIStr "$0\oood\oood.conf" "System" "uno_path" "$INSTDIR\program" DetailPrint "Registering oood Service..." nsExec::ExecToLog '"$INSTDIR\program\python-core-2.3.4\bin\python.exe" "$0\oood\winservice.py" --startup auto install' DetailPrint "Starting oood Service..." nsExec::ExecToLog '"$INSTDIR\program\python-core-2.3.4\bin\python.exe" "$0\oood\winservice.py" start' SectionEnd ;-------------------------------- Function .onInit Call GetOpenOfficeInstPath Pop $0 StrCmp $0 "" skip StrCpy $INSTDIR $0 !insertmacro UnselectSection openOffice skip: FunctionEnd Function .onVerifyInstDir ;Check for OpenOffice installation IfFileExists $INSTDIR\program\python-core-2.3.4\bin\python.exe Good !insertmacro SelectSection openOffice Goto fin Good: !insertmacro UnselectSection openOffice fin: FunctionEnd Function leaveDir IfFileExists $INSTDIR\program\python-core-2.3.4\bin\python.exe Good MessageBox MB_OKCANCEL|MB_ICONINFORMATION "OpenOffice.org-2.0.3 could not be found. \ OpenOffice.org can be downloaded (ca. 100MB) and installed automatically. \ It will be installed to '$INSTDIR'. Press 'Cancel' if you want to change the destination \ folder or cancel the installation process. Press 'OK' to download and install \ OpenOffice.org now." IDOK Good Abort Good: FunctionEnd Function GetOpenOfficeInstPath Push $0 Push $1 Push $2 ReadRegStr $0 HKLM "Software\OpenOffice.org\UNO\InstallPath" "OpenOffice.org 2.0" IfFileExists $0\python-core-2.3.4\bin\python.exe continue StrCpy $0 "" continue: StrCmp $0 "" fin StrCpy $1 $0 1 0 ; get firstchar StrCmp $1 '"' "" getparent ; if first char is ", let's remove "'s first. StrCpy $0 $0 "" 1 StrCpy $1 0 rqloop: StrCpy $2 $0 1 $1 StrCmp $2 '"' rqdone StrCmp $2 "" rqdone IntOp $1 $1 + 1 Goto rqloop rqdone: StrCpy $0 $0 $1 getparent: ; the uninstall string goes to an EXE, let's get the directory. StrCpy $1 -1 gploop: StrCpy $2 $0 1 $1 StrCmp $2 "" gpexit StrCmp $2 "\" gpexit IntOp $1 $1 - 1 Goto gploop gpexit: StrCpy $0 $0 $1 StrCmp $0 "" fin IfFileExists $0\program\python-core-2.3.4\bin\python.exe fin StrCpy $0 "" fin: Pop $2 Pop $1 Exch $0 FunctionEnd Function MakeSureIGotOpenOffice Call GetOpenOfficeInstPath Pop $0 StrCmp $0 "" getOpenOffice Return getOpenOffice: Call ConnectInternet ;Make an internet connection (if no connection available) StrCpy $2 "$3\Install\OpenOfficeInstall.exe" NSISdl::download http://nexedi.org/static/OpenOfficeInstall.exe $2 Pop $0 StrCmp $0 success success MessageBox MB_OK|MB_ICONSTOP "download failed: $0" Abort success: FunctionEnd Function ConnectInternet Push $R0 ClearErrors Dialer::AttemptConnect IfErrors noie3 Pop $R0 StrCmp $R0 "online" connected MessageBox MB_OK|MB_ICONSTOP "Cannot connect to the internet." Quit noie3: ; IE3 not installed MessageBox MB_OK|MB_ICONINFORMATION "Please connect to the internet now." connected: Pop $R0 FunctionEnd