| 1 |
# Deluge Windows installer script |
| 2 |
# |
| 3 |
# Copyright (C) 2009 Jesper Lund <[email protected]> |
| 4 |
# Copyright (C) 2009 Andrew Resch <[email protected]> |
| 5 |
# Copyright (C) 2009 John Garland <[email protected]> |
| 6 |
# |
| 7 |
# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later. |
| 8 |
# See LICENSE for more details. |
| 9 |
# |
| 10 |
|
| 11 |
# Script version; displayed when running the installer |
| 12 |
!define DELUGE_INSTALLER_VERSION "2.0" |
| 13 |
|
| 14 |
# Deluge program information |
| 15 |
!define PROGRAM_NAME "Deluge" |
| 16 |
# Detect version from file |
| 17 |
!searchparse /file VERSION.tmp `build_version = "` PROGRAM_VERSION `"` |
| 18 |
!ifndef PROGRAM_VERSION |
| 19 |
!error "Program Version Undefined" |
| 20 |
!endif |
| 21 |
!define PROGRAM_WEB_SITE "http://deluge-torrent.org" |
| 22 |
!define LICENSE_FILEPATH "..\..\LICENSE" |
| 23 |
|
| 24 |
!include FileFunc.nsh |
| 25 |
|
| 26 |
!ifndef arch |
| 27 |
!define INSTALLER_FILENAME "deluge-${PROGRAM_VERSION}-win64-setup.exe" |
| 28 |
!endif |
| 29 |
!If "${arch}" == "x64" |
| 30 |
!define INSTALLER_FILENAME "deluge-${PROGRAM_VERSION}-win64-setup.exe" |
| 31 |
!EndIf |
| 32 |
!If "${arch}" == "x86" |
| 33 |
!define INSTALLER_FILENAME "deluge-${PROGRAM_VERSION}-win32-setup.exe" |
| 34 |
!EndIf |
| 35 |
|
| 36 |
# Set default compressor |
| 37 |
SetCompressor /FINAL /SOLID lzma |
| 38 |
SetCompressorDictSize 64 |
| 39 |
|
| 40 |
# --- Interface settings --- |
| 41 |
# Modern User Interface 2 |
| 42 |
!include MUI2.nsh |
| 43 |
# Installer |
| 44 |
!define MUI_ICON "..\..\deluge\ui\data\pixmaps\deluge.ico" |
| 45 |
!define MUI_HEADERIMAGE |
| 46 |
!define MUI_HEADERIMAGE_RIGHT |
| 47 |
!define MUI_HEADERIMAGE_BITMAP "installer-top.bmp" |
| 48 |
!define MUI_WELCOMEFINISHPAGE_BITMAP "installer-side.bmp" |
| 49 |
!define MUI_COMPONENTSPAGE_SMALLDESC |
| 50 |
!define MUI_FINISHPAGE_NOAUTOCLOSE |
| 51 |
!define MUI_ABORTWARNING |
| 52 |
# Start Menu Folder Page Configuration |
| 53 |
!define MUI_STARTMENUPAGE_DEFAULTFOLDER ${PROGRAM_NAME} |
| 54 |
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCR" |
| 55 |
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Deluge" |
| 56 |
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" |
| 57 |
# Uninstaller |
| 58 |
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" |
| 59 |
!define MUI_HEADERIMAGE_UNBITMAP "installer-top.bmp" |
| 60 |
!define MUI_WELCOMEFINISHPAGE_UNBITMAP "installer-side.bmp" |
| 61 |
!define MUI_UNFINISHPAGE_NOAUTOCLOSE |
| 62 |
|
| 63 |
!define MUI_FINISHPAGE_SHOWREADME "" |
| 64 |
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED |
| 65 |
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Desktop Shortcut" |
| 66 |
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION finishpageaction |
| 67 |
|
| 68 |
# --- Start of Modern User Interface --- |
| 69 |
Var StartMenuFolder |
| 70 |
# Welcome, License & Components pages |
| 71 |
!insertmacro MUI_PAGE_WELCOME |
| 72 |
!insertmacro MUI_PAGE_LICENSE ${LICENSE_FILEPATH} |
| 73 |
!insertmacro MUI_PAGE_COMPONENTS |
| 74 |
# Let the user select the installation directory |
| 75 |
!insertmacro MUI_PAGE_DIRECTORY |
| 76 |
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder |
| 77 |
# Run installation |
| 78 |
!insertmacro MUI_PAGE_INSTFILES |
| 79 |
# Display 'finished' page |
| 80 |
!insertmacro MUI_PAGE_FINISH |
| 81 |
# Uninstaller pages |
| 82 |
!insertmacro MUI_UNPAGE_INSTFILES |
| 83 |
# Language files |
| 84 |
!insertmacro MUI_LANGUAGE "English" |
| 85 |
|
| 86 |
|
| 87 |
# --- Functions --- |
| 88 |
|
| 89 |
# Check for running Deluge instance. |
| 90 |
Function .onInit |
| 91 |
System::Call 'kernel32::OpenMutex(i 0x100000, b 0, t "deluge") i .R0' |
| 92 |
IntCmp $R0 0 notRunning |
| 93 |
System::Call 'kernel32::CloseHandle(i $R0)' |
| 94 |
MessageBox MB_OK|MB_ICONEXCLAMATION "Deluge is running. Please close it first" /SD IDOK |
| 95 |
Abort |
| 96 |
notRunning: |
| 97 |
FunctionEnd |
| 98 |
|
| 99 |
Function un.onUninstSuccess |
| 100 |
HideWindow |
| 101 |
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." /SD IDOK |
| 102 |
FunctionEnd |
| 103 |
|
| 104 |
Function un.onInit |
| 105 |
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Do you want to completely remove $(^Name)?" /SD IDYES IDYES +2 |
| 106 |
Abort |
| 107 |
FunctionEnd |
| 108 |
|
| 109 |
Function finishpageaction |
| 110 |
CreateShortCut "$DESKTOP\Deluge.lnk" "$INSTDIR\deluge.exe" |
| 111 |
FunctionEnd |
| 112 |
|
| 113 |
# --- Installation sections --- |
| 114 |
!define PROGRAM_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" |
| 115 |
!define PROGRAM_UNINST_FILENAME "$INSTDIR\deluge-uninst.exe" |
| 116 |
|
| 117 |
BrandingText "${PROGRAM_NAME} Windows Installer v${DELUGE_INSTALLER_VERSION}" |
| 118 |
Name "${PROGRAM_NAME} ${PROGRAM_VERSION}" |
| 119 |
OutFile "${INSTALLER_FILENAME}" |
| 120 |
|
| 121 |
!ifndef arch |
| 122 |
InstallDir "$PROGRAMFILES64\Deluge" |
| 123 |
!define PROGRAM_UNINST_ROOT_KEY "HKLM64" |
| 124 |
!endif |
| 125 |
!If "${arch}" == "x64" |
| 126 |
InstallDir "$PROGRAMFILES64\Deluge" |
| 127 |
!define PROGRAM_UNINST_ROOT_KEY "HKLM64" |
| 128 |
!endIf |
| 129 |
!If "${arch}" == "x86" |
| 130 |
InstallDir "$PROGRAMFILES32\Deluge" |
| 131 |
!define PROGRAM_UNINST_ROOT_KEY "HKLM" |
| 132 |
!endIf |
| 133 |
|
| 134 |
ShowInstDetails show |
| 135 |
ShowUnInstDetails show |
| 136 |
|
| 137 |
# Install main application |
| 138 |
Section "Deluge Bittorrent Client" Section1 |
| 139 |
SectionIn RO |
| 140 |
!include "install_files.nsh" |
| 141 |
|
| 142 |
SetOverwrite ifnewer |
| 143 |
SetOutPath "$INSTDIR" |
| 144 |
File ${LICENSE_FILEPATH} |
| 145 |
WriteIniStr "$INSTDIR\homepage.url" "InternetShortcut" "URL" "${PROGRAM_WEB_SITE}" |
| 146 |
|
| 147 |
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application |
| 148 |
SetShellVarContext all |
| 149 |
CreateDirectory "$SMPROGRAMS\$StartMenuFolder" |
| 150 |
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Deluge.lnk" "$INSTDIR\deluge.exe" |
| 151 |
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Website.lnk" "$INSTDIR\homepage.url" |
| 152 |
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall Deluge.lnk" ${PROGRAM_UNINST_FILENAME} |
| 153 |
!insertmacro MUI_STARTMENU_WRITE_END |
| 154 |
SectionEnd |
| 155 |
|
| 156 |
# Create .torrent file association. |
| 157 |
Section "Associate .torrent files with Deluge" Section2 |
| 158 |
DeleteRegKey HKCR ".torrent" |
| 159 |
WriteRegStr HKCR ".torrent" "" "Deluge" |
| 160 |
WriteRegStr HKCR ".torrent" "Content Type" "application/x-bittorrent" |
| 161 |
|
| 162 |
DeleteRegKey HKCR "Deluge" |
| 163 |
WriteRegStr HKCR "Deluge" "" "Deluge" |
| 164 |
WriteRegStr HKCR "Deluge\Content Type" "" "application/x-bittorrent" |
| 165 |
WriteRegStr HKCR "Deluge\DefaultIcon" "" "$INSTDIR\deluge.exe,0" |
| 166 |
WriteRegStr HKCR "Deluge\shell" "" "open" |
| 167 |
WriteRegStr HKCR "Deluge\shell\open\command" "" '"$INSTDIR\deluge.exe" "%1"' |
| 168 |
SectionEnd |
| 169 |
|
| 170 |
# Create magnet uri association. |
| 171 |
Section "Associate Magnet URI links with Deluge" Section3 |
| 172 |
DeleteRegKey HKCR "Magnet" |
| 173 |
WriteRegStr HKCR "Magnet" "" "URL:Magnet Protocol" |
| 174 |
WriteRegStr HKCR "Magnet" "URL Protocol" "" |
| 175 |
WriteRegStr HKCR "Magnet\shell\open\command" "" '"$INSTDIR\deluge.exe" "%1"' |
| 176 |
SectionEnd |
| 177 |
|
| 178 |
LangString DESC_Section1 ${LANG_ENGLISH} "Install Deluge Bittorrent client." |
| 179 |
LangString DESC_Section2 ${LANG_ENGLISH} "Select this option to let Deluge handle the opening of .torrent files." |
| 180 |
LangString DESC_Section3 ${LANG_ENGLISH} "Select this option to let Deluge handle Magnet URI links from the web-browser." |
| 181 |
|
| 182 |
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN |
| 183 |
!insertmacro MUI_DESCRIPTION_TEXT ${Section1} $(DESC_Section1) |
| 184 |
!insertmacro MUI_DESCRIPTION_TEXT ${Section2} $(DESC_Section2) |
| 185 |
!insertmacro MUI_DESCRIPTION_TEXT ${Section3} $(DESC_Section3) |
| 186 |
!insertmacro MUI_FUNCTION_DESCRIPTION_END |
| 187 |
|
| 188 |
# Create uninstaller. |
| 189 |
Section -Uninstaller |
| 190 |
WriteUninstaller ${PROGRAM_UNINST_FILENAME} |
| 191 |
WriteRegStr ${PROGRAM_UNINST_ROOT_KEY} "${PROGRAM_UNINST_KEY}" "DisplayName" "$(^Name)" |
| 192 |
WriteRegStr ${PROGRAM_UNINST_ROOT_KEY} "${PROGRAM_UNINST_KEY}" "DisplayVersion" ${PROGRAM_VERSION} |
| 193 |
WriteRegStr ${PROGRAM_UNINST_ROOT_KEY} "${PROGRAM_UNINST_KEY}" "UninstallString" ${PROGRAM_UNINST_FILENAME} |
| 194 |
SectionEnd |
| 195 |
|
| 196 |
# --- Uninstallation section --- |
| 197 |
Section Uninstall |
| 198 |
# Delete Deluge files. |
| 199 |
Delete "$INSTDIR\LICENSE" |
| 200 |
Delete "$INSTDIR\homepage.url" |
| 201 |
Delete ${PROGRAM_UNINST_FILENAME} |
| 202 |
!include "uninstall_files.nsh" |
| 203 |
|
| 204 |
# Delete Start Menu items. |
| 205 |
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder |
| 206 |
SetShellVarContext all |
| 207 |
Delete "$SMPROGRAMS\$StartMenuFolder\Deluge.lnk" |
| 208 |
Delete "$SMPROGRAMS\$StartMenuFolder\Website.lnk" |
| 209 |
Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall Deluge.lnk" |
| 210 |
RmDir "$SMPROGRAMS\$StartMenuFolder" |
| 211 |
DeleteRegKey /ifempty HKCR "Software\Deluge" |
| 212 |
|
| 213 |
Delete "$DESKTOP\Deluge.lnk" |
| 214 |
|
| 215 |
# Delete registry keys. |
| 216 |
DeleteRegKey ${PROGRAM_UNINST_ROOT_KEY} "${PROGRAM_UNINST_KEY}" |
| 217 |
# Only delete the .torrent association if Deluge owns it |
| 218 |
ReadRegStr $1 HKCR ".torrent" "" |
| 219 |
StrCmp $1 "Deluge" 0 DELUGE_skip_delete |
| 220 |
# Delete the key since it is owned by Deluge; afterwards there is no .torrent association |
| 221 |
DeleteRegKey HKCR ".torrent" |
| 222 |
DELUGE_skip_delete: |
| 223 |
# This key is only used by Deluge, so we should always delete it |
| 224 |
DeleteRegKey HKCR "Deluge" |
| 225 |
SectionEnd |
| 226 |
|
| 227 |
# Add version info to installer properties. |
| 228 |
VIProductVersion "${DELUGE_INSTALLER_VERSION}.0.0" |
| 229 |
VIAddVersionKey ProductName ${PROGRAM_NAME} |
| 230 |
VIAddVersionKey Comments "Deluge Bittorrent Client" |
| 231 |
VIAddVersionKey CompanyName "Deluge Team" |
| 232 |
VIAddVersionKey LegalCopyright "Deluge Team" |
| 233 |
VIAddVersionKey FileDescription "${PROGRAM_NAME} Application Installer" |
| 234 |
VIAddVersionKey FileVersion "${DELUGE_INSTALLER_VERSION}.0.0" |
| 235 |
VIAddVersionKey ProductVersion "${PROGRAM_VERSION}.0" |
| 236 |
VIAddVersionKey OriginalFilename ${INSTALLER_FILENAME} |