Skip to content

Commit

Permalink
support perUser and perMachine
Browse files Browse the repository at this point in the history
  • Loading branch information
gdams committed Apr 30, 2024
1 parent f7ca8d5 commit 18ec3e1
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 43 deletions.
4 changes: 1 addition & 3 deletions wix/Build.OpenJDK_generic.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ REM SKIP_MSI_VALIDATION=true (Add -sval option to light.exe to skip MSI/MSM vali
REM UPGRADE_CODE_SEED=thisIsAPrivateSecretSeed ( optional ) for upgradable MSI (If none, new PRODUCT_UPGRADE_CODE is generate for each run)
REM OUTPUT_BASE_FILENAME=customFileName (optional) for setting file names that are not based on the default naming convention
REM WIX_VERSION=5.0.0 (optional) for setting the version of Wix Toolset to use
REM INSTALL_SCOPE=perMachine|perUser (default is perMachine)

SETLOCAL ENABLEEXTENSIONS
SET ERR=0
Expand All @@ -40,7 +39,6 @@ IF NOT DEFINED PRODUCT_SUPPORT_LINK SET PRODUCT_SUPPORT_LINK=https://adoptium.ne
IF NOT DEFINED PRODUCT_UPDATE_INFO_LINK SET PRODUCT_UPDATE_INFO_LINK=https://adoptium.net/temurin/releases
IF NOT DEFINED WIX_HEAT_PATH SET WIX_HEAT_PATH=.\Resources\heat_dir\heat.exe
IF NOT DEFINED WIX_VERSION SET WIX_VERSION=5.0.0
IF NOT DEFINED INSTALL_SCOPE SET INSTALL_SCOPE=perMachine

powershell -ExecutionPolicy Bypass -File "%~dp0\helpers\Validate-Input.ps1" ^
-toValidate '%ARCH%' ^
Expand Down Expand Up @@ -166,7 +164,7 @@ FOR %%A IN (%ARCH%) DO (
REM Prevent concurrency issues if multiple builds are running in parallel.
SET OUTPUT_FILE=%WORKDIR%!OUTPUT_BASE_FILENAME!-!INPUT_FILE:.template=%!
ECHO string replacement input !INPUT_FILE! output !OUTPUT_FILE!
powershell -Command "(gc -Raw -encoding utf8 %%i) -replace '{vendor}', '!VENDOR!' -replace '{vendor_branding_logo}', '!VENDOR_BRANDING_LOGO!' -replace '{vendor_branding_banner}', '!VENDOR_BRANDING_BANNER!' -replace '{vendor_branding_dialog}', '!VENDOR_BRANDING_DIALOG!' -replace '{vendor_branding}', '!VENDOR_BRANDING!' -replace '{product_help_link}', '!PRODUCT_HELP_LINK!' -replace '{product_support_link}', '!PRODUCT_SUPPORT_LINK!' -replace '{product_update_info_link}', '!PRODUCT_UPDATE_INFO_LINK!' -replace '{InstallScope}', '!INSTALL_SCOPE!' | Out-File -encoding utf8 !OUTPUT_FILE!"
powershell -Command "(gc -Raw -encoding utf8 %%i) -replace '{vendor}', '!VENDOR!' -replace '{vendor_branding_logo}', '!VENDOR_BRANDING_LOGO!' -replace '{vendor_branding_banner}', '!VENDOR_BRANDING_BANNER!' -replace '{vendor_branding_dialog}', '!VENDOR_BRANDING_DIALOG!' -replace '{vendor_branding}', '!VENDOR_BRANDING!' -replace '{product_help_link}', '!PRODUCT_HELP_LINK!' -replace '{product_support_link}', '!PRODUCT_SUPPORT_LINK!' -replace '{product_update_info_link}', '!PRODUCT_UPDATE_INFO_LINK!' | Out-File -encoding utf8 !OUTPUT_FILE!"
IF ERRORLEVEL 1 (
ECHO Unable to make string replacement
GOTO FAILED
Expand Down
4 changes: 4 additions & 0 deletions wix/Lang/OpenJDK.Base.de-de.wxl.template
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@
<String Id="FeatureIcedTeaWebDescription" Value="Install the IcedTea-Web package" />
<String Id="FeatureJNLPFileRunWithTitle" Value="Associate .jnlp" />
<String Id="FeatureJNLPFileRunWithDescription" Value="Associate .jnlp files to run with IcedTea-Web" />
<String Id="CustomScopeDlgDescription" Value="Wählen Sie den Installationsbereich und Ordner" />
<String Id="CustomScopeDlgTitle" Value="{\WixUI_Font_Title}Installationsbereich" />
<String Id="CustomScopeDlgPerUser" Value="{\WixUI_Font_Emphasized}Nur für Sie installieren ([LogonUser])" />
<String Id="CustomScopeDlgPerMachine" Value="{\WixUI_Font_Emphasized}Für alle Benutzer dieses &amp;Computers installieren" />
</WixLocalization>
4 changes: 4 additions & 0 deletions wix/Lang/OpenJDK.Base.en-us.wxl.template
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@
<String Id="FeatureIcedTeaWebDescription" Value="Install the IcedTea-Web package" />
<String Id="FeatureJNLPFileRunWithTitle" Value="Associate .jnlp" />
<String Id="FeatureJNLPFileRunWithDescription" Value="Associate .jnlp files to run with IcedTea-Web" />
<String Id="CustomScopeDlgDescription" Value="Choose the installation scope and folder" />
<String Id="CustomScopeDlgTitle" Value="{\WixUI_Font_Title}Installation Scope" />
<String Id="CustomScopeDlgPerUser" Value="Install &amp;just for you ([LogonUser])" />
<String Id="CustomScopeDlgPerMachine" Value="Install for all users of this &amp;machine" />
</WixLocalization>
4 changes: 4 additions & 0 deletions wix/Lang/OpenJDK.Base.es-es.wxl.template
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@
<String Id="FeatureIcedTeaWebDescription" Value="Instalar el paquete IcedTea-Web" />
<String Id="FeatureJNLPFileRunWithTitle" Value="Asociar .jnlp" />
<String Id="FeatureJNLPFileRunWithDescription" Value="Asociar la extensión de fichero .jnlp con IcedTea-Web" />
<String Id="CustomScopeDlgDescription" Value="Elija el ámbito de instalación y la carpeta" />
<String Id="CustomScopeDlgTitle" Value="{\WixUI_Font_Title}Ámbito de la instalación" />
<String Id="CustomScopeDlgPerUser" Value="{\WixUI_Font_Emphasized}Instalar solo para usted ([LogonUser])" />
<String Id="CustomScopeDlgPerMachine" Value="{\WixUI_Font_Emphasized}Instalar para todos los usuarios de esta &amp;máquina" />
</WixLocalization>
4 changes: 4 additions & 0 deletions wix/Lang/OpenJDK.Base.fr-fr.wxl.template
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@
<String Id="FeatureIcedTeaWebDescription" Value="Install the IcedTea-Web package" />
<String Id="FeatureJNLPFileRunWithTitle" Value="Associate .jnlp" />
<String Id="FeatureJNLPFileRunWithDescription" Value="Associate .jnlp files to run with IcedTea-Web" />
<String Id="CustomScopeDlgDescription" Value="Choisissez le périmètre d'installation et le dossier" />
<String Id="CustomScopeDlgTitle" Value="{\WixUI_Font_Title}Portée de l'installation" />
<String Id="CustomScopeDlgPerUser" Value="{\WixUI_Font_Emphasized}Installer juste pour vous ([LogonUser])" />
<String Id="CustomScopeDlgPerMachine" Value="{\WixUI_Font_Emphasized}Installer pour tous les utilisateurs de cet &amp;ordinateur" />
</WixLocalization>
4 changes: 4 additions & 0 deletions wix/Lang/OpenJDK.Base.ja-jp.wxl.template
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@
<String Id="FeatureIcedTeaWebDescription" Value="Install the IcedTea-Web package" />
<String Id="FeatureJNLPFileRunWithTitle" Value="Associate .jnlp" />
<String Id="FeatureJNLPFileRunWithDescription" Value="Associate .jnlp files to run with IcedTea-Web" />
<String Id="CustomScopeDlgDescription" Value="Choose the installation scope and folder" />
<String Id="CustomScopeDlgTitle" Value="{\WixUI_Font_Title}Installation Scope" />
<String Id="CustomScopeDlgPerUser" Value="Install &amp;just for you ([LogonUser])" />
<String Id="CustomScopeDlgPerMachine" Value="Install for all users of this &amp;machine" />
</WixLocalization>
4 changes: 4 additions & 0 deletions wix/Lang/OpenJDK.Base.zh-cn.wxl.template
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@
<String Id="FeatureIcedTeaWebDescription" Value="Install the IcedTea-Web package" />
<String Id="FeatureJNLPFileRunWithTitle" Value="Associate .jnlp" />
<String Id="FeatureJNLPFileRunWithDescription" Value="Associate .jnlp files to run with IcedTea-Web" />
<String Id="CustomScopeDlgDescription" Value="Choose the installation scope and folder" />
<String Id="CustomScopeDlgTitle" Value="{\WixUI_Font_Title}Installation Scope" />
<String Id="CustomScopeDlgPerUser" Value="Install &amp;just for you ([LogonUser])" />
<String Id="CustomScopeDlgPerMachine" Value="Install for all users of this &amp;machine" />
</WixLocalization>
4 changes: 4 additions & 0 deletions wix/Lang/OpenJDK.Base.zh-tw.wxl.template
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@
<String Id="FeatureIcedTeaWebDescription" Value="Install the IcedTea-Web package" />
<String Id="FeatureJNLPFileRunWithTitle" Value="Associate .jnlp" />
<String Id="FeatureJNLPFileRunWithDescription" Value="Associate .jnlp files to run with IcedTea-Web" />
<String Id="CustomScopeDlgDescription" Value="Choose the installation scope and folder" />
<String Id="CustomScopeDlgTitle" Value="{\WixUI_Font_Title}Installation Scope" />
<String Id="CustomScopeDlgPerUser" Value="Install &amp;just for you ([LogonUser])" />
<String Id="CustomScopeDlgPerMachine" Value="Install for all users of this &amp;machine" />
</WixLocalization>
78 changes: 55 additions & 23 deletions wix/Main.wxs.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util" xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
<?include $(sys.CURRENTDIR)\Workdir\$(var.OutputBaseFilename)-$(var.ProductSku).Variables.wxi ?>

<Package Name="$(var.ProductNameWithVersion)" Language="$(var.ProductLanguage)" Version="$(var.ProductVersion)" Manufacturer="$(var.ProductManufacturer)" UpgradeCode="$(var.ProductUpgradeCode)" InstallerVersion="500" ProductCode="$(var.ProductId)" Scope="{InstallScope}">
<Package Name="$(var.ProductNameWithVersion)" Language="$(var.ProductLanguage)" Version="$(var.ProductVersion)" Manufacturer="$(var.ProductManufacturer)" UpgradeCode="$(var.ProductUpgradeCode)" InstallerVersion="500" ProductCode="$(var.ProductId)">
<SummaryInformation Description="$(var.PackageDescription)" Manufacturer="$(var.ProductManufacturer)" />
<MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeDenied)" />
<Media Id="1" Cabinet="Data1.cab" EmbedCab="yes" CompressionLevel="high" />
Expand Down Expand Up @@ -37,26 +37,28 @@
-->

<!-- Define the directory structure -->

<Property Id="ApplicationFolderName" Value="PerUserOrMachine-Example" />
<Property Id="WixAppFolder" Value="WixPerMachineFolder" />
<WixVariable Id="WixUISupportPerUser" Value="1" />
<WixVariable Id="WixUISupportPerMachine" Value="1" />

<!--
RemoveFolderEx requires that we "remember" the path for uninstall.
This workaround is only required for the uninstall.
-->
<Property Id="INSTALLDIR_PER_MACHINE">
<RegistrySearch Id="INSTALLDIR_REGSEARCH_HKLM" Root="HKLM" Key="SOFTWARE\$(var.ProductManufacturer)\$(var.ProductCategory)\$(var.ProductVersion)\$(var.JVM)\MSI" Name="Path" Type="raw" />
</Property>
<Property Id="INSTALLDIR_PER_USER">
<RegistrySearch Id="INSTALLDIR_REGSEARCH_HKCU" Root="HKCU" Key="SOFTWARE\$(var.ProductManufacturer)\$(var.ProductCategory)\$(var.ProductVersion)\$(var.JVM)\MSI" Name="Path" Type="raw" />
</Property>

<CustomAction Id="PerMachineInstall" Property="TARGETDIR" Value="[INSTALLDIR_PER_MACHINE]" Execute="immediate" />
<CustomAction Id="PerUserInstall" Property="TARGETDIR" Value="[INSTALLDIR_PER_USER]" Execute="immediate" />
<CustomAction Id="CustomSetDefaultPerUserFolder" Property="CustomWixPerUserFolder" Value="[LocalAppDataFolder]Programs\[ApplicationFolderName]" Execute="immediate" />
<CustomAction Id="CustomSetDefaultPerMachineFolder" Property="CustomWixPerMachineFolder" Value="[ProgramFiles64Folder][ApplicationFolderName]" Execute="immediate" />
<CustomAction Id="CustomSetPerUserFolder" Property="APPLICATIONFOLDER" Value="[CustomWixPerUserFolder]" Execute="immediate" />
<CustomAction Id="CustomSetPerMachineFolder" Property="APPLICATIONFOLDER" Value="[CustomWixPerMachineFolder]" Execute="immediate" />

<InstallExecuteSequence>
<Custom Action="PerMachineInstall" Before="CostFinalize" Condition="ALLUSERS=1 OR (ALLUSERS=2 AND Privileged)" />
<Custom Action="PerUserInstall" Before="CostFinalize" Condition="ALLUSERS=&quot;&quot; OR (ALLUSERS=2 AND (NOT Privileged))" />
<InstallExecuteSequence>
<Custom Action="CustomSetDefaultPerUserFolder" Before="CostFinalize" />
<Custom Action="CustomSetDefaultPerMachineFolder" After="CustomSetDefaultPerUserFolder" />
<Custom Action="CustomSetPerUserFolder" After="CustomSetDefaultPerMachineFolder" Condition='ACTION="INSTALL" AND (ALLUSERS="" OR ALLUSERS=0 OR (ALLUSERS=2 AND (NOT Privileged)))'/>
<Custom Action="CustomSetPerMachineFolder" After="CustomSetPerUserFolder" Condition='ACTION="INSTALL" AND (ALLUSERS=1 OR (ALLUSERS=2 AND Privileged))'/>
</InstallExecuteSequence>
<InstallUISequence>
<Custom Action="CustomSetDefaultPerUserFolder" Before="CostFinalize" />
<Custom Action="CustomSetDefaultPerMachineFolder" After="CustomSetDefaultPerUserFolder" />
<Custom Action="CustomSetPerUserFolder" After="CustomSetDefaultPerMachineFolder" Condition='ACTION="INSTALL" AND (ALLUSERS="" OR ALLUSERS=0 OR (ALLUSERS=2 AND (NOT Privileged)))'/>
<Custom Action="CustomSetPerMachineFolder" After="CustomSetPerUserFolder" Condition='ACTION="INSTALL" AND (ALLUSERS=1 OR (ALLUSERS=2 AND Privileged))'/>
</InstallUISequence>

<!-- Add the shortcuts to your installer package -->
<DirectoryRef Id="INSTALLDIR">
Expand Down Expand Up @@ -199,13 +201,43 @@
<WixVariable Id="WixUILicenseRtf" Value="$(var.SetupResourcesDir)\$(var.license)" />
<WixVariable Id="WixUIDialogBmp" Value="{vendor_branding_dialog}" />
<WixVariable Id="WixUIBannerBmp" Value="{vendor_branding_banner}" />

<UI>
<ui:WixUI Id="WixUI_FeatureTree" />
<?if $(var.license_shown)=0 ?>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="CustomizeDlg" Order="3" />
<!-- skip the page on the way back too -->
<Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="3" />
<?endif?>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg" Order="3" />
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="CustomInstallScopeDlg" Order="3" />

<Publish Dialog="CustomInstallScopeDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg" />
<Publish Dialog="CustomInstallScopeDlg" Control="Next" Event="DoAction" Value="CustomSetPerMachineFolder" Condition='WixAppFolder="WixPerMachineFolder"' Order="1"/>
<Publish Dialog="CustomInstallScopeDlg" Control="Next" Event="DoAction" Value="CustomSetPerUserFolder" Condition='WixAppFolder="WixPerUserFolder"' Order="2"/>
<Publish Dialog="CustomInstallScopeDlg" Control="Next" Property="ALLUSERS" Value="{}" Order="2" Condition='WixAppFolder = "WixPerUserFolder"' />
<Publish Dialog="CustomInstallScopeDlg" Control="Next" Property="ALLUSERS" Value="1" Order="3" Condition='WixAppFolder = "WixPerMachineFolder"' />
<Publish Dialog="CustomInstallScopeDlg" Control="Next" Property="MSIINSTALLPERUSER" Value="1" Order="2" Condition='WixAppFolder = "WixPerUserFolder"' />
<Publish Dialog="CustomInstallScopeDlg" Control="Next" Property="MSIINSTALLPERUSER" Value="{}" Order="3" Condition='WixAppFolder = "WixPerMachineFolder"' />
<Publish Dialog="CustomInstallScopeDlg" Control="Next" Event="NewDialog" Value="CustomizeDlg" Order="3"/>

<Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="CustomInstallScopeDlg" Order="3" />

<!-- Custom UI Banner to select perMachine or perUser install -->
<Dialog Id="CustomInstallScopeDlg" Width="370" Height="270" KeepModeless="yes" Title="[ProductName] Setup">
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallScopeDlgBannerBitmap)" />
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="20" Transparent="yes" NoPrefix="yes" Text="!(loc.CustomScopeDlgDescription)" />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="!(loc.CustomScopeDlgTitle)" />
<Control Id="BothScopes" Type="RadioButtonGroup" X="20" Y="55" Width="330" Height="40" Property="WixAppFolder">
<RadioButtonGroup Property="WixAppFolder">
<RadioButton Value="WixPerUserFolder" X="0" Y="0" Width="300" Height="17" Text="!(loc.CustomScopeDlgPerUser)" />
<RadioButton Value="WixPerMachineFolder" X="0" Y="20" Width="300" Height="17" Text="!(loc.CustomScopeDlgPerMachine)" />
</RadioButtonGroup>
</Control>
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)" />
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
<Publish Event="SpawnDialog" Value="CancelDlg"/>
</Control>
</Dialog>

</UI>

<?if $(env.Platform)=x86?>
Expand Down
3 changes: 1 addition & 2 deletions wix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ call powershell.exe ./CreateSourceFolder.AdoptOpenJDK.ps1 ^
set VENDOR_BRANDING_LOGO=$(var.SetupResourcesDir)\logo.ico
set VENDOR_BRANDING_BANNER=$(var.SetupResourcesDir)\wix-banner.png
set VENDOR_BRANDING_DIALOG=$(var.SetupResourcesDir)\wix-dialog.png
set OUTPUT_BASE_FILENAME=%PRODUCT_SKU%%PRODUCT_MAJOR_VERSION%-%PRODUCT_CATEGORY%_%FOLDER_PLATFORM%_windows_%PACKAGE_TYPE%-%PRODUCT_FULL_VERSION%
set INSTALL_SCOPE=perMachine | perUser | perUserOrMachine (default is 'perMachine', note that 'perUserOrMachine' has not been fully implemented in wix v4 or v5 yet)
set OUTPUT_BASE_FILENAME=%PRODUCT_SKU%%PRODUCT_MAJOR_VERSION%-%PRODUCT_CATEGORY%_%FOLDER_PLATFORM%_windows_%PACKAGE_TYPE%-%PRODUCT_FULL_VERSION%F
```

`Build.OpenJDK_generic.cmd` statically depends on this SDK version (edit if needed):
Expand Down
26 changes: 13 additions & 13 deletions wix/Resources/heat.icedteaweb.xslt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wix="http://wixtoolset.org/schemas/v4/wxl">
<xsl:output omit-xml-declaration="yes" indent="yes" />
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>

<xsl:template match="wix:Directory[@Name='bin']/@Id">
<xsl:attribute name="Id">IcedTeaWebBin</xsl:attribute>
</xsl:template>

</xsl:stylesheet>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wix="http://wixtoolset.org/schemas/v4/wxl">
<xsl:output omit-xml-declaration="yes" indent="yes" />
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>

<xsl:template match="wix:Directory[@Name='bin']/@Id">
<xsl:attribute name="Id">IcedTeaWebBin</xsl:attribute>
</xsl:template>

</xsl:stylesheet>
4 changes: 2 additions & 2 deletions wix/Resources/heat.tools.xslt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wix="http://wixtoolset.org/schemas/v4/wxl"
Expand Down Expand Up @@ -26,4 +26,4 @@
<!-- Remove the files -->
<xsl:template match="*[self::wix:Component or self::wix:ComponentRef]
[key('FileToRemove', @Id)]" />
</xsl:stylesheet>
</xsl:stylesheet>

0 comments on commit 18ec3e1

Please sign in to comment.