# HG changeset patch # User herrick # Date 1549990721 18000 # Node ID d10b861e8d623cf598864de68d5aa48253882219 # Parent 1d6f8a7c6d5a7fc8e7ec997896d9247a2deb09fd 8214564: --win-upgrade-uuid does not work as expected Submitten-by: almatvee Reviewed-by: herrick, ihse diff -r 1d6f8a7c6d5a -r d10b861e8d62 src/jdk.jpackage/share/classes/jdk/jpackage/internal/BundlerParamInfo.java --- 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 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, T> getDefaultValueFunction() { return defaultValueFunction; } @@ -144,6 +153,7 @@ T result = getDefaultValueFunction().apply(params); if (result != null) { params.put(getID(), result); + isDefaultValue = true; } return result; } diff -r 1d6f8a7c6d5a -r d10b861e8d62 src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiBundler.java --- 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" + " \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 = + ""; + + private String getUpgradeBlock(Map params) { + if (UPGRADE_UUID.getIsDefaultValue()) { + return ""; + } else { + return UPGRADE_BLOCK; + } + } + /** * Creates UI element using WiX built-in dialog sets * - WixUI_InstallDir/WixUI_Minimal. diff -r 1d6f8a7c6d5a -r d10b861e8d62 src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/template.jre.wxs --- 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 @@ - +UPGRADE_BLOCK - - @@ -33,11 +34,11 @@ KeyPath="yes" /> - WIX36_ONLY_START + WIX36_ONLY_START WIX36_ONLY_END - + UI_BLOCK diff -r 1d6f8a7c6d5a -r d10b861e8d62 src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/template.wxs --- 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 @@ - +UPGRADE_BLOCK - - @@ -33,11 +34,11 @@ KeyPath="yes" /> - WIX36_ONLY_START + WIX36_ONLY_START WIX36_ONLY_END - + UI_BLOCK diff -r 1d6f8a7c6d5a -r d10b861e8d62 test/jdk/tools/jpackage/createimage/JPackageCreateImageBuildRootTest.java.rej --- 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 diff -r 1d6f8a7c6d5a -r d10b861e8d62 test/jdk/tools/jpackage/createinstaller/windows/base/JPackageCreateInstallerWinUpgradeUUIDBase.java --- /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 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(); + } + } +} diff -r 1d6f8a7c6d5a -r d10b861e8d62 test/jdk/tools/jpackage/createinstaller/windows/exe/JPackageCreateInstallerWinUpgradeUUIDTest.java --- /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); + } +} diff -r 1d6f8a7c6d5a -r d10b861e8d62 test/jdk/tools/jpackage/createinstaller/windows/exe/install.bat --- 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 diff -r 1d6f8a7c6d5a -r d10b861e8d62 test/jdk/tools/jpackage/createinstaller/windows/exe/uninstall.bat --- 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 diff -r 1d6f8a7c6d5a -r d10b861e8d62 test/jdk/tools/jpackage/createinstaller/windows/msi/JPackageCreateInstallerWinUpgradeUUIDTest.java --- /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); + } +} diff -r 1d6f8a7c6d5a -r d10b861e8d62 test/jdk/tools/jpackage/createinstaller/windows/msi/install.bat --- 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 diff -r 1d6f8a7c6d5a -r d10b861e8d62 test/jdk/tools/jpackage/createinstaller/windows/msi/uninstall.bat --- 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 diff -r 1d6f8a7c6d5a -r d10b861e8d62 test/jdk/tools/jpackage/helpers/JPackagePath.java --- 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"; + } }