You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

270 lines
9.7 KiB

  1. ;==============================================================================
  2. ; dupeGuru Installer Script for Windows via NSIS
  3. ;
  4. ; When calling makensis use the following:
  5. ; makensis /DVERSIONMAJOR=x /DVERSIONMINOR=x /DVERSIONPATCH=x /DBITS=x \
  6. ; /DSOURCEPATH=x
  7. ; NOTE:
  8. ; If SOURCEPATH is not set it will default to build (uses subdir based on app).
  9. ;==============================================================================
  10. ; Compression Setting
  11. SetCompressor /SOLID lzma
  12. ; General Headers
  13. !include "FileFunc.nsh"
  14. ;==============================================================================
  15. ; Configuration Defines
  16. ;==============================================================================
  17. ; Environment Defines
  18. !verbose push
  19. !verbose 4
  20. !ifndef VERSIONMAJOR
  21. !echo "VERSIONMAJOR is NOT defined"
  22. !endif
  23. !ifndef VERSIONMINOR
  24. !echo "VERSIONMINOR is NOT defined"
  25. !endif
  26. !ifndef VERSIONPATCH
  27. !echo "VERSIONPATCH is NOT defined"
  28. !endif
  29. !ifndef BITS
  30. !echo "BITS is NOT defined"
  31. !endif
  32. !ifndef SOURCEPATH
  33. !echo "SOURCEPATH is NOT defined"
  34. !define SOURCEPATH "dist"
  35. !endif
  36. !ifndef VERSIONMAJOR | VERSIONMINOR | VERSIONPATCH | BITS | SOURCEPATH
  37. !error "Command line Defines missing use /DDEFINE=VALUE to define before script"
  38. !endif
  39. !verbose pop
  40. ; Application Specific Defines
  41. !define APPNAME "dupeGuru"
  42. !define COMPANYNAME "Hardcoded Software"
  43. !define DESCRIPTION "dupeGuru is a tool to find duplicate files on your computer."
  44. !define APPLICENSE "LICENSE" ; License is not in build directory
  45. !define APPICON "images\dgse_logo.ico" ; nor is the icon
  46. !define DISTDIR "dist"
  47. !define HELPURL "https://github.com/arsenetar/dupeguru/issues"
  48. !define UPDATEURL "https://dupeguru.voltaicideas.net/"
  49. !define ABOUTURL "https://dupeguru.voltaicideas.net/"
  50. ; Static Defines
  51. !define UNINSTALLREGBASE "Software\Microsoft\Windows\CurrentVersion\Uninstall"
  52. ; Derived Defines
  53. !define BASEREGKEY "Software\${COMPANYNAME}\${APPNAME}" ;without root key
  54. !define VENDORREGKEY "Software\${COMPANYNAME}" ;without root key
  55. !define UNINSTALLREG "${UNINSTALLREGBASE}\${APPNAME}" ;without root key
  56. !define INSTPATH "${COMPANYNAME}\${APPNAME}" ;without programs / appdata
  57. ; Global vars
  58. var StartMenuFolder
  59. var InstallSize
  60. ;==============================================================================
  61. ; Plugin Setup
  62. ;==============================================================================
  63. ; MultiUser Plugin - Allow single user or all install based on execution level
  64. !define MULTIUSER_EXECUTIONLEVEL Highest
  65. !define MULTIUSER_MUI
  66. !define MULTIUSER_INSTALLMODE_COMMANDLINE
  67. !define MULTIUSER_INSTALLMODE_INSTDIR "${INSTPATH}" ; without programs /appdata
  68. ; allow for next run of installer to automatically find install path and type
  69. !define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "${BASEREGKEY}"
  70. !define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME "InstallPath"
  71. !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "${BASEREGKEY}"
  72. !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "InstallType"
  73. !if ${BITS} == "64"
  74. !define MULTIUSER_USE_PROGRAMFILES64
  75. !endif
  76. !include MultiUser.nsh
  77. ; Modern UI 2
  78. !include MUI2.nsh
  79. !define MUI_ICON "${APPICON}"
  80. !define MUI_ABORTWARNING
  81. !define MUI_UNABORTWARNING
  82. ;==============================================================================
  83. ; NSIS Variables
  84. ;==============================================================================
  85. Name "${APPNAME}"
  86. !system 'mkdir "${DISTDIR}"'
  87. OutFile "${DISTDIR}\${APPNAME}_win${BITS}_${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONPATCH}.exe"
  88. Icon "${APPICON}"
  89. ;==============================================================================
  90. ; Pages
  91. ;==============================================================================
  92. !insertmacro MUI_PAGE_WELCOME
  93. !insertmacro MUI_PAGE_LICENSE "${APPLICENSE}"
  94. !insertmacro MULTIUSER_PAGE_INSTALLMODE
  95. !insertmacro MUI_PAGE_DIRECTORY
  96. ; values for start menu page
  97. !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX" ; uses shell context
  98. !define MUI_STARTMENUPAGE_REGISTRY_KEY "${BASEREGKEY}"
  99. !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
  100. !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
  101. !insertmacro MUI_PAGE_INSTFILES
  102. !insertmacro MUI_PAGE_FINISH
  103. ; uninstaller pages
  104. !insertmacro MUI_UNPAGE_CONFIRM
  105. !insertmacro MUI_UNPAGE_INSTFILES
  106. ;==============================================================================
  107. ; Languages
  108. ;==============================================================================
  109. !insertmacro MUI_LANGUAGE "English" ;first language is the default language
  110. !insertmacro MUI_LANGUAGE "French"
  111. !insertmacro MUI_LANGUAGE "German"
  112. !insertmacro MUI_LANGUAGE "Greek"
  113. !insertmacro MUI_LANGUAGE "Italian"
  114. !insertmacro MUI_LANGUAGE "Korean"
  115. !insertmacro MUI_LANGUAGE "Polish"
  116. !insertmacro MUI_LANGUAGE "Russian"
  117. !insertmacro MUI_LANGUAGE "Spanish"
  118. !insertmacro MUI_LANGUAGE "Ukrainian"
  119. !insertmacro MUI_LANGUAGE "Vietnamese"
  120. !insertmacro MUI_LANGUAGE "Dutch"
  121. !insertmacro MUI_LANGUAGE "Czech"
  122. ;!insertmacro MUI_LANGUAGE "Chinese" ; no NSIS builtin support
  123. ;!insertmacro MUI_LANGUAGE "Brazilian" ; no NSIS builtin support
  124. ;!insertmacro MUI_LANGUAGE "Armenian" ; requires UNICODE
  125. ;==============================================================================
  126. ; Reserve Files
  127. ;==============================================================================
  128. ; If you are using solid compression, files that are required before
  129. ; the actual installation should be stored first in the data block,
  130. ; because this will make your installer start faster.
  131. !insertmacro MUI_RESERVEFILE_LANGDLL
  132. ReserveFile /nonfatal "${NSISDIR}\Plugins\*.dll" ;reserve if needed
  133. ;==============================================================================
  134. ; Installer Sections
  135. ;==============================================================================
  136. Section "!Application" AppSec
  137. SetOutPath "$INSTDIR" ; set from result of installer pages
  138. ; Files to install
  139. File /r "${SOURCEPATH}\${APPNAME}-win${BITS}\*"
  140. ; Create Start Menu Items
  141. !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
  142. CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
  143. CreateShortcut "$SMPROGRAMS\$StartMenuFolder\${APPNAME}.lnk" "$INSTDIR\${APPNAME}-win${BITS}.exe"
  144. CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
  145. !insertmacro MUI_STARTMENU_WRITE_END
  146. ; Store installation folder
  147. WriteRegStr SHCTX "${BASEREGKEY}" "InstallPath" $INSTDIR
  148. WriteRegStr SHCTX "${BASEREGKEY}" "InstallType" $MultiUser.InstallMode
  149. ; get installed size
  150. Push $R0
  151. Push $R1
  152. Push $R2
  153. ${GetSize} "$INSTDIR" "/S=0K" $R0 $R1 $R2 ; look into locate
  154. IntFmt $InstallSize "0x%08X" $R0
  155. Pop $R2
  156. Pop $R1
  157. Pop $R0
  158. ; Uninstall Entry
  159. WriteRegStr SHCTX "${UNINSTALLREG}" "DisplayName" "${APPNAME} ${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONPATCH}"
  160. WriteRegStr SHCTX "${UNINSTALLREG}" "DisplayVersion" "${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONPATCH}"
  161. WriteRegStr SHCTX "${UNINSTALLREG}" "DisplayIcon" "$INSTDIR\${APPNAME}.exe"
  162. WriteRegDWORD SHCTX "${UNINSTALLREG}" "VersionMajor" ${VERSIONMAJOR}
  163. WriteRegDWORD SHCTX "${UNINSTALLREG}" "VersionMinor" ${VERSIONMINOR}
  164. WriteRegDWORD SHCTX "${UNINSTALLREG}" "VersionPatch" ${VERSIONPATCH}
  165. WriteRegStr SHCTX "${UNINSTALLREG}" "Comments" "${APPNAME} installer"
  166. WriteRegStr SHCTX "${UNINSTALLREG}" "InstallLocation" "$INSTDIR"
  167. WriteRegStr SHCTX "${UNINSTALLREG}" "Publisher" "${COMPANYNAME}"
  168. WriteRegStr SHCTX "${UNINSTALLREG}" "Contact" "${HELPURL}"
  169. WriteRegStr SHCTX "${UNINSTALLREG}" "HelpLink" "${HELPURL}"
  170. WriteRegStr SHCTX "${UNINSTALLREG}" "URLUpdateInfo" "${UPDATEURL}"
  171. WriteRegStr SHCTX "${UNINSTALLREG}" "URLInfoAbout" "${ABOUTURL}"
  172. WriteRegDWORD SHCTX "${UNINSTALLREG}" "NoModify" 1
  173. WriteRegDWORD SHCTX "${UNINSTALLREG}" "NoRepair" 1
  174. WriteRegDWORD SHCTX "${UNINSTALLREG}" "EstimatedSize" $InstallSize
  175. WriteRegStr SHCTX "${UNINSTALLREG}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\" /$MultiUser.InstallMode"
  176. WriteRegStr SHCTX "${UNINSTALLREG}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /$MultiUser.InstallMode /S"
  177. ; Create uninstaller
  178. WriteUninstaller "$INSTDIR\Uninstall.exe"
  179. SectionEnd
  180. ;==============================================================================
  181. ; Descriptions
  182. ;==============================================================================
  183. ; Add descriptions as needed
  184. ;==============================================================================
  185. ; Uninstaller Sections
  186. ;==============================================================================
  187. Section "Uninstall"
  188. ; Remove Start Menu Folder
  189. !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
  190. RMDir /r "$SMPROGRAMS\$StartMenuFolder"
  191. ; Remove Files & Folders in Install Folder
  192. RMDir /r "$INSTDIR\core"
  193. RMDir /r "$INSTDIR\help"
  194. RMDir /r "$INSTDIR\PyQt5"
  195. RMDir /r "$INSTDIR\qt"
  196. RMDir /r "$INSTDIR\locale"
  197. Delete "$INSTDIR\*.exe"
  198. Delete "$INSTDIR\*.dll"
  199. Delete "$INSTDIR\*.pyd"
  200. Delete "$INSTDIR\*.zip"
  201. Delete "$INSTDIR\*.manifest"
  202. ; Remove Install Folder if empty
  203. RMDir "$INSTDIR"
  204. ; Remove registry keys and vendor keys (if empty)
  205. DeleteRegKey SHCTX "${BASEREGKEY}"
  206. DeleteRegKey /ifempty SHCTX "${VENDORREGKEY}"
  207. DeleteRegKey SHCTX "${UNINSTALLREG}"
  208. SectionEnd
  209. ;==============================================================================
  210. ; Functions
  211. ;==============================================================================
  212. Function .onInit
  213. !if ${BITS} == "64"
  214. SetRegView 64
  215. !else
  216. SetRegView 32
  217. !endif
  218. !insertmacro MULTIUSER_INIT
  219. ; it appears that the languages shown may not always be filtered correctly
  220. !define MUI_LANGDLL_ALLLANGUAGES
  221. !insertmacro MUI_LANGDLL_DISPLAY
  222. FunctionEnd
  223. Function un.onInit
  224. !if ${BITS} == "64"
  225. SetRegView 64
  226. !else
  227. SetRegView 32
  228. !endif
  229. !insertmacro MULTIUSER_UNINIT
  230. !insertmacro MUI_UNGETLANGUAGE
  231. FunctionEnd