Browse Source

NSIS: Refactor configuration to ease installer creation via scripting

adaptive-webui-19844
sledgehammer999 2 years ago
parent
commit
102b6c32eb
No known key found for this signature in database
GPG Key ID: 6E4A2D025B7CC9A2
  1. 61
      dist/windows/3rdparty/VersionCompleteXXXX.nsi
  2. 21
      dist/windows/README.txt
  3. 94
      dist/windows/config.nsi
  4. 2
      dist/windows/installer.nsi

61
dist/windows/3rdparty/VersionCompleteXXXX.nsi vendored

@ -0,0 +1,61 @@
; Code taken from https://nsis.sourceforge.io/VersionCompleteXXXX
; See http://nsis.sourceforge.net/VersionCompleteXXXX for documentation
!macro VersionCompleteXXXRevision _INPUT_VALUE _OUTPUT_SYMBOL _REVISION
!searchparse /noerrors ${_INPUT_VALUE} "" _VERSION_1 "." _VERSION_2 "." _VERSION_3 "." _VERSION_4
!ifndef _VERSION_1
!define _VERSION_1 0
!else if `${_VERSION_1}` == ``
!define /redef _VERSION_1 0
!endif
!ifndef _VERSION_2
!define _VERSION_2 0
!else if `${_VERSION_2}` == ``
!define /redef _VERSION_2 0
!endif
!ifndef _VERSION_3
!define _VERSION_3 0
!else if `${_VERSION_3}` == ``
!define /redef _VERSION_3 0
!endif
!ifndef _VERSION_4
!define _VERSION_4 0
!else if `${_VERSION_4}` == ``
!define /redef _VERSION_4 0
!endif
!define ${_OUTPUT_SYMBOL} ${_VERSION_1}.${_VERSION_2}.${_VERSION_3}.${_REVISION}
!undef _VERSION_1
!undef _VERSION_2
!undef _VERSION_3
!undef _VERSION_4
!undef _REVISION
!macroend
!define VersionCompleteXXXRevision `!insertmacro VersionCompleteXXXRevision`
!macro VersionCompleteXXXX _INPUT_VALUE _OUTPUT_SYMBOL
!searchparse /noerrors ${_INPUT_VALUE} "" _VERSION_1 "." _VERSION_2 "." _VERSION_3 "." _VERSION_4
!ifndef _VERSION_1
!define _VERSION_1 0
!else if `${_VERSION_1}` == ``
!define /redef _VERSION_1 0
!endif
!ifndef _VERSION_2
!define _VERSION_2 0
!else if `${_VERSION_2}` == ``
!define /redef _VERSION_2 0
!endif
!ifndef _VERSION_3
!define _VERSION_3 0
!else if `${_VERSION_3}` == ``
!define /redef _VERSION_3 0
!endif
!ifndef _VERSION_4
!define _VERSION_4 0
!else if `${_VERSION_4}` == ``
!define /redef _VERSION_4 0
!endif
!define ${_OUTPUT_SYMBOL} ${_VERSION_1}.${_VERSION_2}.${_VERSION_3}.${_VERSION_4}
!undef _VERSION_1
!undef _VERSION_2
!undef _VERSION_3
!undef _VERSION_4
!macroend
!define VersionCompleteXXXX `!insertmacro VersionCompleteXXXX`

21
dist/windows/README.txt vendored

@ -16,16 +16,16 @@ TRANSLATORS:
PACKAGERS: PACKAGERS:
You will need NSIS and upx to make the installer. You need a unicode version of NSIS. You will need NSIS 3 to make the installer. UPX is an optional requirement.
I tested with NSIS 3.0 (final).
1. Open the options.nsi file in an editor and change line that contains 1. Open the config.nsi file in an editor and change line that contains
"!define QBT_VERSION "3.0.3"" to the version of qbittorrent you just built. "!define QBT_VERSION "3.0.3"" to the version of qbittorrent you just built.
2. Extract the plugins found in the folder "nsis plugins" into your 2. config.nsi contains some other defines that control the installer output. Read the comments in that file.
3. Extract the plugins found in the folder "nsis plugins" into your
NSIS's unicode Plugin directory(usually C:\Program Files\NSIS\Plugins\x86-unicode). NSIS's unicode Plugin directory(usually C:\Program Files\NSIS\Plugins\x86-unicode).
Only the *.dll files are needed. Use the unicode version of the dlls. Only the *.dll files are needed. Use the unicode version of the dlls.
3. The script you need to compile is "qbittorrent.nsi". It includes all other necessary scripts. 4. The script you need to compile is "qbittorrent.nsi". It includes all other necessary scripts.
4. The script expects the following file tree: 5. The script expects the following file tree:
The installer script expects the following file tree: The installer script expects the following file tree:
@ -46,8 +46,10 @@ translations
qt_zh_TW.qm qt_zh_TW.qm
installer.nsi installer.nsi
license.txt license.txt
options.nsi config.nsi
helper.nsi
qbittorrent.exe qbittorrent.exe
qbittorrent.pdb
qbittorrent.nsi qbittorrent.nsi
qt.conf qt.conf
translations.nsi translations.nsi
@ -55,9 +57,10 @@ UAC.nsh
uninstaller.nsi uninstaller.nsi
5. "license.txt" is a text file that contains the text rendered 6. "license.txt" is a text file that contains the text rendered
from src\gui\gpl.html from src\gui\gpl.html
6. "qbittorrent.exe" is the compiled binary file. 7. "qbittorrent.exe" is the compiled binary file.
8. "qbittorrent.pdb" is the compiled binary's PDB file.
SCRIPT HACKERS: SCRIPT HACKERS:

94
dist/windows/config.nsi vendored

@ -1,3 +1,10 @@
;Start of user configurable options
;==============================================================================
; Uncomment if you want to use UPX to pack the installer header
; Doing so may make antivirus software flag the installer as virus/malware
;!define USE_UPX
; Uncomment when packaging 64bit qbittorrent ; Uncomment when packaging 64bit qbittorrent
;!define QBT_IS_X64 ;!define QBT_IS_X64
@ -10,25 +17,79 @@
!endif !endif
; qBittorrent version ; qBittorrent version
; The string MUST contain ONLY numbers delimited by dots.
; It MUST contain a maximum of 4 delimited numbers
; Other values will result in undefined behavior
; examples:
; 4.5.0 -> good
; 4.5.1.3 -> good
; 4.5.1.3.2 -> bad
; 4.5.0beta -> bad
!define /ifndef QBT_VERSION "4.5.0" !define /ifndef QBT_VERSION "4.5.0"
; Option that controls the installer's window name
; If set, its value will be used like this:
; "qBittorrent ${QBT_INSTALLER_FILENAME}"
; If not set, the window name will be auto composed from QBT_VERSION, QBT_USES_QT6, QBT_IS_X64
; If you set this define then you MUST set QBT_INSTALLER_FILENAME too. Otherwise it will be ignored.
; This define is meant to ease automation from scripts/commandline
;!define QBT_INSTALLER_WINDOWNAME
; Option that controls the installer's window name
; If set, its value will be used like this:
; "qbittorrent_${QBT_INSTALLER_FILENAME}_setup.exe"
; If not set, the window name will be auto composed from QBT_VERSION, QBT_USES_QT6, QBT_IS_X64
; If you set this define then you MUST set QBT_INSTALLER_WINDOWNAME too. Otherwise it will be ignored.
; This define is meant to ease automation from scripts/commandline
;!define QBT_INSTALLER_FILENAME
;End of user configurable options
;==============================================================================
!ifndef QBT_INSTALLER_WINDOWNAME | QBT_INSTALLER_FILENAME
!ifndef QBT_IS_X64
; The name of the installer
!define QBT_INSTALLER_WINDOWNAME "${QBT_VERSION}"
; The file to write
!define QBT_INSTALLER_FILENAME "${QBT_VERSION}"
!else ; QBT_IS_X64
!ifndef QBT_USES_QT6
; The name of the installer
!define QBT_INSTALLER_WINDOWNAME "${QBT_VERSION} x64"
; The file to write
!define QBT_INSTALLER_FILENAME "${QBT_VERSION}_x64"
!else ; QBT_USES_QT6
; The name of the installer
!define QBT_INSTALLER_WINDOWNAME "${QBT_VERSION} (qt6) x64"
; The file to write
!define QBT_INSTALLER_FILENAME "${QBT_VERSION}_qt6_x64"
!endif ; QBT_USES_QT6
!endif ; QBT_IS_X64
!endif
Unicode true Unicode true
ManifestDPIAware true ManifestDPIAware true
;Compress the header too
!ifdef USE_UPX
!packhdr "$%TEMP%\exehead.tmp" 'upx.exe -9 --best --ultra-brute "$%TEMP%\exehead.tmp"' !packhdr "$%TEMP%\exehead.tmp" 'upx.exe -9 --best --ultra-brute "$%TEMP%\exehead.tmp"'
!endif
;Setting the compression ;Setting the compression
SetCompressor /SOLID LZMA SetCompressor /SOLID LZMA
SetCompressorDictSize 64 SetCompressorDictSize 64
XPStyle on XPStyle on
!include "MUI.nsh" !include "MUI2.nsh"
!include "UAC.nsh" !include "UAC.nsh"
!include "FileFunc.nsh" !include "FileFunc.nsh"
!include "WinVer.nsh" !include "WinVer.nsh"
!ifdef QBT_IS_X64 !ifdef QBT_IS_X64
!include "x64.nsh" !include "x64.nsh"
!endif !endif
!include "3rdparty\VersionCompleteXXXX.nsi"
;For the file association ;For the file association
!define SHCNE_ASSOCCHANGED 0x8000000 !define SHCNE_ASSOCCHANGED 0x8000000
@ -42,27 +103,11 @@ XPStyle on
!define MUI_FINISHPAGE_RUN_FUNCTION PageFinishRun !define MUI_FINISHPAGE_RUN_FUNCTION PageFinishRun
!define MUI_FINISHPAGE_RUN_TEXT $(launch_qbt) !define MUI_FINISHPAGE_RUN_TEXT $(launch_qbt)
!ifndef QBT_IS_X64 ; The name of the installer
; The name of the installer Name "qBittorrent ${QBT_INSTALLER_WINDOWNAME}"
Name "qBittorrent ${QBT_VERSION}"
; The file to write
OutFile "qbittorrent_${QBT_VERSION}_setup.exe"
!else ; QBT_IS_X64
!ifndef QBT_USES_QT6
; The name of the installer
Name "qBittorrent ${QBT_VERSION} x64"
; The file to write
OutFile "qbittorrent_${QBT_VERSION}_x64_setup.exe"
!else ; QBT_USES_QT6
; The name of the installer
Name "qBittorrent ${QBT_VERSION} (qt6) x64"
; The file to write ; The file to write
OutFile "qbittorrent_${QBT_VERSION}_qt6_x64_setup.exe" OutFile "qbittorrent_${QBT_INSTALLER_FILENAME}_setup.exe"
!endif ; QBT_USES_QT6
!endif ; QBT_IS_X64
;Installer Version Information ;Installer Version Information
VIAddVersionKey "ProductName" "qBittorrent" VIAddVersionKey "ProductName" "qBittorrent"
@ -71,7 +116,10 @@ VIAddVersionKey "LegalCopyright" "Copyright ©2006-2022 The qBittorrent project"
VIAddVersionKey "FileDescription" "qBittorrent - A Bittorrent Client" VIAddVersionKey "FileDescription" "qBittorrent - A Bittorrent Client"
VIAddVersionKey "FileVersion" "${QBT_VERSION}" VIAddVersionKey "FileVersion" "${QBT_VERSION}"
VIProductVersion "${QBT_VERSION}.0" ; VIProductVersion needs a 4 part version.
; If QBT_VERSION contains less than 4 parts then VersionCompleteXXXX, will extend it with zeroes.
${VersionCompleteXXXX} ${QBT_VERSION} VERSION_4_PART
VIProductVersion "${VERSION_4_PART}"
; The default installation directory. It changes depending if we install in the 64bit dir or not. ; The default installation directory. It changes depending if we install in the 64bit dir or not.
; A caveat of this is if a user has installed a 32bit version and then runs the 64bit installer ; A caveat of this is if a user has installed a 32bit version and then runs the 64bit installer

2
dist/windows/installer.nsi vendored

@ -40,7 +40,7 @@ Section $(inst_qbt_req) ;"qBittorrent (required)"
WriteRegStr HKLM "Software\qBittorrent" "InstallLocation" "$INSTDIR" WriteRegStr HKLM "Software\qBittorrent" "InstallLocation" "$INSTDIR"
; Write the uninstall keys for Windows ; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "DisplayName" "qBittorrent ${QBT_VERSION}" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "DisplayName" "qBittorrent"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "UninstallString" '"$INSTDIR\uninst.exe"' WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "UninstallString" '"$INSTDIR\uninst.exe"'
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "DisplayIcon" '"$INSTDIR\qbittorrent.exe",0' WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "DisplayIcon" '"$INSTDIR\qbittorrent.exe",0'
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "Publisher" "The qBittorrent project" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "Publisher" "The qBittorrent project"

Loading…
Cancel
Save