8214564: --win-upgrade-uuid does not work as expected
Submitten-by: almatvee
Reviewed-by: herrick, ihse
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/BundlerParamInfo.java Tue Feb 12 11:54:56 2019 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/BundlerParamInfo.java Tue Feb 12 11:58:41 2019 -0500
@@ -51,11 +51,16 @@
String id;
/**
- * Type of the parameter.
+ * Type of the parameter
*/
Class<T> valueType;
/**
+ * Indicates if value was set using default value function
+ */
+ boolean isDefaultValue;
+
+ /**
* If the value is not set, and no fallback value is found,
* the parameter uses the value returned by the producer.
*/
@@ -94,6 +99,10 @@
this.valueType = valueType;
}
+ boolean getIsDefaultValue() {
+ return isDefaultValue;
+ }
+
Function<Map<String, ? super Object>, T> getDefaultValueFunction() {
return defaultValueFunction;
}
@@ -144,6 +153,7 @@
T result = getDefaultValueFunction().apply(params);
if (result != null) {
params.put(getID(), result);
+ isDefaultValue = true;
}
return result;
}
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiBundler.java Tue Feb 12 11:54:56 2019 -0500
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiBundler.java Tue Feb 12 11:58:41 2019 -0500
@@ -576,6 +576,7 @@
data.put("PRODUCT_GUID", productGUID.toString());
data.put("PRODUCT_UPGRADE_GUID",
UPGRADE_UUID.fetchFrom(params).toString());
+ data.put("UPGRADE_BLOCK", getUpgradeBlock(params));
data.put("APPLICATION_NAME", APP_NAME.fetchFrom(params));
data.put("APPLICATION_DESCRIPTION", DESCRIPTION.fetchFrom(params));
@@ -660,7 +661,6 @@
private int id;
private int compId;
private final static String LAUNCHER_ID = "LauncherId";
- private final static String LAUNCHER_SVC_ID = "LauncherSvcId";
/**
* Overrides the dialog sequence in built-in dialog set "WixUI_InstallDir"
@@ -676,6 +676,19 @@
+ " Order=\"2\"> 1"
+ " </Publish>\n";
+ // Required upgrade element for installers which support major upgrade (when user
+ // specifies --win-upgrade-uuid). We will allow downgrades.
+ private static final String UPGRADE_BLOCK =
+ "<MajorUpgrade AllowDowngrades=\"yes\"/>";
+
+ private String getUpgradeBlock(Map<String, ? super Object> params) {
+ if (UPGRADE_UUID.getIsDefaultValue()) {
+ return "";
+ } else {
+ return UPGRADE_BLOCK;
+ }
+ }
+
/**
* Creates UI element using WiX built-in dialog sets
* - WixUI_InstallDir/WixUI_Minimal.
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/template.jre.wxs Tue Feb 12 11:54:56 2019 -0500
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/template.jre.wxs Tue Feb 12 11:58:41 2019 -0500
@@ -1,28 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
- <Product Id="PRODUCT_GUID" Name="APPLICATION_NAME"
+ <Product Id="PRODUCT_GUID" Name="APPLICATION_NAME"
Language="1033" Version="APPLICATION_VERSION"
- Manufacturer="APPLICATION_VENDOR"
+ Manufacturer="APPLICATION_VENDOR"
UpgradeCode="PRODUCT_UPGRADE_GUID">
<Package Description="APPLICATION_DESCRIPTION" Comments="None"
InstallerVersion="200" Compressed="yes"
InstallScope="INSTALL_SCOPE" Platform="PLATFORM"/>
<Media Id="1" Cabinet="simple.cab" EmbedCab="yes" />
+UPGRADE_BLOCK
- <!-- We use RemoveFolderEx to ensure application folder is fully
+ <!-- We use RemoveFolderEx to ensure application folder is fully
removed on uninstall. Including files created outside of MSI
after application had been installed (e.g. on AU or user state).
-
- Hovewer, RemoveFolderEx is only available in WiX 3.6,
+
+ Hovewer, RemoveFolderEx is only available in WiX 3.6,
we will comment it out if we running older WiX.
RemoveFolderEx requires that we "remember" the path for uninstall.
Read the path value and set the APPLICATIONFOLDER property with the value.
-->
<Property Id="APPLICATIONFOLDER">
- <RegistrySearch Key="SOFTWARE\APPLICATION_VENDOR\APPLICATION_NAME"
- Root="REGISTRY_ROOT" Type="raw"
+ <RegistrySearch Key="SOFTWARE\APPLICATION_VENDOR\APPLICATION_NAME"
+ Root="REGISTRY_ROOT" Type="raw"
Id="APPLICATIONFOLDER_REGSEARCH" Name="Path" />
</Property>
<DirectoryRef Id="APPLICATIONFOLDER">
@@ -33,11 +34,11 @@
KeyPath="yes" />
<!-- We need to use APPLICATIONFOLDER variable here or RemoveFolderEx
will not remove on "install". But only if WiX 3.6 is used. -->
- WIX36_ONLY_START
+ WIX36_ONLY_START
<util:RemoveFolderEx On="uninstall" Property="APPLICATIONFOLDER" />
WIX36_ONLY_END
</Component>
- </DirectoryRef>
+ </DirectoryRef>
<?include bundle.wxi ?>
UI_BLOCK
</Product>
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/template.wxs Tue Feb 12 11:54:56 2019 -0500
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/template.wxs Tue Feb 12 11:58:41 2019 -0500
@@ -1,28 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
- <Product Id="PRODUCT_GUID" Name="APPLICATION_NAME"
+ <Product Id="PRODUCT_GUID" Name="APPLICATION_NAME"
Language="1033" Version="APPLICATION_VERSION"
- Manufacturer="APPLICATION_VENDOR"
+ Manufacturer="APPLICATION_VENDOR"
UpgradeCode="PRODUCT_UPGRADE_GUID">
<Package Description="APPLICATION_DESCRIPTION" Comments="None"
InstallerVersion="200" Compressed="yes"
InstallScope="INSTALL_SCOPE" Platform="PLATFORM"/>
<Media Id="1" Cabinet="simple.cab" EmbedCab="yes" />
+UPGRADE_BLOCK
- <!-- We use RemoveFolderEx to ensure application folder is fully
+ <!-- We use RemoveFolderEx to ensure application folder is fully
removed on uninstall. Including files created outside of MSI
after application had been installed (e.g. on AU or user state).
-
- Hovewer, RemoveFolderEx is only available in WiX 3.6,
+
+ Hovewer, RemoveFolderEx is only available in WiX 3.6,
we will comment it out if we running older WiX.
RemoveFolderEx requires that we "remember" the path for uninstall.
Read the path value and set the APPLICATIONFOLDER property with the value.
-->
<Property Id="APPLICATIONFOLDER">
- <RegistrySearch Key="SOFTWARE\APPLICATION_VENDOR\APPLICATION_NAME"
- Root="REGISTRY_ROOT" Type="raw"
+ <RegistrySearch Key="SOFTWARE\APPLICATION_VENDOR\APPLICATION_NAME"
+ Root="REGISTRY_ROOT" Type="raw"
Id="APPLICATIONFOLDER_REGSEARCH" Name="Path" />
</Property>
<DirectoryRef Id="APPLICATIONFOLDER">
@@ -33,11 +34,11 @@
KeyPath="yes" />
<!-- We need to use APPLICATIONFOLDER variable here or RemoveFolderEx
will not remove on "install". But only if WiX 3.6 is used. -->
- WIX36_ONLY_START
+ WIX36_ONLY_START
<util:RemoveFolderEx On="uninstall" Property="APPLICATIONFOLDER" />
WIX36_ONLY_END
</Component>
- </DirectoryRef>
+ </DirectoryRef>
<?include bundle.wxi ?>
UI_BLOCK
<Icon Id="DesktopIcon.exe" SourceFile="APPLICATION_ICON" />
--- a/test/jdk/tools/jpackage/createimage/JPackageCreateImageBuildRootTest.java.rej Tue Feb 12 11:54:56 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
---- JPackageCreateImageBuildRootTest.java
-+++ JPackageCreateImageBuildRootTest.java
-@@ -25,6 +25,7 @@
-
- /*
- * @test
-+ * @requires (os.family == "windows")
- * @summary jpackage create image to test --build-root
- * @library ../helpers
- * @build JPackageHelper
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/jpackage/createinstaller/windows/base/JPackageCreateInstallerWinUpgradeUUIDBase.java Tue Feb 12 11:58:41 2019 -0500
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+public class JPackageCreateInstallerWinUpgradeUUIDBase {
+
+ private static String TEST_NAME;
+ private static String EXT;
+ private static String OUTPUT_1;
+ private static String[] CMD_1;
+ private static String OUTPUT_2;
+ private static String[] CMD_2;
+ private static final String FILE_1 = "file1.txt";
+ private static final String FILE_2 = "file2.txt";
+
+ private static void copyResults() throws Exception {
+ List<String> files = new ArrayList<>();
+ files.add(OUTPUT_1);
+ files.add(OUTPUT_2);
+ JPackageInstallerHelper.copyTestResults(files);
+ }
+
+ private static void testCreateInstaller() throws Exception {
+ JPackageHelper.executeCLI(true, CMD_1);
+ JPackageInstallerHelper.validateOutput(OUTPUT_1);
+ JPackageHelper.executeCLI(true, CMD_2);
+ JPackageInstallerHelper.validateOutput(OUTPUT_2);
+ copyResults();
+ }
+
+ private static void verifyInstall() throws Exception {
+ String app = JPackagePath.getWinInstalledApp(TEST_NAME);
+ JPackageInstallerHelper.validateApp(app);
+
+ String file1Path = JPackagePath.getWinInstalledAppFolder(TEST_NAME) + File.separator + FILE_1;
+ File file1 = new File(file1Path);
+ if (EXT.equals("msi")) {
+ if (file1.exists()) {
+ throw new AssertionError("Unexpected file does exist: "
+ + file1.getAbsolutePath());
+ }
+ } else if (EXT.equals("exe")) {
+ if (!file1.exists()) {
+ throw new AssertionError("Unexpected file does not exist: "
+ + file1.getAbsolutePath());
+ }
+ } else {
+ throw new AssertionError("Unknown installer type: " + EXT);
+ }
+
+ String file2Path = JPackagePath.getWinInstalledAppFolder(TEST_NAME) + File.separator + FILE_2;
+ File file2 = new File(file2Path);
+ if (!file2.exists()) {
+ throw new AssertionError("Unexpected file does not exist: "
+ + file2.getAbsolutePath());
+ }
+ }
+
+ private static void verifyUnInstall() throws Exception {
+ String folderPath = JPackagePath.getWinInstallFolder(TEST_NAME);
+ File folder = new File(folderPath);
+ if (folder.exists()) {
+ throw new AssertionError("Error: " + folder.getAbsolutePath() + " exist");
+ }
+ }
+
+ private static void init(String name, String ext) {
+ TEST_NAME = name;
+ EXT = ext;
+ OUTPUT_1 = "output" + File.separator + TEST_NAME + "-1.0." + EXT;
+ CMD_1 = new String[]{
+ "create-installer",
+ "--installer-type", EXT,
+ "--input", "input",
+ "--output", "output",
+ "--name", TEST_NAME,
+ "--main-jar", "hello.jar",
+ "--main-class", "Hello",
+ "--overwrite",
+ "--files", "hello.jar" + File.pathSeparator + FILE_1,
+ "--app-version", "1.0",
+ "--win-upgrade-uuid", "F0B18E75-52AD-41A2-BC86-6BE4FCD50BEB"};
+ OUTPUT_2 = "output" + File.separator + TEST_NAME + "-2.0." + EXT;
+ CMD_2 = new String[]{
+ "create-installer",
+ "--installer-type", EXT,
+ "--input", "input",
+ "--output", "output",
+ "--name", TEST_NAME,
+ "--main-jar", "hello.jar",
+ "--main-class", "Hello",
+ "--overwrite",
+ "--files", "hello.jar" + File.pathSeparator + FILE_2,
+ "--app-version", "2.0",
+ "--win-upgrade-uuid", "F0B18E75-52AD-41A2-BC86-6BE4FCD50BEB"};
+ }
+
+ private static void createInputFile(String name, String context) throws Exception {
+ try (PrintWriter out = new PrintWriter(
+ new BufferedWriter(new FileWriter("input" + File.separator + name)))) {
+ out.println(context);
+ }
+ }
+
+ public static void run(String name, String ext) throws Exception {
+ init(name, ext);
+
+ if (JPackageInstallerHelper.isVerifyInstall()) {
+ verifyInstall();
+ } else if (JPackageInstallerHelper.isVerifyUnInstall()) {
+ verifyUnInstall();
+ } else {
+ JPackageHelper.createHelloInstallerJar();
+ createInputFile(FILE_1, FILE_1);
+ createInputFile(FILE_2, FILE_2);
+ testCreateInstaller();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/jpackage/createinstaller/windows/exe/JPackageCreateInstallerWinUpgradeUUIDTest.java Tue Feb 12 11:58:41 2019 -0500
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary jpackage create installer test
+ * @library ../../../helpers
+ * @library ../base
+ * @build JPackageHelper
+ * @build JPackagePath
+ * @build JPackageInstallerHelper
+ * @build JPackageCreateInstallerWinUpgradeUUIDBase
+ * @requires (os.family == "windows")
+ * @modules jdk.jpackage
+ * @ignore
+ * @run main/othervm -Xmx512m JPackageCreateInstallerWinUpgradeUUIDTest
+ */
+public class JPackageCreateInstallerWinUpgradeUUIDTest {
+ private static final String TEST_NAME = "JPackageCreateInstallerWinUpgradeUUIDTest";
+ private static final String EXT = "exe";
+
+ public static void main(String[] args) throws Exception {
+ JPackageCreateInstallerWinUpgradeUUIDBase.run(TEST_NAME, EXT);
+ }
+}
--- a/test/jdk/tools/jpackage/createinstaller/windows/exe/install.bat Tue Feb 12 11:54:56 2019 -0500
+++ b/test/jdk/tools/jpackage/createinstaller/windows/exe/install.bat Tue Feb 12 11:58:41 2019 -0500
@@ -9,4 +9,6 @@
JPackageCreateInstallerWinShortcutTest-1.0.exe
ECHO Make sure that installer shows license
JPackageCreateInstallerLicenseTest-1.0.exe
+JPackageCreateInstallerWinUpgradeUUIDTest-1.0.exe
+JPackageCreateInstallerWinUpgradeUUIDTest-2.0.exe
PAUSE
--- a/test/jdk/tools/jpackage/createinstaller/windows/exe/uninstall.bat Tue Feb 12 11:54:56 2019 -0500
+++ b/test/jdk/tools/jpackage/createinstaller/windows/exe/uninstall.bat Tue Feb 12 11:58:41 2019 -0500
@@ -7,4 +7,5 @@
"%ProgramFiles%\JPackageCreateInstallerWinRegistryNameTest\unins000.exe"
"%ProgramFiles%\JPackageCreateInstallerWinShortcutTest\unins000.exe"
"%ProgramFiles%\JPackageCreateInstallerLicenseTest\unins000.exe"
+"%ProgramFiles%\JPackageCreateInstallerWinUpgradeUUIDTest\unins000.exe"
PAUSE
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/jpackage/createinstaller/windows/msi/JPackageCreateInstallerWinUpgradeUUIDTest.java Tue Feb 12 11:58:41 2019 -0500
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary jpackage create installer test
+ * @library ../../../helpers
+ * @library ../base
+ * @build JPackageHelper
+ * @build JPackagePath
+ * @build JPackageInstallerHelper
+ * @build JPackageCreateInstallerWinUpgradeUUIDBase
+ * @requires (os.family == "windows")
+ * @modules jdk.jpackage
+ * @ignore
+ * @run main/othervm -Xmx512m JPackageCreateInstallerWinUpgradeUUIDTest
+ */
+public class JPackageCreateInstallerWinUpgradeUUIDTest {
+ private static final String TEST_NAME = "JPackageCreateInstallerWinUpgradeUUIDTest";
+ private static final String EXT = "msi";
+
+ public static void main(String[] args) throws Exception {
+ JPackageCreateInstallerWinUpgradeUUIDBase.run(TEST_NAME, EXT);
+ }
+}
--- a/test/jdk/tools/jpackage/createinstaller/windows/msi/install.bat Tue Feb 12 11:54:56 2019 -0500
+++ b/test/jdk/tools/jpackage/createinstaller/windows/msi/install.bat Tue Feb 12 11:58:41 2019 -0500
@@ -9,4 +9,6 @@
JPackageCreateInstallerWinShortcutTest-1.0.msi
ECHO Make sure that installer shows license
JPackageCreateInstallerLicenseTest-1.0.msi
+JPackageCreateInstallerWinUpgradeUUIDTest-1.0.msi
+JPackageCreateInstallerWinUpgradeUUIDTest-2.0.msi
PAUSE
--- a/test/jdk/tools/jpackage/createinstaller/windows/msi/uninstall.bat Tue Feb 12 11:54:56 2019 -0500
+++ b/test/jdk/tools/jpackage/createinstaller/windows/msi/uninstall.bat Tue Feb 12 11:58:41 2019 -0500
@@ -7,4 +7,5 @@
MSIEXEC /uninstall JPackageCreateInstallerWinRegistryNameTest-1.0.msi
MSIEXEC /uninstall JPackageCreateInstallerWinShortcutTest-1.0.msi
MSIEXEC /uninstall JPackageCreateInstallerLicenseTest-1.0.msi
+MSIEXEC /uninstall JPackageCreateInstallerWinUpgradeUUIDTest-2.0.msi
PAUSE
\ No newline at end of file
--- a/test/jdk/tools/jpackage/helpers/JPackagePath.java Tue Feb 12 11:54:56 2019 -0500
+++ b/test/jdk/tools/jpackage/helpers/JPackagePath.java Tue Feb 12 11:58:41 2019 -0500
@@ -275,4 +275,10 @@
return path;
}
+
+ // Returns path to app folder of installed application
+ public static String getWinInstalledAppFolder(String testName) {
+ return getWinProgramFiles() + File.separator + testName + File.separator
+ + "app";
+ }
}