From 50371844cc5b01e221782a9ada247de8077b31d9 Mon Sep 17 00:00:00 2001 From: MTRNord Date: Mon, 2 Oct 2017 14:21:58 +0200 Subject: [PATCH] replace NSIS installer with QT Installer Framework 2 --- CMakeLists.txt | 3 +- appveyor.yml | 65 ++++++++++++++++++++++++--- cmake/QtCommon.cmake | 4 +- deploy/installer/config.xml | 15 +++++++ deploy/installer/controlscript.qs | 25 +++++++++++ deploy/installer/gui/installscript.qs | 22 +++++++++ deploy/installer/gui/package.xml | 14 ++++++ deploy/installer/uninstall.qs | 18 ++++++++ 8 files changed, 159 insertions(+), 7 deletions(-) create mode 100644 deploy/installer/config.xml create mode 100644 deploy/installer/controlscript.qs create mode 100644 deploy/installer/gui/installscript.qs create mode 100644 deploy/installer/gui/package.xml create mode 100644 deploy/installer/uninstall.qs diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f29bcd5..f67582aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,13 +2,14 @@ cmake_minimum_required(VERSION 3.1) option(BUILD_TESTS "Build all tests" OFF) option(APPVEYOR_BUILD "Build on appveyor" OFF) +option(WINDOWS_DEBUG "Build with debug window" OFF) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) # Include Qt basic functions include(QtCommon) -project(nheko LANGUAGES C CXX VERSION 1.0) +project(nheko LANGUAGES C CXX VERSION 0.0.1) # Set PROJECT_VERSION_PATCH and PROJECT_VERSION_TWEAK to 0 if not present, needed by add_project_meta fix_project_version() diff --git a/appveyor.yml b/appveyor.yml index b5625097..f7681b5c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,14 +15,34 @@ build: install: - set QT_DIR=C:\Qt\5.8\msvc2015_64 - set PATH=%PATH%;%QT_DIR%\bin;C:\MinGW\bin - - copy LICENSE .ci\windows\LICENSE.txt - - cinst nsis --version 3.0 -y -installArgs /D=C:\nsis build_script: - - cmake -G "Visual Studio 14 2015 Win64" -H. -Bbuild -DAPPVEYOR_BUILD=ON + # VERSION format: branch-master/branch-1.2 + # INSTVERSION format: x.y.z + # WINVERSION format: 9999.0.0.123/1.2.0.234 + - if "%APPVEYOR_REPO_TAG%"=="false" set INSTVERSION=0.0.1 + - if "%APPVEYOR_REPO_TAG%"=="false" set VERSION=%INSTVERSION% + - if "%APPVEYOR_REPO_TAG%"=="false" if "%APPVEYOR_REPO_BRANCH%"=="master" set INSTVERSION=9999.0 + - if "%APPVEYOR_REPO_TAG%"=="false" set WINVERSION=%INSTVERSION%.0.%APPVEYOR_BUILD_NUMBER% + # VERSION format: v1.2.3/v1.3.4 + # INSTVERSION format: 1.2.3/1.3.4 + # WINVERSION format: 1.2.3.123/1.3.4.234 + - if "%APPVEYOR_REPO_TAG%"=="true" set VERSION=%APPVEYOR_REPO_TAG_NAME% + - if "%APPVEYOR_REPO_TAG%"=="true" set INSTVERSION=%VERSION:~1% + - if "%APPVEYOR_REPO_TAG%"=="true" set WINVERSION=%VERSION:~1%.%APPVEYOR_BUILD_NUMBER% + - set DIST=nheko-%VERSION%-win64 + - set DATE=%date:~10,4%-%date:~4,2%-%date:~7,2% + - echo %VERSION% + - echo %INSTVERSION% + - echo %DIST% + - echo %DATE% + - cmake -G "Visual Studio 14 2015 Win64" -H. -Bbuild -DAPPVEYOR_BUILD=ON -DWINDOWS_DEBUG=ON - cmake --build build --config Release after_build: + # Variables + - set BUILD=%APPVEYOR_BUILD_FOLDER% + - echo %BUILD% - mkdir NhekoRelease - copy build\Release\nheko.exe NhekoRelease\nheko.exe - windeployqt --qmldir C:\Qt\5.8\msvc2015_64\qml\ --release NhekoRelease\nheko.exe @@ -31,9 +51,44 @@ after_build: - copy C:\OpenSSL-Win64\lib\libeay32.lib .\NhekoRelease\libeay32.lib - copy C:\OpenSSL-Win64\bin\ssleay32.dll .\NhekoRelease\ssleay32.dll - 7z a nheko_win_64.zip .\NhekoRelease\* - - C:\nsis\makensis .ci\windows\nheko.nsi + - ls -lh build\Release\ + - ls -lh NhekoRelease\ + - mkdir %DIST% + - xcopy .\NhekoRelease\*.* %DIST%\*.* /s /e /c /y + # + # Create the Qt Installer Framework version + # + - mkdir installer + - mkdir installer\config + - mkdir installer\packages + - mkdir installer\packages\com.mujx.nheko + - mkdir installer\packages\com.mujx.nheko\data + - mkdir installer\packages\com.mujx.nheko\meta + # Copy installer data + - copy %BUILD%\resources\nheko.ico installer\config + - copy %BUILD%\resources\nheko.png installer\config + - copy %BUILD%\LICENSE installer\packages\com.mujx.nheko\meta\license.txt + - copy %BUILD%\deploy\installer\config.xml installer\config + - copy %BUILD%\deploy\installer\controlscript.qs installer\config + - copy %BUILD%\deploy\installer\uninstall.qs installer\packages\com.mujx.nheko\data + - copy %BUILD%\deploy\installer\gui\package.xml installer\packages\com.mujx.nheko\meta + - copy %BUILD%\deploy\installer\gui\installscript.qs installer\packages\com.mujx.nheko\meta + # Amend version and date + - sed -i "s/__VERSION__/%INSTVERSION%/" installer\config\config.xml + - sed -i "s/__VERSION__/%INSTVERSION%/" installer\packages\com.mujx.nheko\meta\package.xml + - sed -i "s/__VERSION__/%INSTVERSION%/" installer\packages\com.mujx.nheko\meta\package.xml + - sed -i "s/__DATE__/%DATE%/" installer\packages\com.mujx.nheko\meta\package.xml + - sed -i "s/__DATE__/%DATE%/" installer\packages\com.mujx.nheko\meta\package.xml + # Copy nheko data + - xcopy %DIST%\*.* installer\packages\com.mujx.nheko\data\*.* /s /e /c /y + - move NhekoRelease\nheko.exe installer\packages\com.mujx.nheko\data + - mkdir tools + - curl -L -O https://download.qt.io/official_releases/qt-installer-framework/3.0.1/QtInstallerFramework-win-x86.exe + - 7z x QtInstallerFramework-win-x86.exe -otools -aoa + - set PATH=%BUILD%\tools\bin;%PATH% + - binarycreator.exe -f -c installer\config\config.xml -p installer\packages %DIST%-installer.exe artifacts: - path: nheko_win_64.zip - path: NhekoRelease\nheko.exe - - path: nheko_setup.exe + - path: .\%DIST%-installer.exe diff --git a/cmake/QtCommon.cmake b/cmake/QtCommon.cmake index bdc99456..0725509f 100644 --- a/cmake/QtCommon.cmake +++ b/cmake/QtCommon.cmake @@ -57,7 +57,9 @@ macro(init_os_bundle) if (APPLE) set(OS_BUNDLE MACOSX_BUNDLE) elseif (WIN32) - set(OS_BUNDLE WIN32) + if(NOT WINDOWS_DEBUG) + set(OS_BUNDLE WIN32) + endif() endif() endmacro() diff --git a/deploy/installer/config.xml b/deploy/installer/config.xml new file mode 100644 index 00000000..2cf7d99c --- /dev/null +++ b/deploy/installer/config.xml @@ -0,0 +1,15 @@ + + + Nheko + __VERSION__ + Nheko Installer + Mujx + https://github.com/mujx/nheko + nheko + nheko + nheko.png + Nheko + @ApplicationsDir@/nheko + @TargetDir@/nheko.exe + controlscript.qs + diff --git a/deploy/installer/controlscript.qs b/deploy/installer/controlscript.qs new file mode 100644 index 00000000..a53c3e99 --- /dev/null +++ b/deploy/installer/controlscript.qs @@ -0,0 +1,25 @@ +/** + * Source: http://stackoverflow.com/questions/21389105/qt-installer-framework-offline-update-how + */ + +function Controller() +{ +} + +Controller.prototype.TargetDirectoryPageCallback = function() +{ + var widget = gui.currentPageWidget(); + widget.TargetDirectoryLineEdit.textChanged.connect( this, Controller.prototype.targetChanged ); + Controller.prototype.targetChanged( widget.TargetDirectoryLineEdit.text ); +} + +Controller.prototype.targetChanged = function( text ) +{ + if( text != "" && installer.fileExists(text + "/components.xml") ) + { + if( QMessageBox.question("PreviousInstallation", "Previous installation detected", "Do you want to uninstall the previous installation?", QMessageBox.Yes | QMessageBox.No) == QMessageBox.Yes ) + { + installer.execute( text+"/maintenancetool.exe", new Array("--script", text+"/uninstall.qs") ) + } + } +} diff --git a/deploy/installer/gui/installscript.qs b/deploy/installer/gui/installscript.qs new file mode 100644 index 00000000..4411a0d9 --- /dev/null +++ b/deploy/installer/gui/installscript.qs @@ -0,0 +1,22 @@ +function Component() +{ +} + +Component.prototype.createOperations = function() +{ + component.createOperations(); + + try + { + if( installer.value("os") === "win" ) + { + component.addOperation( "CreateShortcut", "@TargetDir@\\nheko.exe", "@StartMenuDir@\\nheko.lnk", + "workingDirectory=@TargetDir@", "iconPath=@TargetDir@\\nheko.exe", + "iconId=0", "description=Desktop client for the Matrix protocol"); + } + } + catch( e ) + { + print( e ); + } +} diff --git a/deploy/installer/gui/package.xml b/deploy/installer/gui/package.xml new file mode 100644 index 00000000..8993c63d --- /dev/null +++ b/deploy/installer/gui/package.xml @@ -0,0 +1,14 @@ + + + Nheko + Desktop client for the Matrix protocol + __VERSION__ + __DATE__ + + + + true + true + 100 + + diff --git a/deploy/installer/uninstall.qs b/deploy/installer/uninstall.qs new file mode 100644 index 00000000..43935d0f --- /dev/null +++ b/deploy/installer/uninstall.qs @@ -0,0 +1,18 @@ +function Controller() +{ +} + +Controller.prototype.IntroductionPageCallback = function() +{ + gui.clickButton( buttons.NextButton ); +} + +Controller.prototype.ReadyForInstallationPageCallback = function() +{ + gui.clickButton( buttons.CommitButton ); +} + +Controller.prototype.FinishedPageCallback = function() +{ + gui.clickButton( buttons.FinishButton ); +}