Skip to content

Commit

Permalink
Improve NSIS scripts
Browse files Browse the repository at this point in the history
* Improve NSIS scripts
* CI: Create installer for Windows build artifacts

PR #19728.
  • Loading branch information
glassez authored Oct 20, 2023
1 parent 8d5022c commit 9de32a7
Show file tree
Hide file tree
Showing 72 changed files with 843 additions and 307 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ core.eol=lf
*.qm binary
*.zip binary

dist/windows/license.txt text eol=crlf
test/testdata/crlf.txt text eol=crlf
58 changes: 35 additions & 23 deletions .github/workflows/ci_windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,30 +116,31 @@ jobs:
- name: Prepare build artifacts
run: |
mkdir upload
copy build/qbittorrent.exe upload
copy build/qbittorrent.pdb upload
copy dist/windows/qt.conf upload
mkdir upload/qBittorrent
copy build/qbittorrent.exe upload/qBittorrent
copy build/qbittorrent.pdb upload/qBittorrent
copy dist/windows/qt.conf upload/qBittorrent
# runtimes
copy "${{ env.Qt6_DIR }}/bin/Qt6Core.dll" upload
copy "${{ env.Qt6_DIR }}/bin/Qt6Gui.dll" upload
copy "${{ env.Qt6_DIR }}/bin/Qt6Network.dll" upload
copy "${{ env.Qt6_DIR }}/bin/Qt6Sql.dll" upload
copy "${{ env.Qt6_DIR }}/bin/Qt6Svg.dll" upload
copy "${{ env.Qt6_DIR }}/bin/Qt6Widgets.dll" upload
copy "${{ env.Qt6_DIR }}/bin/Qt6Xml.dll" upload
mkdir upload/plugins/iconengines
copy "${{ env.Qt6_DIR }}/plugins/iconengines/qsvgicon.dll" upload/plugins/iconengines
mkdir upload/plugins/imageformats
copy "${{ env.Qt6_DIR }}/plugins/imageformats/qico.dll" upload/plugins/imageformats
copy "${{ env.Qt6_DIR }}/plugins/imageformats/qsvg.dll" upload/plugins/imageformats
mkdir upload/plugins/platforms
copy "${{ env.Qt6_DIR }}/plugins/platforms/qwindows.dll" upload/plugins/platforms
mkdir upload/plugins/sqldrivers
copy "${{ env.Qt6_DIR }}/plugins/sqldrivers/qsqlite.dll" upload/plugins/sqldrivers
mkdir upload/plugins/styles
copy "${{ env.Qt6_DIR }}/plugins/styles/qwindowsvistastyle.dll" upload/plugins/styles
mkdir upload/plugins/tls
copy "${{ env.Qt6_DIR }}/plugins/tls/qschannelbackend.dll" upload/plugins/tls
copy "${{ env.Qt6_DIR }}/bin/Qt6Core.dll" upload/qBittorrent
copy "${{ env.Qt6_DIR }}/bin/Qt6Gui.dll" upload/qBittorrent
copy "${{ env.Qt6_DIR }}/bin/Qt6Network.dll" upload/qBittorrent
copy "${{ env.Qt6_DIR }}/bin/Qt6Sql.dll" upload/qBittorrent
copy "${{ env.Qt6_DIR }}/bin/Qt6Svg.dll" upload/qBittorrent
copy "${{ env.Qt6_DIR }}/bin/Qt6Widgets.dll" upload/qBittorrent
copy "${{ env.Qt6_DIR }}/bin/Qt6Xml.dll" upload/qBittorrent
mkdir upload/qBittorrent/plugins/iconengines
copy "${{ env.Qt6_DIR }}/plugins/iconengines/qsvgicon.dll" upload/qBittorrent/plugins/iconengines
mkdir upload/qBittorrent/plugins/imageformats
copy "${{ env.Qt6_DIR }}/plugins/imageformats/qico.dll" upload/qBittorrent/plugins/imageformats
copy "${{ env.Qt6_DIR }}/plugins/imageformats/qsvg.dll" upload/qBittorrent/plugins/imageformats
mkdir upload/qBittorrent/plugins/platforms
copy "${{ env.Qt6_DIR }}/plugins/platforms/qwindows.dll" upload/qBittorrent/plugins/platforms
mkdir upload/qBittorrent/plugins/sqldrivers
copy "${{ env.Qt6_DIR }}/plugins/sqldrivers/qsqlite.dll" upload/qBittorrent/plugins/sqldrivers
mkdir upload/qBittorrent/plugins/styles
copy "${{ env.Qt6_DIR }}/plugins/styles/qwindowsvistastyle.dll" upload/qBittorrent/plugins/styles
mkdir upload/qBittorrent/plugins/tls
copy "${{ env.Qt6_DIR }}/plugins/tls/qschannelbackend.dll" upload/qBittorrent/plugins/tls
# cmake additionals
mkdir upload/cmake
copy build/compile_commands.json upload/cmake
Expand All @@ -152,3 +153,14 @@ jobs:
with:
name: qBittorrent-CI_Windows-x64_libtorrent-${{ matrix.libt_version }}
path: upload

- name: Create installer
run: |
7z x -o"dist/windows/" "dist/windows/NSISPlugins.zip"
makensis /DQBT_DIST_DIR="../../upload/qBittorrent" dist/windows/qbittorrent.nsi
- name: Upload installer
uses: actions/upload-artifact@v3
with:
name: qBittorrent-CI_Windows-x64_libtorrent-${{ matrix.libt_version }}-setup
path: dist/windows/qbittorrent_*_setup.exe
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ repos:
(?x)^(
src/webui/www/private/css/lib/.* |
src/webui/www/private/scripts/lib/.* |
dist/windows/license.txt |
test/testdata/crlf.txt
)$
Expand Down
Binary file added dist/windows/NSISPlugins.zip
Binary file not shown.
56 changes: 25 additions & 31 deletions dist/windows/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,46 +21,40 @@ You will need NSIS 3 to make the installer. UPX is an optional requirement.
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.
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).
Only the *.dll files are needed. Use the unicode version of the dlls.
3. Extract "NSISPlugins.zip" next to "qbittorrent.nsi" script or into your
NSIS's unicode Plugin directory (usually "C:\Program Files\NSIS\Plugins\x86-unicode").
4. The script you need to compile is "qbittorrent.nsi". It includes all other necessary scripts.
5. The script expects the following file tree:

The installer script expects the following file tree:

Root:
installer-translations
afrikaans.nsi
....
(all the .nsi files found here in every source release)
welsh.nsi
translations
qt_ar.qm
...
(All the .qm files found in the 'translations' folder of your Qt install. Those files differ between Qt5 and Qt6.
You will need the files that conform to this globbing expression 'qt_??.qm qt_??_??.qm qtbase_??.qm qtbase_??_??.qm'.
Some of those files will be stubs. Filter any file that is smaller than 10KB in size.
Alternatively you can use the 'gather_qt_translations.py' script found in the same folder as this file.
Run it with '--help' to see its usage.)
qt_zh_TW.qm
installer.nsi
afrikaans.nsh
....
(all the .nsh files found here in every source release)
welsh.nsh
installer.nsh
license.txt
config.nsi
helper.nsi
qbittorrent.exe
qbittorrent.pdb
config.nsh
qbittorrent.nsi
qt.conf
translations.nsi
translations.nsh
UAC.nsh
uninstaller.nsi

uninstaller.nsh
qBittorrent
qbittorrent.exe (required)
qbittorrent.pdb (optional but recommended)
translations (optional)
qt_ar.qm
..
(All the .qm files found in the 'translations' folder of your Qt install. Those files differ between Qt5 and Qt6.
You will need the files that conform to this globbing expression 'qt_??.qm qt_??_??.qm qtbase_??.qm qtbase_??_??.qm'.
Some of those files will be stubs. Filter any file that is smaller than 10KB in size.
Alternatively you can use the 'gather_qt_translations.py' script found in the same folder as this file.
Run it with '--help' to see its usage.)
qt_zh_TW.qm
(Any other files including the ones from all subdirectories will be also included in the installer.)

6. "license.txt" is a text file that contains the text rendered
from src\gui\gpl.html
7. "qbittorrent.exe" is the compiled binary file.
8. "qbittorrent.pdb" is the compiled binary's PDB file.
6. "qbittorrent.exe" is the compiled binary file.
7. "qbittorrent.pdb" is the compiled binary's PDB file.

SCRIPT HACKERS:

Expand Down
65 changes: 17 additions & 48 deletions dist/windows/config.nsi → dist/windows/config.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@
; Doing so may make antivirus software flag the installer as virus/malware
;!define USE_UPX

; Uncomment when packaging 64bit qbittorrent
;!define QBT_IS_X64

; Uncomment when packaging qt6 qbittorrent
; It will also define QBT_IS_X64
;!define QBT_USES_QT6

!ifdef QBT_USES_QT6
!define /redef QBT_IS_X64
!endif

; qBittorrent version
; The string MUST contain ONLY numbers delimited by dots.
; It MUST contain a maximum of 4 delimited numbers
Expand All @@ -25,20 +14,20 @@
; 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 "5.0.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 not set, the window name will be auto composed from QBT_VERSION
; 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 not set, the installer filename will be auto composed from QBT_VERSION
; 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
Expand All @@ -47,29 +36,16 @@
;==============================================================================

!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
; The name of the installer
!define QBT_INSTALLER_WINDOWNAME "${QBT_VERSION} x64"

; The file to write
!define QBT_INSTALLER_FILENAME "${QBT_VERSION}_x64"
!endif

!define /ifndef QBT_DIST_DIR "qBittorrent"
!define /ifndef QBT_NSIS_PLUGINS_DIR "NSISPlugins"

Unicode true
ManifestDPIAware true

Expand All @@ -86,9 +62,7 @@ XPStyle on
!include "UAC.nsh"
!include "FileFunc.nsh"
!include "WinVer.nsh"
!ifdef QBT_IS_X64
!include "x64.nsh"
!endif
!include "3rdparty\VersionCompleteXXXX.nsi"

;For the file association
Expand Down Expand Up @@ -121,15 +95,8 @@ VIAddVersionKey "FileVersion" "${QBT_VERSION}"
${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.
; A caveat of this is if a user has installed a 32bit version and then runs the 64bit installer
; (which in turn launches the 32bit uninstaller first) the value will still point to the 32bit location.
; The user has to manually uninstall the old version and THEN run the 64bit installer
!ifndef QBT_IS_X64
InstallDir $PROGRAMFILES32\qBittorrent
!else
InstallDir $PROGRAMFILES64\qBittorrent
!endif
; The default installation directory.
InstallDir $PROGRAMFILES64\qBittorrent

; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
Expand Down Expand Up @@ -171,8 +138,10 @@ RequestExecutionLevel user
!insertmacro MUI_UNPAGE_INSTFILES

!insertmacro MUI_RESERVEFILE_LANGDLL
ReserveFile "${NSISDIR}\Plugins\x86-unicode\FindProcDLL.dll"
ReserveFile "${NSISDIR}\Plugins\x86-unicode\UAC.dll"

!addplugindir /x86-unicode "${QBT_NSIS_PLUGINS_DIR}"
ReserveFile /plugin FindProcDLL.dll
ReserveFile /plugin UAC.dll

!macro Init thing
uac_tryagain:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ LangString inst_unist ${LANG_AFRIKAANS} "Uninstalling previous version."
LangString launch_qbt ${LANG_AFRIKAANS} "Launch qBittorrent."
;LangString inst_requires_64bit ${LANG_ENGLISH} "This installer works only in 64-bit Windows versions."
LangString inst_requires_64bit ${LANG_AFRIKAANS} "This installer works only in 64-bit Windows versions."
;LangString inst_requires_win7 ${LANG_ENGLISH} "This qBittorrent version requires at least Windows 7."
LangString inst_requires_win7 ${LANG_AFRIKAANS} "This qBittorrent version requires at least Windows 7."
;LangString inst_requires_win10 ${LANG_ENGLISH} "This installer requires at least Windows 10 1809."
LangString inst_requires_win10 ${LANG_AFRIKAANS} "This installer requires at least Windows 10 1809."
;LangString inst_uninstall_link_description ${LANG_ENGLISH} "Uninstall qBittorrent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ LangString inst_unist ${LANG_ARABIC} "جاري ازالة النسخة السا
LangString launch_qbt ${LANG_ARABIC} "تشغيل البرنامج"
;LangString inst_requires_64bit ${LANG_ENGLISH} "This installer works only in 64-bit Windows versions."
LangString inst_requires_64bit ${LANG_ARABIC} "هذا المثبت يعمل فقط في نسخ ويندوز 64 بت"
;LangString inst_requires_win7 ${LANG_ENGLISH} "This qBittorrent version requires at least Windows 7."
LangString inst_requires_win7 ${LANG_ARABIC} "This qBittorrent version requires at least Windows 7."
;LangString inst_requires_win10 ${LANG_ENGLISH} "This installer requires at least Windows 10 1809."
LangString inst_requires_win10 ${LANG_ARABIC} "This installer requires at least Windows 10 1809."
;LangString inst_uninstall_link_description ${LANG_ENGLISH} "Uninstall qBittorrent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ LangString inst_unist ${LANG_BASQUE} "Aurreko bertsioa kentzen."
LangString launch_qbt ${LANG_BASQUE} "Abiarazi qBittorrent."
;LangString inst_requires_64bit ${LANG_ENGLISH} "This installer works only in 64-bit Windows versions."
LangString inst_requires_64bit ${LANG_BASQUE} "This installer works only in 64-bit Windows versions."
;LangString inst_requires_win7 ${LANG_ENGLISH} "This qBittorrent version requires at least Windows 7."
LangString inst_requires_win7 ${LANG_BASQUE} "This qBittorrent version requires at least Windows 7."
;LangString inst_requires_win10 ${LANG_ENGLISH} "This installer requires at least Windows 10 1809."
LangString inst_requires_win10 ${LANG_BASQUE} "This installer requires at least Windows 10 1809."
;LangString inst_uninstall_link_description ${LANG_ENGLISH} "Uninstall qBittorrent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ LangString inst_unist ${LANG_BELARUSIAN} "Uninstalling previous version."
LangString launch_qbt ${LANG_BELARUSIAN} "Launch qBittorrent."
;LangString inst_requires_64bit ${LANG_ENGLISH} "This installer works only in 64-bit Windows versions."
LangString inst_requires_64bit ${LANG_BELARUSIAN} "This installer works only in 64-bit Windows versions."
;LangString inst_requires_win7 ${LANG_ENGLISH} "This qBittorrent version requires at least Windows 7."
LangString inst_requires_win7 ${LANG_BELARUSIAN} "This qBittorrent version requires at least Windows 7."
;LangString inst_requires_win10 ${LANG_ENGLISH} "This installer requires at least Windows 10 1809."
LangString inst_requires_win10 ${LANG_BELARUSIAN} "This installer requires at least Windows 10 1809."
;LangString inst_uninstall_link_description ${LANG_ENGLISH} "Uninstall qBittorrent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ LangString inst_unist ${LANG_BOSNIAN} "Uninstalling previous version."
LangString launch_qbt ${LANG_BOSNIAN} "Launch qBittorrent."
;LangString inst_requires_64bit ${LANG_ENGLISH} "This installer works only in 64-bit Windows versions."
LangString inst_requires_64bit ${LANG_BOSNIAN} "This installer works only in 64-bit Windows versions."
;LangString inst_requires_win7 ${LANG_ENGLISH} "This qBittorrent version requires at least Windows 7."
LangString inst_requires_win7 ${LANG_BOSNIAN} "This qBittorrent version requires at least Windows 7."
;LangString inst_requires_win10 ${LANG_ENGLISH} "This installer requires at least Windows 10 1809."
LangString inst_requires_win10 ${LANG_BOSNIAN} "This installer requires at least Windows 10 1809."
;LangString inst_uninstall_link_description ${LANG_ENGLISH} "Uninstall qBittorrent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ LangString inst_unist ${LANG_BRETON} "Uninstalling previous version."
LangString launch_qbt ${LANG_BRETON} "Launch qBittorrent."
;LangString inst_requires_64bit ${LANG_ENGLISH} "This installer works only in 64-bit Windows versions."
LangString inst_requires_64bit ${LANG_BRETON} "This installer works only in 64-bit Windows versions."
;LangString inst_requires_win7 ${LANG_ENGLISH} "This qBittorrent version requires at least Windows 7."
LangString inst_requires_win7 ${LANG_BRETON} "This qBittorrent version requires at least Windows 7."
;LangString inst_requires_win10 ${LANG_ENGLISH} "This installer requires at least Windows 10 1809."
LangString inst_requires_win10 ${LANG_BRETON} "This installer requires at least Windows 10 1809."
;LangString inst_uninstall_link_description ${LANG_ENGLISH} "Uninstall qBittorrent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ LangString inst_unist ${LANG_BULGARIAN} "Uninstalling previous version."
LangString launch_qbt ${LANG_BULGARIAN} "Launch qBittorrent."
;LangString inst_requires_64bit ${LANG_ENGLISH} "This installer works only in 64-bit Windows versions."
LangString inst_requires_64bit ${LANG_BULGARIAN} "This installer works only in 64-bit Windows versions."
;LangString inst_requires_win7 ${LANG_ENGLISH} "This qBittorrent version requires at least Windows 7."
LangString inst_requires_win7 ${LANG_BULGARIAN} "This qBittorrent version requires at least Windows 7."
;LangString inst_requires_win10 ${LANG_ENGLISH} "This installer requires at least Windows 10 1809."
LangString inst_requires_win10 ${LANG_BULGARIAN} "This installer requires at least Windows 10 1809."
;LangString inst_uninstall_link_description ${LANG_ENGLISH} "Uninstall qBittorrent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ LangString inst_unist ${LANG_CATALAN} "Uninstalling previous version."
LangString launch_qbt ${LANG_CATALAN} "Launch qBittorrent."
;LangString inst_requires_64bit ${LANG_ENGLISH} "This installer works only in 64-bit Windows versions."
LangString inst_requires_64bit ${LANG_CATALAN} "This installer works only in 64-bit Windows versions."
;LangString inst_requires_win7 ${LANG_ENGLISH} "This qBittorrent version requires at least Windows 7."
LangString inst_requires_win7 ${LANG_CATALAN} "This qBittorrent version requires at least Windows 7."
;LangString inst_requires_win10 ${LANG_ENGLISH} "This installer requires at least Windows 10 1809."
LangString inst_requires_win10 ${LANG_CATALAN} "This installer requires at least Windows 10 1809."
;LangString inst_uninstall_link_description ${LANG_ENGLISH} "Uninstall qBittorrent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ LangString inst_unist ${LANG_CROATIAN} "Deinstaliraj prethodnu verziju."
LangString launch_qbt ${LANG_CROATIAN} "Pokreni qBittorrent."
;LangString inst_requires_64bit ${LANG_ENGLISH} "This installer works only in 64-bit Windows versions."
LangString inst_requires_64bit ${LANG_CROATIAN} "This installer works only in 64-bit Windows versions."
;LangString inst_requires_win7 ${LANG_ENGLISH} "This qBittorrent version requires at least Windows 7."
LangString inst_requires_win7 ${LANG_CROATIAN} "This qBittorrent version requires at least Windows 7."
;LangString inst_requires_win10 ${LANG_ENGLISH} "This installer requires at least Windows 10 1809."
LangString inst_requires_win10 ${LANG_CROATIAN} "This installer requires at least Windows 10 1809."
;LangString inst_uninstall_link_description ${LANG_ENGLISH} "Uninstall qBittorrent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ LangString inst_unist ${LANG_CZECH} "Odinstalace předchozí verze."
LangString launch_qbt ${LANG_CZECH} "Spustit qBittorrent."
;LangString inst_requires_64bit ${LANG_ENGLISH} "This installer works only in 64-bit Windows versions."
LangString inst_requires_64bit ${LANG_CZECH} "Tento instalátor funguje pouze v 64-bit Windows."
;LangString inst_requires_win7 ${LANG_ENGLISH} "This qBittorrent version requires at least Windows 7."
LangString inst_requires_win7 ${LANG_CZECH} "Tato verze qBittorrent vyžaduje minimálně Windows 7."
;LangString inst_requires_win10 ${LANG_ENGLISH} "This installer requires at least Windows 10 1809."
LangString inst_requires_win10 ${LANG_CZECH} "This installer requires at least Windows 10 1809."
;LangString inst_uninstall_link_description ${LANG_ENGLISH} "Uninstall qBittorrent"
Expand Down
Loading

0 comments on commit 9de32a7

Please sign in to comment.