[Packaging] Updates to the NSIS Installer script

* New message box popup if VC 2008 Redist package not detected.
 * Add Start Menu page to choose where/if to install items.
 * Add desktop shortcut install option to finish page.
 * Clean up spacing and use consistent 4 spaces to indent.
 * Exclude as many unneeded pygame libraries as possible.
This commit is contained in:
Calum Lind 2015-09-17 09:56:58 +01:00
parent 52c8fde461
commit a13b4270b5
2 changed files with 157 additions and 104 deletions

View File

@ -116,8 +116,11 @@ fzr()
for script in script_list: for script in script_list:
os.remove(script) os.remove(script)
# Exclude files which are already included in GTK or Windows. # Exclude files which are already included in GTK or Windows. Also exclude unneeded pygame dlls.
excludeDlls = ("MSIMG32.dll", "MSVCR90.dll", "MSVCP90.dll", "MSVCR120.dll", "POWRPROF.dll", "DNSAPI.dll", "USP10.dll") excludeDlls = ("MSIMG32.dll", "MSVCR90.dll", "MSVCP90.dll", "MSVCR120.dll",
"POWRPROF.dll", "DNSAPI.dll", "USP10.dll", "MPR.dll",
"jpeg.dll", "libfreetype-6.dll", "libpng12-0.dll", "libtiff.dll",
"SDL_image.dll", "SDL_ttf.dll")
for dll in excludeDlls: for dll in excludeDlls:
try: try:
os.remove(os.path.join(build_dir, dll)) os.remove(os.path.join(build_dir, dll))

View File

@ -25,35 +25,31 @@
# Boston, MA 02110-1301, USA. # Boston, MA 02110-1301, USA.
# #
# Set default compressor
SetCompressor /FINAL /SOLID lzma
SetCompressorDictSize 64
###
### --- The PROGRAM_VERSION !define need to be updated with new Deluge versions ---
###
# Script version; displayed when running the installer # Script version; displayed when running the installer
!define DELUGE_INSTALLER_VERSION "0.8" !define DELUGE_INSTALLER_VERSION "1.0"
# Deluge program information # Deluge program information
!define PROGRAM_NAME "Deluge" !define PROGRAM_NAME "Deluge"
# Deluge program information # Detect version from file
!searchparse /file VERSION.tmp `build_version = "` PROGRAM_VERSION `"` !searchparse /file VERSION.tmp `build_version = "` PROGRAM_VERSION `"`
!ifndef PROGRAM_VERSION !ifndef PROGRAM_VERSION
!error "Program Version Undefined" !error "Program Version Undefined"
!endif !endif
!define PROGRAM_WEB_SITE "http://deluge-torrent.org" !define PROGRAM_WEB_SITE "http://deluge-torrent.org"
!define LICENSE_FILEPATH "..\LICENSE"
# Python files generated with bbfreeze # Python files generated with bbfreeze
!define BUILD_DIR "build-win32" !define BUILD_DIR "build-win32"
!define BBFREEZE_DIR "${BUILD_DIR}\deluge-bbfreeze-${PROGRAM_VERSION}" !define BBFREEZE_DIR "${BUILD_DIR}\deluge-bbfreeze-${PROGRAM_VERSION}"
!define INSTALLER_FILENAME "deluge-${PROGRAM_VERSION}-win32-setup.exe"
# Set default compressor
SetCompressor /FINAL /SOLID lzma
SetCompressorDictSize 64
# --- Interface settings --- # --- Interface settings ---
# Modern User Interface 2 # Modern User Interface 2
!include MUI2.nsh !include MUI2.nsh
# Installer # Installer
!define MUI_ICON "..\deluge\data\pixmaps\deluge.ico" !define MUI_ICON "..\deluge\data\pixmaps\deluge.ico"
!define MUI_HEADERIMAGE !define MUI_HEADERIMAGE
@ -63,77 +59,117 @@ SetCompressorDictSize 64
!define MUI_COMPONENTSPAGE_SMALLDESC !define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_FINISHPAGE_NOAUTOCLOSE !define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_ABORTWARNING !define MUI_ABORTWARNING
# Start Menu Folder Page Configuration
!define MUI_STARTMENUPAGE_DEFAULTFOLDER ${PROGRAM_NAME}
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCR"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Deluge"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
# Uninstaller # Uninstaller
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
!define MUI_HEADERIMAGE_UNBITMAP "installer-top.bmp" !define MUI_HEADERIMAGE_UNBITMAP "installer-top.bmp"
!define MUI_WELCOMEFINISHPAGE_UNBITMAP "installer-side.bmp" !define MUI_WELCOMEFINISHPAGE_UNBITMAP "installer-side.bmp"
!define MUI_UNFINISHPAGE_NOAUTOCLOSE !define MUI_UNFINISHPAGE_NOAUTOCLOSE
!define MUI_FINISHPAGE_SHOWREADME ""
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Desktop Shortcut"
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION finishpageaction
# --- Start of Modern User Interface --- # --- Start of Modern User Interface ---
Var StartMenuFolder
# Welcome page # Welcome, License & Components pages
!insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE ${LICENSE_FILEPATH}
# License page
!insertmacro MUI_PAGE_LICENSE "..\LICENSE"
# Components page
!insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_COMPONENTS
# Let the user select the installation directory # Let the user select the installation directory
!insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
# Run installation # Run installation
!insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_INSTFILES
# Popup Message if VC Redist missing
Page Custom VCRedistMessage
# Display 'finished' page # Display 'finished' page
!insertmacro MUI_PAGE_FINISH !insertmacro MUI_PAGE_FINISH
# Uninstaller pages # Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_INSTFILES
# Language files # Language files
!insertmacro MUI_LANGUAGE "English" !insertmacro MUI_LANGUAGE "English"
VIProductVersion "${DELUGE_INSTALLER_VERSION}.0.0"
VIAddVersionKey ProductName "${PROGRAM_NAME}"
VIAddVersionKey Comments "Deluge Bittorrent Client"
VIAddVersionKey CompanyName "Deluge Team"
VIAddVersionKey LegalCopyright "Deluge Team"
VIAddVersionKey FileDescription "${PROGRAM_NAME} Application Installer"
VIAddVersionKey FileVersion "${DELUGE_INSTALLER_VERSION}.0.0"
VIAddVersionKey ProductVersion "${PROGRAM_VERSION}.0"
VIAddVersionKey OriginalFilename "deluge-${PROGRAM_VERSION}-win32-setup.exe"
# --- Functions --- # --- Functions ---
# Check for running Deluge instance.
Function .onInit Function .onInit
System::Call 'kernel32::OpenMutex(i 0x100000, b 0, t "deluge") i .R0' System::Call 'kernel32::OpenMutex(i 0x100000, b 0, t "deluge") i .R0'
IntCmp $R0 0 notRunning IntCmp $R0 0 notRunning
System::Call 'kernel32::CloseHandle(i $R0)' System::Call 'kernel32::CloseHandle(i $R0)'
MessageBox MB_OK|MB_ICONEXCLAMATION "Deluge is running. Please close it first" /SD IDOK MessageBox MB_OK|MB_ICONEXCLAMATION "Deluge is running. Please close it first" /SD IDOK
Abort Abort
notRunning: notRunning:
FunctionEnd FunctionEnd
Function un.onUninstSuccess Function un.onUninstSuccess
HideWindow HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." /SD IDOK MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." /SD IDOK
FunctionEnd FunctionEnd
Function un.onInit Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Do you want to completely remove $(^Name)?" /SD IDYES IDYES +2 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Do you want to completely remove $(^Name)?" /SD IDYES IDYES +2
Abort Abort
FunctionEnd
Function finishpageaction
CreateShortCut "$DESKTOP\Deluge.lnk" "$INSTDIR\deluge.exe"
FunctionEnd
#Test if Visual Studio Redistributables 2008 SP1 installed
#Returns -1 if there is no VC redistributables intstalled
Function CheckVCRedist2008
Push $R0
ClearErrors
ReadRegDword $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{FF66E9F6-83E7-3A3E-AF14-8DE9A809A6A4}" "Version"
IfErrors 0 +2
StrCpy $R0 "-1"
Push $R1
ClearErrors
ReadRegDword $R1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9A25302D-30C0-39D9-BD6F-21E6EC160475}" "Version"
IfErrors 0 VSRedistInstalled
StrCpy $R1 "-1"
StrCmp $R0 "-1" +3 0
Exch $R0
Goto VSRedistInstalled
StrCmp $R1 "-1" +3 0
Exch $R1
Goto VSRedistInstalled
# else
Push "-1"
VSRedistInstalled:
FunctionEnd
Function VCRedistMessage
Call CheckVCRedist2008
Pop $R0
StrCmp $R0 "-1" 0 end
MessageBox MB_YESNO|MB_ICONEXCLAMATION "The following package is required to run \
Deluge but it does not appear to be installed:$\r$\n$\r$\n\
Microsoft Visual C++ 2008 SP1 Redistributable Package (x86)$\r$\n$\r$\n\
Would you like to download it now?" /SD IDNO IDYES clickyes
Goto end
clickyes:
ExecShell open "https://www.microsoft.com/en-us/download/details.aspx?id=5582"
end:
FunctionEnd FunctionEnd
# --- Installation sections --- # --- Installation sections ---
!define PROGRAM_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" !define PROGRAM_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}"
!define PROGRAM_UNINST_ROOT_KEY "HKLM" !define PROGRAM_UNINST_ROOT_KEY "HKLM"
!define PROGRAM_UNINST_FILENAME "$INSTDIR\deluge-uninst.exe"
BrandingText "Deluge Windows Installer v${DELUGE_INSTALLER_VERSION}" BrandingText "${PROGRAM_NAME} Windows Installer v${DELUGE_INSTALLER_VERSION}"
Name "${PROGRAM_NAME} ${PROGRAM_VERSION}" Name "${PROGRAM_NAME} ${PROGRAM_VERSION}"
OutFile "${BUILD_DIR}\deluge-${PROGRAM_VERSION}-win32-setup.exe" OutFile "${BUILD_DIR}\${INSTALLER_FILENAME}"
InstallDir "$PROGRAMFILES\Deluge" InstallDir "$PROGRAMFILES\Deluge"
ShowInstDetails show ShowInstDetails show
@ -141,47 +177,38 @@ ShowUnInstDetails show
# Install main application # Install main application
Section "Deluge Bittorrent Client" Section1 Section "Deluge Bittorrent Client" Section1
SectionIn RO SectionIn RO
!include "install_files.nsh" !include "install_files.nsh"
SetOverwrite ifnewer SetOverwrite ifnewer
SetOutPath "$INSTDIR" SetOutPath "$INSTDIR"
File "..\LICENSE" File ${LICENSE_FILEPATH}
WriteIniStr "$INSTDIR\homepage.url" "InternetShortcut" "URL" "${PROGRAM_WEB_SITE}"
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
SetShellVarContext all
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Deluge.lnk" "$INSTDIR\deluge.exe"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Website.lnk" "$INSTDIR\homepage.url"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall Deluge.lnk" ${PROGRAM_UNINST_FILENAME}
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd SectionEnd
Section -StartMenu_Desktop_Links # Create .torrent file association.
WriteIniStr "$INSTDIR\homepage.url" "InternetShortcut" "URL" "${PROGRAM_WEB_SITE}"
# create shortcuts for all users
SetShellVarContext all
CreateDirectory "$SMPROGRAMS\Deluge"
CreateShortCut "$SMPROGRAMS\Deluge\Deluge.lnk" "$INSTDIR\deluge.exe"
CreateShortCut "$SMPROGRAMS\Deluge\Website.lnk" "$INSTDIR\homepage.url"
CreateShortCut "$SMPROGRAMS\Deluge\Uninstall Deluge.lnk" "$INSTDIR\deluge-uninst.exe"
CreateShortCut "$DESKTOP\Deluge.lnk" "$INSTDIR\deluge.exe"
SectionEnd
Section -Uninstaller
WriteUninstaller "$INSTDIR\deluge-uninst.exe"
WriteRegStr ${PROGRAM_UNINST_ROOT_KEY} "${PROGRAM_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PROGRAM_UNINST_ROOT_KEY} "${PROGRAM_UNINST_KEY}" "UninstallString" "$INSTDIR\deluge-uninst.exe"
SectionEnd
# Create file association for .torrent
Section "Associate .torrent files with Deluge" Section2 Section "Associate .torrent files with Deluge" Section2
# Set up file association for .torrent files DeleteRegKey HKCR ".torrent"
DeleteRegKey HKCR ".torrent" WriteRegStr HKCR ".torrent" "" "Deluge"
WriteRegStr HKCR ".torrent" "" "Deluge" WriteRegStr HKCR ".torrent" "Content Type" "application/x-bittorrent"
WriteRegStr HKCR ".torrent" "Content Type" "application/x-bittorrent"
DeleteRegKey HKCR "Deluge" DeleteRegKey HKCR "Deluge"
WriteRegStr HKCR "Deluge" "" "Deluge" WriteRegStr HKCR "Deluge" "" "Deluge"
WriteRegStr HKCR "Deluge\Content Type" "" "application/x-bittorrent" WriteRegStr HKCR "Deluge\Content Type" "" "application/x-bittorrent"
WriteRegStr HKCR "Deluge\DefaultIcon" "" "$INSTDIR\deluge.exe,0" WriteRegStr HKCR "Deluge\DefaultIcon" "" "$INSTDIR\deluge.exe,0"
WriteRegStr HKCR "Deluge\shell" "" "open" WriteRegStr HKCR "Deluge\shell" "" "open"
WriteRegStr HKCR "Deluge\shell\open\command" "" '"$INSTDIR\deluge.exe" "%1"' WriteRegStr HKCR "Deluge\shell\open\command" "" '"$INSTDIR\deluge.exe" "%1"'
SectionEnd SectionEnd
# Create magnet uri association # Create magnet uri association.
Section "Associate Magnet URI links with Deluge" Section3 Section "Associate Magnet URI links with Deluge" Section3
DeleteRegKey HKCR "Magnet" DeleteRegKey HKCR "Magnet"
WriteRegStr HKCR "Magnet" "" "URL:Magnet Protocol" WriteRegStr HKCR "Magnet" "" "URL:Magnet Protocol"
@ -194,33 +221,56 @@ LangString DESC_Section2 ${LANG_ENGLISH} "Select this option to let Deluge handl
LangString DESC_Section3 ${LANG_ENGLISH} "Select this option to let Deluge handle Magnet URI links from the web-browser." LangString DESC_Section3 ${LANG_ENGLISH} "Select this option to let Deluge handle Magnet URI links from the web-browser."
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${Section1} $(DESC_Section1) !insertmacro MUI_DESCRIPTION_TEXT ${Section1} $(DESC_Section1)
!insertmacro MUI_DESCRIPTION_TEXT ${Section2} $(DESC_Section2) !insertmacro MUI_DESCRIPTION_TEXT ${Section2} $(DESC_Section2)
!insertmacro MUI_DESCRIPTION_TEXT ${Section3} $(DESC_Section3) !insertmacro MUI_DESCRIPTION_TEXT ${Section3} $(DESC_Section3)
!insertmacro MUI_FUNCTION_DESCRIPTION_END !insertmacro MUI_FUNCTION_DESCRIPTION_END
# Create uninstaller.
Section -Uninstaller
WriteUninstaller ${PROGRAM_UNINST_FILENAME}
WriteRegStr ${PROGRAM_UNINST_ROOT_KEY} "${PROGRAM_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PROGRAM_UNINST_ROOT_KEY} "${PROGRAM_UNINST_KEY}" "UninstallString" ${PROGRAM_UNINST_FILENAME}
SectionEnd
# --- Uninstallation section --- # --- Uninstallation section ---
Section Uninstall Section Uninstall
Delete "$INSTDIR\LICENSE" # Delete Deluge files.
Delete "$INSTDIR\homepage.url" Delete "$INSTDIR\LICENSE"
Delete "$INSTDIR\deluge-uninst.exe" Delete "$INSTDIR\homepage.url"
!include "uninstall_files.nsh" Delete ${PROGRAM_UNINST_FILENAME}
!include "uninstall_files.nsh"
SetShellVarContext all # Delete Start Menu items.
Delete "$SMPROGRAMS\Deluge\Deluge.lnk" !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
Delete "$SMPROGRAMS\Deluge\Uninstall Deluge.lnk" SetShellVarContext all
Delete "$SMPROGRAMS\Deluge\Deluge Website.lnk" Delete "$SMPROGRAMS\$StartMenuFolder\Deluge.lnk"
RmDir "$SMPROGRAMS\Deluge" Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall Deluge.lnk"
Delete "$DESKTOP\Deluge.lnk" Delete "$SMPROGRAMS\$StartMenuFolder\Deluge Website.lnk"
RmDir "$SMPROGRAMS\$StartMenuFolder"
DeleteRegKey /ifempty HKCR "Software\Deluge"
DeleteRegKey ${PROGRAM_UNINST_ROOT_KEY} "${PROGRAM_UNINST_KEY}" Delete "$DESKTOP\Deluge.lnk"
# Only delete the .torrent association if Deluge owns it # Delete registry keys.
ReadRegStr $1 HKCR ".torrent" "" DeleteRegKey ${PROGRAM_UNINST_ROOT_KEY} "${PROGRAM_UNINST_KEY}"
StrCmp $1 "Deluge" 0 DELUGE_skip_delete # Only delete the .torrent association if Deluge owns it
# Delete the key since it is owned by Deluge; afterwards there is no .torrent association ReadRegStr $1 HKCR ".torrent" ""
DeleteRegKey HKCR ".torrent" StrCmp $1 "Deluge" 0 DELUGE_skip_delete
DELUGE_skip_delete: # Delete the key since it is owned by Deluge; afterwards there is no .torrent association
# This key is only used by Deluge, so we should always delete it DeleteRegKey HKCR ".torrent"
DeleteRegKey HKCR "Deluge" DELUGE_skip_delete:
# This key is only used by Deluge, so we should always delete it
DeleteRegKey HKCR "Deluge"
SectionEnd SectionEnd
# Add version info to installer properties.
VIProductVersion "${DELUGE_INSTALLER_VERSION}.0.0"
VIAddVersionKey ProductName ${PROGRAM_NAME}
VIAddVersionKey Comments "Deluge Bittorrent Client"
VIAddVersionKey CompanyName "Deluge Team"
VIAddVersionKey LegalCopyright "Deluge Team"
VIAddVersionKey FileDescription "${PROGRAM_NAME} Application Installer"
VIAddVersionKey FileVersion "${DELUGE_INSTALLER_VERSION}.0.0"
VIAddVersionKey ProductVersion "${PROGRAM_VERSION}.0"
VIAddVersionKey OriginalFilename ${INSTALLER_FILENAME}