Newer
Older
dub_jkp / scripts / win-installer / installer.nsi
  1. SetCompressor /SOLID lzma
  2.  
  3. ;--------------------------------------------------------
  4. ; Defines
  5. ;--------------------------------------------------------
  6.  
  7. ; Options
  8. !ifndef Version
  9. !define /ifndef Version "0.9.21"
  10. !endif
  11. !define DubExecPath "..\..\bin"
  12.  
  13. ;--------------------------------------------------------
  14. ; Includes
  15. ;--------------------------------------------------------
  16.  
  17. !include "MUI.nsh"
  18. !include "EnvVarUpdate.nsh"
  19.  
  20. ;--------------------------------------------------------
  21. ; General definitions
  22. ;--------------------------------------------------------
  23.  
  24. ; Name of the installer
  25. Name "dub Package Manager ${Version}"
  26.  
  27. ; Name of the output file of the installer
  28. OutFile "dub-${Version}-setup.exe"
  29.  
  30. ; Where the program will be installed
  31. InstallDir "$PROGRAMFILES\dub"
  32.  
  33. ; Take the installation directory from the registry, if possible
  34. InstallDirRegKey HKLM "Software\dub" ""
  35.  
  36. ; Prevent installation of a corrupt installer
  37. CRCCheck force
  38.  
  39. RequestExecutionLevel admin
  40.  
  41. ;--------------------------------------------------------
  42. ; Interface settings
  43. ;--------------------------------------------------------
  44.  
  45. ;!define MUI_ICON "installer-icon.ico"
  46. ;!define MUI_UNICON "uninstaller-icon.ico"
  47.  
  48. ;--------------------------------------------------------
  49. ; Installer pages
  50. ;--------------------------------------------------------
  51.  
  52. !define MUI_WELCOMEFINISHPAGE_BITMAP "banner.bmp"
  53. !define MUI_HEADERIMAGE
  54. !define MUI_HEADERIMAGE_BITMAP "header.bmp"
  55. !insertmacro MUI_PAGE_WELCOME
  56. !insertmacro MUI_PAGE_COMPONENTS
  57. !insertmacro MUI_PAGE_DIRECTORY
  58. !insertmacro MUI_PAGE_INSTFILES
  59. !insertmacro MUI_PAGE_FINISH
  60.  
  61. !insertmacro MUI_UNPAGE_WELCOME
  62. !insertmacro MUI_UNPAGE_CONFIRM
  63. !insertmacro MUI_UNPAGE_INSTFILES
  64. !insertmacro MUI_UNPAGE_FINISH
  65.  
  66. ;--------------------------------------------------------
  67. ; The languages
  68. ;--------------------------------------------------------
  69.  
  70. !insertmacro MUI_LANGUAGE "English"
  71.  
  72.  
  73. ;--------------------------------------------------------
  74. ; Required section: main program files,
  75. ; registry entries, etc.
  76. ;--------------------------------------------------------
  77. ;
  78. Section "dub" DubFiles
  79.  
  80. ; This section is mandatory
  81. SectionIn RO
  82.  
  83. SetOutPath $INSTDIR
  84.  
  85. ; Create installation directory
  86. CreateDirectory "$INSTDIR"
  87.  
  88. File "${DubExecPath}\dub.exe"
  89. File "${DubExecPath}\libcurl.dll"
  90. File "${DubExecPath}\libeay32.dll"
  91. File "${DubExecPath}\ssleay32.dll"
  92.  
  93. ; Create command line batch file
  94. FileOpen $0 "$INSTDIR\dubvars.bat" w
  95. FileWrite $0 "@echo.$\n"
  96. FileWrite $0 "@echo Setting up environment for using dub from %~dp0$\n"
  97. FileWrite $0 "@set PATH=%~dp0;%PATH%$\n"
  98. FileClose $0
  99.  
  100. ; Write installation dir in the registry
  101. WriteRegStr HKLM SOFTWARE\dub "Install_Dir" "$INSTDIR"
  102.  
  103. ; Write registry keys to make uninstall from Windows
  104. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\dub" "DisplayName" "dub package manager"
  105. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\dub" "UninstallString" '"$INSTDIR\uninstall.exe"'
  106. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\dub" "NoModify" 1
  107. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\dub" "NoRepair" 1
  108. WriteUninstaller "uninstall.exe"
  109.  
  110. SectionEnd
  111.  
  112. Section "Add to PATH" AddDubToPath
  113.  
  114. ; Add dub directory to path (for all users)
  115. ${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR"
  116.  
  117. SectionEnd
  118.  
  119. Section /o "Start menu shortcuts" StartMenuShortcuts
  120. CreateDirectory "$SMPROGRAMS\DUB"
  121.  
  122. ; install dub command prompt
  123. CreateShortCut "$SMPROGRAMS\DUB\DUB Command Prompt.lnk" '%comspec%' '/k ""$INSTDIR\dubvars.bat""' "" "" SW_SHOWNORMAL "" "Open DUB Command Prompt"
  124.  
  125. CreateShortCut "$SMPROGRAMS\DUB\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  126. SectionEnd
  127.  
  128. ;--------------------------------------------------------
  129. ; Uninstaller
  130. ;--------------------------------------------------------
  131.  
  132. Section "Uninstall"
  133.  
  134. ; Remove directories to path (for all users)
  135. ; (if for the current user, use HKCU)
  136. ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR"
  137.  
  138. ; Remove stuff from registry
  139. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\dub"
  140. DeleteRegKey HKLM SOFTWARE\dub
  141. DeleteRegKey /ifempty HKLM SOFTWARE\dub
  142.  
  143. ; This is for deleting the remembered language of the installation
  144. DeleteRegKey HKCU Software\dub
  145. DeleteRegKey /ifempty HKCU Software\dub
  146.  
  147. ; Remove the uninstaller
  148. Delete $INSTDIR\uninstall.exe
  149.  
  150. ; Remove shortcuts
  151. Delete "$SMPROGRAMS\dub\dub Command Prompt.lnk"
  152.  
  153. ; Remove used directories
  154. RMDir /r /REBOOTOK "$INSTDIR"
  155. RMDir /r /REBOOTOK "$SMPROGRAMS\dub"
  156.  
  157. SectionEnd
  158.