; Script generated by the HM NIS Edit Script Wizard. ; HM NIS Edit Wizard helper defines !define PRODUCT_NAME "hpgs" !define PRODUCT_MAJOR_MINOR "@MVERSION@" !define PRODUCT_VERSION "@VERSION@" !define PRODUCT_PUBLISHER "ev-i Informationstechnologie GmbH" !define PRODUCT_WEB_SITE "http://hpgs.berlios.de" !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\hpgs.exe" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" !define PRODUCT_UNINST_ROOT_KEY "HKLM" !define PRODUCT_PATH_REGKEY "Software\ev-i\hpgs" !define DOC_DIR "/usr/share/doc/hpgs-doc" !define MINGW_LOCAL_DIR "@prefix@" ; MUI 1.67 compatible ------ !include "MUI.nsh" ; 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 ; License page !insertmacro MUI_PAGE_LICENSE "${DOC_DIR}\LICENSE" ; Directory page !insertmacro MUI_PAGE_DIRECTORY ; Instfiles page !insertmacro MUI_PAGE_INSTFILES ; Finish page !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\doc\html\index.html" !insertmacro MUI_PAGE_FINISH ; Uninstaller pages !insertmacro MUI_UNPAGE_INSTFILES ; Language files !insertmacro MUI_LANGUAGE "English" !insertmacro MUI_LANGUAGE "German" ; MUI end ------ ;---------------------------------------- ; based upon a script of "Written by KiCHiK 2003-01-18 05:57:02" ;---------------------------------------- !verbose 3 !include "WinMessages.NSH" !verbose 4 ;==================================================== ; get_NT_environment ; Returns: the selected environment ; Output : head of the stack ;==================================================== !macro select_NT_profile UN Function ${UN}select_NT_profile MessageBox MB_YESNO|MB_ICONQUESTION "Change the environment for all users?$\r$\nSaying no here will change the envrironment for the current user only.$\r$\n(Administrator permissions required for all users)" \ IDNO environment_single DetailPrint "Selected environment for all users" Push "all" Return environment_single: DetailPrint "Selected environment for current user only." Push "current" Return FunctionEnd !macroend !insertmacro select_NT_profile "" !insertmacro select_NT_profile "un." ;---------------------------------------------------- !define NT_current_env 'HKCU "Environment"' !define NT_all_env 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' ;==================================================== ; IsNT - Returns 1 if the current system is NT, 0 ; otherwise. ; Output: head of the stack ;==================================================== !macro IsNT UN Function ${UN}IsNT Push $0 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion StrCmp $0 "" 0 IsNT_yes ; we are not NT. Pop $0 Push 0 Return IsNT_yes: ; NT!!! Pop $0 Push 1 FunctionEnd !macroend !insertmacro IsNT "" !insertmacro IsNT "un." ;==================================================== ; AddToPath - Adds the given dir to the search path. ; Input - head of the stack ; Note - Win9x systems requires reboot ;==================================================== Function AddToPath Exch $0 Push $1 Push $2 Call IsNT Pop $1 StrCmp $1 1 AddToPath_NT ; Not on NT StrCpy $1 $WINDIR 2 FileOpen $1 "$1\autoexec.bat" a FileSeek $1 0 END GetFullPathName /SHORT $0 $0 FileWrite $1 "$\r$\nSET PATH=%PATH%;$0$\r$\n" FileClose $1 Goto AddToPath_done AddToPath_NT: Push $4 Call select_NT_profile Pop $4 AddToPath_NT_selection_done: StrCmp $4 "current" read_path_NT_current ReadRegStr $1 ${NT_all_env} "PATH" Goto read_path_NT_resume read_path_NT_current: ReadRegStr $1 ${NT_current_env} "PATH" read_path_NT_resume: StrCpy $2 $0 StrCmp $1 "" AddToPath_NTdoIt StrCpy $2 "$1;$0" AddToPath_NTdoIt: StrCmp $4 "current" write_path_NT_current ClearErrors WriteRegExpandStr ${NT_all_env} "PATH" $2 IfErrors 0 write_path_NT_resume MessageBox MB_YESNO|MB_ICONQUESTION "The path could not be set for all users$\r$\nShould I try for the current user?" \ IDNO write_path_NT_failed ; change selection StrCpy $4 "current" Goto AddToPath_NT_selection_done write_path_NT_current: ClearErrors WriteRegExpandStr ${NT_current_env} "PATH" $2 IfErrors 0 write_path_NT_resume MessageBox MB_OK|MB_ICONINFORMATION "The path could not be set for the current user." Goto write_path_NT_failed write_path_NT_resume: SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 DetailPrint "added path for user ($4), $0" write_path_NT_failed: Pop $4 AddToPath_done: Pop $2 Pop $1 Pop $0 FunctionEnd ;==================================================== ; RemoveFromPath - Remove a given dir from the path ; Input: head of the stack ;==================================================== Function un.RemoveFromPath Exch $0 Push $1 Push $2 Push $3 Push $4 Call un.IsNT Pop $1 StrCmp $1 1 unRemoveFromPath_NT ; Not on NT StrCpy $1 $WINDIR 2 FileOpen $1 "$1\autoexec.bat" r GetTempFileName $4 FileOpen $2 $4 w GetFullPathName /SHORT $0 $0 StrCpy $0 "SET PATH=%PATH%;$0" SetRebootFlag true Goto unRemoveFromPath_dosLoop unRemoveFromPath_dosLoop: FileRead $1 $3 StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoop StrCmp $3 "$0$\n" unRemoveFromPath_dosLoop StrCmp $3 "$0" unRemoveFromPath_dosLoop StrCmp $3 "" unRemoveFromPath_dosLoopEnd FileWrite $2 $3 Goto unRemoveFromPath_dosLoop unRemoveFromPath_dosLoopEnd: FileClose $2 FileClose $1 StrCpy $1 $WINDIR 2 Delete "$1\autoexec.bat" CopyFiles /SILENT $4 "$1\autoexec.bat" Delete $4 Goto unRemoveFromPath_done unRemoveFromPath_NT: StrLen $2 $0 Call un.select_NT_profile Pop $4 StrCmp $4 "current" un_read_path_NT_current ReadRegStr $1 ${NT_all_env} "PATH" Goto un_read_path_NT_resume un_read_path_NT_current: ReadRegStr $1 ${NT_current_env} "PATH" un_read_path_NT_resume: Push $1 Push $0 Call un.StrStr ; Find $0 in $1 Pop $0 ; pos of our dir IntCmp $0 -1 unRemoveFromPath_done ; else, it is in path StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';') IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon. StrLen $0 $1 StrCpy $1 $1 $0 $2 StrCpy $3 "$3$1" StrCmp $4 "current" un_write_path_NT_current WriteRegExpandStr ${NT_all_env} "PATH" $3 Goto un_write_path_NT_resume un_write_path_NT_current: WriteRegExpandStr ${NT_current_env} "PATH" $3 un_write_path_NT_resume: SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 unRemoveFromPath_done: Pop $4 Pop $3 Pop $2 Pop $1 Pop $0 FunctionEnd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Uninstall sutff ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;==================================================== ; StrStr - Finds a given string in another given string. ; Returns -1 if not found and the pos if found. ; Input: head of the stack - string to find ; second in the stack - string to find in ; Output: head of the stack ;==================================================== Function un.StrStr Push $0 Exch Pop $0 ; $0 now have the string to find Push $1 Exch 2 Pop $1 ; $1 now have the string to find in Exch Push $2 Push $3 Push $4 Push $5 StrCpy $2 -1 StrLen $3 $0 StrLen $4 $1 IntOp $4 $4 - $3 unStrStr_loop: IntOp $2 $2 + 1 IntCmp $2 $4 0 0 unStrStrReturn_notFound StrCpy $5 $1 $3 $2 StrCmp $5 $0 unStrStr_done unStrStr_loop unStrStrReturn_notFound: StrCpy $2 -1 unStrStr_done: Pop $5 Pop $4 Pop $3 Exch $2 Exch 2 Pop $0 Pop $1 FunctionEnd ;==================================================== Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" OutFile "hpgs-${PRODUCT_VERSION}-setup-@NSIS_ARCH@.exe" InstallDir "$@NSIS_PROGRAMFILES@\hpgs" InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" "" ShowInstDetails show ShowUnInstDetails show Function .onInit !insertmacro MUI_LANGDLL_DISPLAY FunctionEnd Section "MainSection" SEC01 SetOutPath "$INSTDIR\bin" SetOverwrite ifnewer File "${MINGW_LOCAL_DIR}\bin\hpgs${PRODUCT_MAJOR_MINOR}.dll" File "${MINGW_LOCAL_DIR}\bin\hpgs.${PRODUCT_VERSION}.dll" File "${MINGW_LOCAL_DIR}\bin\zlib1.dll" File "${MINGW_LOCAL_DIR}\bin\libpng12-0.dll" File "${MINGW_LOCAL_DIR}\bin\libiconv-2.dll" File "${MINGW_LOCAL_DIR}\bin\libintl-8.dll" File "${MINGW_LOCAL_DIR}\bin\hpgs.exe" SetOutPath "$INSTDIR\share\locale\de\LC_MESSAGES" File "${MINGW_LOCAL_DIR}\share\locale\de\LC_MESSAGES\hpgs.mo" SetOutPath "$INSTDIR\include" File "${MINGW_LOCAL_DIR}\include\hpgs.h" File "${MINGW_LOCAL_DIR}\include\hpgsmutex.h" File "${MINGW_LOCAL_DIR}\include\hpgsplugin.h" SetOutPath "$INSTDIR\lib" File "${MINGW_LOCAL_DIR}\lib\libhpgs.dll.a" SetOutPath "$INSTDIR\doc" File "${DOC_DIR}\README" File "${DOC_DIR}\INSTALL.gz" File "${DOC_DIR}\LICENSE" File "${DOC_DIR}\TODO" File /r "${DOC_DIR}\html" File /r "${DOC_DIR}\images" File /r "${DOC_DIR}\latex" Push "$INSTDIR\bin" Call AddToPath SectionEnd Section -AdditionalIcons SetOutPath $INSTDIR WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}" CreateDirectory "$SMPROGRAMS\hpgs" CreateShortCut "$SMPROGRAMS\hpgs\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url" CreateShortCut "$SMPROGRAMS\hpgs\Uninstall.lnk" "$INSTDIR\uninst.exe" SectionEnd Section -Post WriteUninstaller "$INSTDIR\uninst.exe" WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\bin\hpgs.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\hpgs.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}" WriteRegStr HKLM "${PRODUCT_PATH_REGKEY}" "prefix" "$INSTDIR" 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 Push "$INSTDIR\bin" Call un.RemoveFromPath Delete "$INSTDIR\${PRODUCT_NAME}.url" Delete "$INSTDIR\uninst.exe" Delete "$INSTDIR\share\locale\de\LC_MESSAGES\hpgs.mo" Delete "$INSTDIR\bin\hpgs.exe" Delete "$INSTDIR\bin\hpgs.${PRODUCT_VERSION}.dll" Delete "$INSTDIR\bin\hpgs${PRODUCT_MAJOR_MINOR}.dll" Delete "$INSTDIR\bin\zlib1.dll" Delete "$INSTDIR\bin\libpng12-0.dll" Delete "$INSTDIR\bin\libiconv-2.dll" Delete "$INSTDIR\bin\libintl-8.dll" Delete "$INSTDIR\lib\libhpgs.dll.a" Delete "$INSTDIR\include\hpgs.h" Delete "$INSTDIR\include\hpgsmutex.h" Delete "$INSTDIR\include\hpgsplugin.h" Delete "$SMPROGRAMS\hpgs\Uninstall.lnk" Delete "$SMPROGRAMS\hpgs\Website.lnk" RMDir "$SMPROGRAMS\hpgs" RMDir "$INSTDIR\share\locale\de\LC_MESSAGES" RMDir "$INSTDIR\share\locale\de" RMDir "$INSTDIR\share\locale" RMDir "$INSTDIR\share" RMDir "$INSTDIR\bin" RMDir "$INSTDIR\include" RMDir "$INSTDIR\lib" RMDir /R "$INSTDIR\doc" RMDir "$INSTDIR" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}" DeleteRegKey HKLM "${PRODUCT_PATH_REGKEY}" SetAutoClose true SectionEnd