From a29f10a5048a2421e33ab8934feec16e3f913081 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Wed, 11 May 2022 12:22:29 +0200 Subject: [PATCH] refactor build scipt to be easiert customizable --- dist/win/build.bat | 15 +++++++- dist/win/build.ps1 | 61 +++++++++++++++++--------------- dist/win/resources/main.wxs | 2 +- dist/win/resources/overrides.wxi | 1 - 4 files changed, 47 insertions(+), 32 deletions(-) diff --git a/dist/win/build.bat b/dist/win/build.bat index 8ca9183b4..84013ec1b 100644 --- a/dist/win/build.bat +++ b/dist/win/build.bat @@ -1,2 +1,15 @@ @echo off -powershell -NoLogo -NoExit -ExecutionPolicy Unrestricted -Command .\build.ps1 \ No newline at end of file +SET APPNAME="Cryptomator" +SET VENDOR="Skymatic GmbH" +SET FIRST_COPYRIGHT_YEAR=2016 +SET ABOUT_URL="https://cryptomator.org" +SET UPDATE_URL="https://cryptomator.org/downloads/" +SET HELP_URL="https://cryptomator.org/contact/" +powershell -NoLogo -NoExit -ExecutionPolicy Unrestricted -Command .\build.ps1^ + -AppName %APPNAME%^ + -Vendor "%VENDOR%"^ + -CopyrightStartYear %FIRST_COPYRIGHT_YEAR%^ + -AboutUrl "%ABOUT_URL%"^ + -HelpUrl "%HELP_URL%"^ + -UpdateUrl "%UPDATE_URL%"^ + -Clean 1 \ No newline at end of file diff --git a/dist/win/build.ps1 b/dist/win/build.ps1 index abecdef61..84900f9ff 100644 --- a/dist/win/build.ps1 +++ b/dist/win/build.ps1 @@ -1,5 +1,13 @@ -# check parameters -$clean = $args[0] -eq "fresh" +Param( + [Parameter(Mandatory, HelpMessage="Please provide a name for the app")][string] $AppName, + [Parameter(Mandatory, HelpMessage="Please provide a valud path to an icon file")][string] $IconPath, + [Parameter(Mandatory, HelpMessage="Please provide the name of the vendor")][string] $Vendor, + [Parameter(Mandatory, HelpMessage="Please provide the starting year for the copyright notice")][int] $CopyrightStartYear, + [Parameter(Mandatory, HelpMessage="Please provide a help url")][string] $HelpUrl, + [Parameter(Mandatory, HelpMessage="Please provide an update url")][string] $UpdateUrl, + [Parameter(Mandatory, HelpMessage="Please provide an about url")][string] $AboutUrl, + [bool] $clean +) # check preconditions if ((Get-Command "git" -ErrorAction SilentlyContinue) -eq $null) @@ -24,8 +32,7 @@ Write-Output "`$revisionNo=$revisionNo" Write-Output "`$buildDir=$buildDir" Write-Output "`$Env:JAVA_HOME=$Env:JAVA_HOME" -$vendor = "Skymatic GmbH" -$copyright = "(C) 2016 - 2022 Skymatic GmbH" +$copyright = "(C) $CopyrightStartYear - $((Get-Date).Year) $Vendor" # compile &mvn -B -f $buildDir/../../pom.xml clean package -DskipTests -Pwin @@ -48,7 +55,7 @@ if ($clean -and (Test-Path -Path $runtimeImagePath)) { --strip-debug ` --compress=1 -$appPath = '.\Cryptomator' +$appPath = ".\$AppName" if ($clean -and (Test-Path -Path $appPath)) { Remove-Item -Path $appPath -Force -Recurse } @@ -62,20 +69,20 @@ if ($clean -and (Test-Path -Path $appPath)) { --module-path ../../target/mods ` --module org.cryptomator.desktop/org.cryptomator.launcher.Cryptomator ` --dest . ` - --name Cryptomator ` - --vendor $vendor ` + --name $AppName ` + --vendor $Vendor ` --copyright $copyright ` --java-options "-Xss5m" ` --java-options "-Xmx256m" ` --java-options "-Dcryptomator.appVersion=`"$semVerNo`"" ` --app-version "$semVerNo.$revisionNo" ` --java-options "-Dfile.encoding=`"utf-8`"" ` - --java-options "-Dcryptomator.logDir=`"~/AppData/Roaming/Cryptomator`"" ` - --java-options "-Dcryptomator.pluginDir=`"~/AppData/Roaming/Cryptomator/Plugins`"" ` - --java-options "-Dcryptomator.settingsPath=`"~/AppData/Roaming/Cryptomator/settings.json`"" ` - --java-options "-Dcryptomator.ipcSocketPath=`"~/AppData/Roaming/Cryptomator/ipc.socket`"" ` - --java-options "-Dcryptomator.keychainPath=`"~/AppData/Roaming/Cryptomator/keychain.json`"" ` - --java-options "-Dcryptomator.mountPointsDir=`"~/Cryptomator`"" ` + --java-options "-Dcryptomator.logDir=`"~/AppData/Roaming/$AppName`"" ` + --java-options "-Dcryptomator.pluginDir=`"~/AppData/Roaming/$AppName/Plugins`"" ` + --java-options "-Dcryptomator.settingsPath=`"~/AppData/Roaming/$AppName/settings.json`"" ` + --java-options "-Dcryptomator.ipcSocketPath=`"~/AppData/Roaming/$AppName/ipc.socket`"" ` + --java-options "-Dcryptomator.keychainPath=`"~/AppData/Roaming/$AppName/keychain.json`"" ` + --java-options "-Dcryptomator.mountPointsDir=`"~/$AppName`"" ` --java-options "-Dcryptomator.showTrayIcon=true" ` --java-options "-Dcryptomator.buildNumber=`"msi-$revisionNo`"" ` --resource-dir resources ` @@ -92,12 +99,8 @@ if ($clean -and (Test-Path -Path $appPath)) { "-Dlicense.licenseMergesUrl=file:///$buildDir/../../license/merges" # patch app dir -Copy-Item "contrib\*" -Destination "Cryptomator" -attrib -r "Cryptomator\Cryptomator.exe" - -$aboutUrl="https://cryptomator.org" -$updateUrl="https://cryptomator.org/downloads/" -$helpUrl="https://cryptomator.org/contact/" +Copy-Item "contrib\*" -Destination "$AppName" +attrib -r "$AppName\$AppName.exe" # create .msi $Env:JP_WIXWIZARD_RESOURCES = "$buildDir\resources" @@ -107,18 +110,18 @@ $Env:JP_WIXWIZARD_RESOURCES = "$buildDir\resources" --win-upgrade-uuid bda45523-42b1-4cae-9354-a45475ed4775 ` --app-image Cryptomator ` --dest installer ` - --name Cryptomator ` - --vendor $vendor ` + --name $AppName ` + --vendor $Vendor ` --copyright $copyright ` --app-version "$semVerNo" ` --win-menu ` --win-dir-chooser ` --win-shortcut-prompt ` - --win-update-url $updateUrl ` - --win-menu-group Cryptomator ` + --win-menu-group $AppName ` --resource-dir resources ` - --about-url $aboutUrl ` --license-file resources/license.rtf ` + --win-update-url $UpdateUrl ` + --about-url $AboutUrl ` --file-associations resources/FAvaultFile.properties #Create RTF license for bundle @@ -139,14 +142,14 @@ Write-Output "Downloading ${winfspMsiUrl}..." Invoke-WebRequest $winfspMsiUrl -OutFile ".\bundle\resources\winfsp.msi" # redirects are followed by default # copy MSI to bundle resources -Copy-Item ".\installer\Cryptomator-*.msi" -Destination ".\bundle\resources\Cryptomator.msi" +Copy-Item ".\installer\$AppName-*.msi" -Destination ".\bundle\resources\$AppName.msi" # create bundle including winfsp & "$env:WIX\bin\candle.exe" .\bundle\bundleWithWinfsp.wxs -ext WixBalExtension -out bundle\ ` -dBundleVersion="$semVerNo.$revisionNo" ` - -dBundleVendor="$vendor" ` + -dBundleVendor="$Vendor" ` -dBundleCopyright="$copyright" ` - -dAboutUrl="$aboutUrl" ` - -dHelpUrl="$helpUrl" ` - -dUpdateUrl="$updateUrl" + -dAboutUrl="$AboutUrl" ` + -dHelpUrl="$HelpUrl" ` + -dUpdateUrl="$UpdateUrl" & "$env:WIX\bin\light.exe" -b . .\bundle\BundlewithWinfsp.wixobj -ext WixBalExtension -out installer\Cryptomator-Installer.exe \ No newline at end of file diff --git a/dist/win/resources/main.wxs b/dist/win/resources/main.wxs index 6df4439ab..26f968fbd 100644 --- a/dist/win/resources/main.wxs +++ b/dist/win/resources/main.wxs @@ -86,7 +86,7 @@ - + diff --git a/dist/win/resources/overrides.wxi b/dist/win/resources/overrides.wxi index 3328ccec2..41194fa05 100644 --- a/dist/win/resources/overrides.wxi +++ b/dist/win/resources/overrides.wxi @@ -31,7 +31,6 @@ Default value is `yes`. --> -