; ; $Id$ ; ; (c)2015 The clazzes.org project. ; ; NSIS Installation Script for the osgi-runner service. ; ; Author: Wolfgang Glas ; ; HM NIS Edit Wizard helper defines !define PRODUCT_NAME "@PROJECT_NAME@" !define PRODUCT_VERSION "@PROJECT_VERSION@" !define PRODUCT_PUBLISHER "The Clazzes.org Project" !define PRODUCT_WEB_SITE "http://www.clazzes.org" !define PRODUCT_PATH_REGKEY "Software\osgi-runner" !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\osgi-runner.exe" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" !define PRODUCT_UNINST_ROOT_KEY "HKLM" !define ARCHITECTURE "@ARCHITECTURE@" !define BINDIR "/usr/@ARCHTRIPLET@/bin" ; Use LZMA compression, because nsis-2.46-1 as of ubuntu lucid fails to compress ; osgi-3.5.1.v20090827.jar, see https://bugs.launchpad.net/bugs/585442 SetCompressor LZMA SetCompressorDictSize 32 SetCompress Auto SetDatablockOptimize On ; MUI 1.67 compatible ------ !include "MUI.nsh" !include "TextFunc.nsh" !include "WordFunc.nsh" !include "Sections.nsh" !insertmacro LineFind !insertmacro WordReplace ; MUI Settings !define MUI_ABORTWARNING !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-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 ; Directory page !insertmacro MUI_PAGE_DIRECTORY ; Instfiles page !insertmacro MUI_PAGE_INSTFILES ; Finish page !insertmacro MUI_PAGE_FINISH ; Uninstaller pages !insertmacro MUI_UNPAGE_INSTFILES ; Language files !insertmacro MUI_LANGUAGE "English" ; MUI end ------ Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" OutFile "${PRODUCT_NAME}-${PRODUCT_VERSION}-setup-${ARCHITECTURE}.exe" InstallDir "$@PROGRAMFILES@\osgi-runner" ShowInstDetails show ShowUnInstDetails show var INSTMODE var JAVA_HOME Function .onInit SetRegView @REGVIEW@ !insertmacro MUI_LANGDLL_DISPLAY ReadRegStr $JAVA_HOME HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\1.8" "JavaHome" IfErrors 0 JRE16Found ReadRegStr $JAVA_HOME HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\1.7" "JavaHome" IfErrors 0 JRE16Found ReadRegStr $JAVA_HOME HKLM "SOFTWARE\JavaSoft\Java Development Kit\1.8" "JavaHome" IfErrors 0 JRE16Found ReadRegStr $JAVA_HOME HKLM "SOFTWARE\JavaSoft\Java Development Kit\1.7" "JavaHome" IfErrors 0 JRE16Found MessageBox MB_OK "Couldn't find a Java Runtime 1.7 or 1.8 installed. Setup will exit now." Quit JRE16Found: ; osgi-runner already installed ? ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" IfErrors fromscratch 0 MessageBox MB_OKCANCEL "There is another version of osgi-runner currently installed. Run Uninstaller $0 now?" IDOK +2 IDCANCEL +1 Abort "Installation aborted by the user." ReadRegStr $INSTDIR HKLM "${PRODUCT_PATH_REGKEY}" "instdir" ExecWait '$0 _?=$INSTDIR' StrCpy $INSTMODE "update" goto goon fromscratch: StrCpy $INSTMODE "install" goon: ; remove some registry keys which interfere badly, when osgi-runner and/or the JRE is updated. ; We do this here after running the uninstaller, so we even erase the regkeys when ; older installers were installed before SetRegView 32 DeleteRegValue HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Java" "Jvm" DeleteRegValue HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Java" "Classpath" DeleteRegValue HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Java" "Options" DeleteRegKey HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Log" DeleteRegKey HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Start" DeleteRegKey HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Stop" SetRegView @REGVIEW@ FunctionEnd Section "OSGi Runner" SEC00 SetOutPath "$INSTDIR" File /oname=osgi-runner.exe "@ARCH_DIST_SUBDIR@prunsrv.exe" File /oname=osgi-runnerw.exe "prunmgr.exe" File "../InstallOsgiService.bat" File "../UninstallOsgiService.bat" SetOutPath "$INSTDIR\lib" File /r "@DIST_DIR@/downloads/lib/*" SetOutPath "$INSTDIR\bundle1" File /r "@DIST_DIR@/downloads/bundle1/*" SetOutPath "$INSTDIR\bundle2" File /r "@DIST_DIR@/downloads/bundle2/*" SetOutPath "$INSTDIR\bundle3" File /r "@DIST_DIR@/downloads/bundle3/*" SetOutPath "$INSTDIR\bundle4" File /r "@DIST_DIR@/downloads/bundle4/*" SetOutPath "$INSTDIR\bundle5" File /r "@DIST_DIR@/downloads/bundle5/*" ; ; TODO Do not overwrite configuration files, which have not been deleted. ; In stall changed config files as *.new and print a remark. ; Possibly write md5 checksums ; SetOutPath "$INSTDIR\etc" !include "./install-config.nsi" SetOutPath "$INSTDIR\log" File "../README" SetOutPath "$INSTDIR\cache" File "../README" SetOutPath "$INSTDIR\var" File "../README" SetOutPath "$INSTDIR\deploy" File "../README" SetOutPath "$INSTDIR\drivers" File "../README-DRIVERS" WriteRegStr HKLM "${PRODUCT_PATH_REGKEY}" "instdir" "$INSTDIR" ExecWait '"$INSTDIR\InstallOsgiService.bat" "$JAVA_HOME"' SectionEnd Section -AdditionalIcons SetOutPath $INSTDIR WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}" CreateShortCut "$SMPROGRAMS\OSGi Runner\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url" CreateShortCut "$SMPROGRAMS\OSGi Runner\Uninstall.lnk" "$INSTDIR\uninst.exe" SectionEnd Section -Post WriteUninstaller "$INSTDIR\uninst.exe" WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\bin\osgi-runner.exe" 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\bin\osgi-runner.exe" 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}" SetAutoClose false SectionEnd Function un.onUninstSuccess ; HideWindow MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." FunctionEnd Function un.onInit SetRegView @REGVIEW@ !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 ExecWait '"$INSTDIR\UninstallOsgiService.bat"' Delete "$INSTDIR\${PRODUCT_NAME}.url" Delete "$INSTDIR\uninst.exe" Delete "$INSTDIR\osgi-runner.exe" Delete "$INSTDIR\osgi-runnerw.exe" Delete "$INSTDIR\InstallOsgiService.bat" Delete "$INSTDIR\UninstallOsgiService.bat" RMDir /r "$INSTDIR\lib" RMDir /r "$INSTDIR\bundle1" RMDir /r "$INSTDIR\bundle2" RMDir /r "$INSTDIR\bundle3" RMDir /r "$INSTDIR\bundle4" RMDir /r "$INSTDIR\bundle5" Delete "$INSTDIR\deploy\README" RMDir "$INSTDIR\deploy" Delete "$INSTDIR\drivers\README-DRIVERS" RMDir "$INSTDIR\drivers" RMDir /r "$INSTDIR\cache" Delete "$INSTDIR\var\README" RMDir "$INSTDIR\var" Delete "$INSTDIR\log\README" Delete "$INSTDIR\log\osgi-runner.*.log" Delete "$INSTDIR\log\stdout.log" Delete "$INSTDIR\log\stderr.log" RMDir "$INSTDIR\log" Delete "$INSTDIR\etc\adm.d\*.new" Delete "$INSTDIR\etc\karaf.d\*.new" Delete "$INSTDIR\etc\conf.d\*.new" ; ; Only delete files, which have not been changed as per MD5 checksum. ; !include "./remove-config.nsi" RMDir "$INSTDIR\etc\karaf.d" RMDir "$INSTDIR\etc\conf.d" RMDir "$INSTDIR\etc\adm.d" RMDir "$INSTDIR\etc" RMDir "$INSTDIR" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}" DeleteRegKey HKLM "${PRODUCT_PATH_REGKEY}" SetRegView 32 DeleteRegValue HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Java" "Jvm" DeleteRegValue HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Java" "Classpath" DeleteRegValue HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Java" "Options" DeleteRegKey HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Log" DeleteRegKey HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Start" DeleteRegKey HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Stop" SetRegView @REGVIEW@ SetAutoClose true SectionEnd