; ERP5Setp.nsi ; Setup Wizard for ERP5 ; The Webshortcut to access ERP5 !define ERP5_URL_NAME "ERP5.url" !define ERP5_URL "http://127.0.0.1:8080/erp5" ; HM NIS Edit Wizard helper defines !define PRODUCT_NAME "ERP5" !define PRODUCT_VERSION "" !define PRODUCT_PUBLISHER "Nexedi" !define PRODUCT_WEB_SITE "http://www.erp5.org" !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\${PRODUCT_NAME}" !define PRODUCT_DIR_ROOT_REGKEY "HKLM" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" !define PRODUCT_UNINST_ROOT_KEY "HKLM" !define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir" SetCompress off ;SetCompressor /SOLID lzma ;SetCompressorDictSize 32 ; MUI 1.67 compatible ------ !include "MUI.nsh" ; MUI Settings !define MUI_ABORTWARNING !define MUI_ICON "..\Doc\img\install.ico" !define MUI_UNICON "..\Doc\img\uninstall.ico" ; Language Selection Dialog Settings !define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}" !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}" !define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language" ; Welcome page !insertmacro MUI_PAGE_WELCOME ; License page !insertmacro MUI_PAGE_LICENSE "..\License.txt" ; Directory page !insertmacro MUI_PAGE_DIRECTORY ; Instfiles page !insertmacro MUI_PAGE_INSTFILES ; Finish page ;!define MUI_FINISHPAGE_RUN "$INSTDIR\${ERP5_URL_NAME}" ;!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\Doc\index.htm" ;!define MUI_FINISHPAGE_NOAUTOCLOSE ;!insertmacro MUI_PAGE_FINISH ; Uninstaller pages !insertmacro MUI_UNPAGE_INSTFILES ; Language files !insertmacro MUI_LANGUAGE "English" !insertmacro MUI_LANGUAGE "French" !insertmacro MUI_LANGUAGE "German" !insertmacro MUI_LANGUAGE "Japanese" ; Reserve files !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS ; MUI end ------ Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" OutFile "ERP5Setup.exe" InstallDir "$PROGRAMFILES\ERP5" InstallDirRegKey ${PRODUCT_DIR_ROOT_REGKEY} "${PRODUCT_DIR_REGKEY}" "" ShowInstDetails hide ShowUnInstDetails hide Function .onInit !insertmacro MUI_LANGDLL_DISPLAY FunctionEnd Section "MainSection" SEC01 SetOverwrite ifnewer ; Add all Files but *.pyc and .svn in specified subdirectories recursivley SetOutPath "$INSTDIR\Doc" File /r ..\Doc\*.* SetOutPath "$INSTDIR\external" File /r ..\external\*.* SetOutPath "$INSTDIR\Install" File /r ..\Install\*.* SetOutPath "$INSTDIR\mysql" File /r /x data ..\mysql\*.* SetOutPath "$INSTDIR\mysql\data\mysql" File /r ..\mysql\data\mysql\*.* SetOutPath "$INSTDIR\oood" File /r /x tmp /x var /x .svn /x *.pyc ..\oood\*.* CreateDirectory "$INSTDIR\oood\tmp" CreateDirectory "$INSTDIR\oood\var" SetOutPath "$INSTDIR\python" File /r /x *.pyc ..\python\*.* SetOutPath "$INSTDIR\Zope" File /r /x *.pyc ..\Zope\*.* SetOutPath "$INSTDIR\Firefox" File /r ..\Firefox\*.* # Make the directory "$INSTDIR\Firefox" read write accessible by all users AccessControl::GrantOnFile \ "$INSTDIR\Firefox" "(BU)" "GenericRead + GenericWrite" SetOutPath "$INSTDIR" File ..\LICENSE.txt ; Shortcuts CreateDirectory "$SMPROGRAMS\ERP5" CreateShortCut "$SMPROGRAMS\ERP5\ERP5.lnk" "$INSTDIR\Firefox\firefox.exe" "${ERP5_URL}" "$INSTDIR\Doc\img\erp5_logo.ico" CreateShortCut "$DESKTOP\ERP5.lnk" "$INSTDIR\Firefox\firefox.exe" "${ERP5_URL}" "$INSTDIR\Doc\img\erp5_logo.ico" SectionEnd Section -AdditionalIcons WriteIniStr "$INSTDIR\ERP5Website.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}" CreateShortCut "$SMPROGRAMS\ERP5\ERP5Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url" CreateShortCut "$SMPROGRAMS\ERP5\Setup oood.lnk" "$INSTDIR\Install\ooodSetup.exe" "$INSTDIR\Doc\img\box-install.ico" CreateShortCut "$SMPROGRAMS\ERP5\Uninstall.lnk" "$INSTDIR\uninst.exe" "$INSTDIR\Doc\img\uninstall.ico" SectionEnd Section -Zope ; make ERP5Instance DetailPrint "Building ERP5Instance..." nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\Zope\bin\mkzopeinstance.py" -d "$INSTDIR\ERP5Instance" -u zope:zope"' SectionEnd Section -ERP5Instance SetOutPath $INSTDIR\ERP5Instance\bt5 File /r ..\ERP5Instance\bt5\*.* SetOutPath $INSTDIR\ERP5Instance\Products File /r /x .svn /x *.pyc ..\ERP5Instance\Products\*.* SetOutPath $INSTDIR\ERP5Instance\Extensions File /r /x *.pyc ..\ERP5Instance\Extensions\*.* CreateDirectory "$INSTDIR\ERP5Instance\Constraint" CreateDirectory "$INSTDIR\ERP5Instance\Dokument" CreateDirectory "$INSTDIR\ERP5Instance\PropertySheet" CreateDirectory "$INSTDIR\ERP5Instance\svn" CreateDirectory "$INSTDIR\ERP5Instance\tests" CreateDirectory "$INSTDIR\ERP5Instance\unit_test" SectionEnd Section -updateRegistry WriteUninstaller "$INSTDIR\uninst.exe" WriteRegStr ${PRODUCT_DIR_ROOT_REGKEY} "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\Doc\img\erp5_logo.ico" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" SectionEnd Section -configure_oood DetailPrint "Configuring oood" WriteINIStr "$INSTDIR\oood\oood.conf" "System" "oood_home" "$INSTDIR\oood" WriteINIStr "$INSTDIR\oood\oood.conf" "System" "run_dir" "$INSTDIR\oood\var" WriteINIStr "$INSTDIR\oood\oood.conf" "System" "log_file" "$INSTDIR\oood\var\oood.log" Exec "$INSTDIR\Install\ooodSetup.exe" SectionEnd Section -ERP5MySQL ; copy my.ini to $INSTDIR\mysql\my.ini - try to overwrite it if it already exist SetOutPath $INSTDIR\mysql SetOverwrite off File ..\Install\my.ini ; adapt my.ini to the installation path DetailPrint "Modifying $INSTDIR\mysql\my.ini" WriteINIStr "$INSTDIR\mysql\my.ini" "mysqld" "basedir" "$INSTDIR\mysql" WriteINIStr "$INSTDIR\mysql\my.ini" "mysqld" "datadir" "$INSTDIR\mysql\data" WriteINIStr "$INSTDIR\mysql\my.ini" "WinMySQLadmin" "Server" "$INSTDIR\mysql\bin\mysqld-nt.exe" ; Register and start ERP5MySQL Service DetailPrint "Registering ERP5MySQL Service..." nsExec::ExecToLog '"$INSTDIR\mysql\bin\mysqld-nt.exe" --install ERP5MySQL --defaults-file="$INSTDIR\mysql\my.ini"' DetailPrint "Starting ERP5MySQL Service..." nsExec::ExecToLog "net start ERP5MySQL" SectionEnd Section -ERP5Service ; Register and start Zope (a.k. ERP5) Service SetOutPath $INSTDIR DetailPrint "Registering ERP5 Service..." nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\ERP5Instance\bin\zopeservice.py" --startup auto install' DetailPrint "Starting ERP5 Service..." nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\ERP5Instance\bin\zopeservice.py" start' SectionEnd Section -CreateDatabasesAndERP5Site ; create set privileges for mysql and create databases DetailPrint "Creating databases..." nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\Install\createdb.py"' ; create ERP5Site using Client.py DetailPrint "Creating ERP5Site. This may take some minutes..." nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\Install\waitForZope.py"' nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\Zope\lib\python\ZPublisher\Client.py" -u zope:zope http://127.0.0.1:8080/manage_addProduct/ERP5/manage_addERP5Site id="erp5" title="ERP5" create_userfolder=1 erp5_catalog_storage="erp5_mysql_innodb_catalog" erp5_sql_connection_string="erp5 erp5 erp5" erp5_sql_deferred_connection_string="erp5 erp5 erp5" cmf_activity_sql_connection_string="cmf_activity erp5 erp5"' Exec '"$INSTDIR\Firefox\firefox.exe" "$INSTDIR\Doc\index.htm"' SectionEnd Function un.onUninstSuccess HideWindow MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." FunctionEnd Function un.onInit !insertmacro MUI_UNGETLANGUAGE MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2 Abort FunctionEnd Section Uninstall ; stop and remove the Zope Service (called ERP5) nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\ERP5Instance\bin\zopeservice.py" stop' nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\ERP5Instance\bin\zopeservice.py" remove' ; stop an remove the oood Service ReadRegStr $0 HKLM "Software\OpenOffice.org\UNO\InstallPath" "OpenOffice.org 2.0" nsExec::ExecToLog '"$0\python-core-2.3.4\bin\python.exe" "$INSTDIR\oood\winservice.py" stop' nsExec::ExecToLog '"$0\python-core-2.3.4\bin\python.exe" "$INSTDIR\oood\winservice.py" remove' ; stop and remove the ERP5MySQL Service nsExec::ExecToLog "net stop ERP5MySQL" nsExec::ExecToLog '"$INSTDIR\mysql\bin\mysqld-nt.exe" --remove ERP5MySQL' Delete "$INSTDIR\ERP5Website.url" Delete "$INSTDIR\${ERP5_URL_NAME}" Delete "$INSTDIR\uninst.exe" Delete "$INSTDIR\Example.file" Delete "$SMPROGRAMS\ERP5\Uninstall.lnk" Delete "$SMPROGRAMS\ERP5\Setup oood.lnk" Delete "$SMPROGRAMS\ERP5\ERP5Website.lnk" Delete "$DESKTOP\ERP5.lnk" Delete "$SMPROGRAMS\ERP5\ERP5.lnk" RMDir "$SMPROGRAMS\ERP5" RMDir /r /REBOOTOK "$INSTDIR" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" DeleteRegKey ${PRODUCT_DIR_ROOT_REGKEY} "${PRODUCT_DIR_REGKEY}" SetAutoClose true SectionEnd Function WriteToFileLine2 Exch $0 ;file Exch Exch $1 ;line number Exch 2 Exch $2 ;string to write Exch 2 Push $3 Push $4 Push $5 Push $6 Push $7 GetTempFileName $7 FileOpen $4 $0 r FileOpen $5 $7 w StrCpy $3 0 Loop: ClearErrors FileRead $4 $6 IfErrors Exit IntOp $3 $3 + 1 StrCmp $3 $1 0 +3 FileWrite $5 "$2$\r$\n" Goto Loop FileWrite $5 $6 Goto Loop Exit: FileClose $5 FileClose $4 SetDetailsPrint none Delete $0 Rename $7 $0 SetDetailsPrint both Pop $7 Pop $6 Pop $5 Pop $4 Pop $3 Pop $2 Pop $1 Pop $0 FunctionEnd