--- old/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebBundler.java 2019-08-19 12:20:32.251906500 -0400 +++ new/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebBundler.java 2019-08-19 12:20:30.920640000 -0400 @@ -28,12 +28,15 @@ import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.*; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.attribute.PosixFilePermission; import java.nio.file.attribute.PosixFilePermissions; import java.text.MessageFormat; import java.util.*; import java.util.regex.Pattern; +import java.util.stream.Stream; import static jdk.jpackage.internal.StandardBundlerParam.*; import static jdk.jpackage.internal.LinuxAppBundler.ICON_PNG; @@ -140,13 +143,13 @@ + EMAIL.fetchFrom(params) + ">", (s, p) -> s); - public static final BundlerParamInfo SECTION = + public static final BundlerParamInfo SECTION = new StandardBundlerParam<>( Arguments.CLIOptions.LINUX_CATEGORY.getId(), String.class, params -> "misc", (s, p) -> s); - + public static final BundlerParamInfo LICENSE_TEXT = new StandardBundlerParam<> ( "linux.deb.licenseText", @@ -155,7 +158,13 @@ try { String licenseFile = LICENSE_FILE.fetchFrom(params); if (licenseFile != null) { - return Files.readString(new File(licenseFile).toPath()); + StringBuilder contentBuilder = new StringBuilder(); + try (Stream stream = Files.lines(Path.of( + licenseFile), StandardCharsets.UTF_8)) { + stream.forEach(s -> contentBuilder.append(s).append( + "\n")); + } + return contentBuilder.toString(); } } catch (Exception e) { Log.verbose(e); @@ -164,6 +173,13 @@ }, (s, p) -> s); + public static final BundlerParamInfo COPYRIGHT_FILE = + new StandardBundlerParam<>( + Arguments.CLIOptions.LINUX_DEB_COPYRIGHT_FILE.getId(), + String.class, + params -> null, + (s, p) -> s); + public static final BundlerParamInfo XDG_FILE_PREFIX = new StandardBundlerParam<> ( "linux.xdg-prefix", @@ -715,16 +731,23 @@ } setPermissions(getConfig_PostrmFile(params), "rwxr-xr-x"); - try (Writer w = Files.newBufferedWriter( - getConfig_CopyrightFile(params).toPath())) { - String content = preprocessTextResource( - getConfig_CopyrightFile(params).getName(), - I18N.getString("resource.deb-copyright-file"), - DEFAULT_COPYRIGHT_TEMPLATE, - data, - VERBOSE.fetchFrom(params), - RESOURCE_DIR.fetchFrom(params)); - w.write(content); + getConfig_CopyrightFile(params).getParentFile().mkdirs(); + String customCopyrightFile = COPYRIGHT_FILE.fetchFrom(params); + if (customCopyrightFile != null) { + IOUtils.copyFile(new File(customCopyrightFile), + getConfig_CopyrightFile(params)); + } else { + try (Writer w = Files.newBufferedWriter( + getConfig_CopyrightFile(params).toPath())) { + String content = preprocessTextResource( + getConfig_CopyrightFile(params).getName(), + I18N.getString("resource.copyright-file"), + DEFAULT_COPYRIGHT_TEMPLATE, + data, + VERBOSE.fetchFrom(params), + RESOURCE_DIR.fetchFrom(params)); + w.write(content); + } } return true; @@ -793,7 +816,8 @@ } private File getConfig_CopyrightFile(Map params) { - return new File(CONFIG_DIR.fetchFrom(params), "copyright"); + return Path.of(DEB_IMAGE_DIR.fetchFrom(params).getAbsolutePath(), "usr", + "share", "doc", BUNDLE_NAME.fetchFrom(params), "copyright").toFile(); } private File buildDeb(Map params, --- old/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/LinuxResources.properties 2019-08-19 12:20:41.790528000 -0400 +++ new/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/LinuxResources.properties 2019-08-19 12:20:40.446574300 -0400 @@ -35,7 +35,7 @@ resource.deb-prerm-script=DEB prerm script resource.deb-postinstall-script=DEB postinstall script resource.deb-postrm-script=DEB postrm script -resource.deb-copyright-file=DEB copyright file +resource.copyright-file=Copyright file resource.menu-shortcut-descriptor=Menu shortcut descriptor resource.menu-icon=menu icon resource.rpm-spec-file=RPM spec file --- old/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/LinuxResources_ja.properties 2019-08-19 12:20:51.316519700 -0400 +++ new/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/LinuxResources_ja.properties 2019-08-19 12:20:49.959879800 -0400 @@ -35,7 +35,7 @@ resource.deb-prerm-script=DEB prerm script resource.deb-postinstall-script=DEB postinstall script resource.deb-postrm-script=DEB postrm script -resource.deb-copyright-file=DEB copyright file +resource.copyright-file=Copyright file resource.menu-shortcut-descriptor=Menu shortcut descriptor resource.menu-icon=menu icon resource.rpm-spec-file=RPM spec file --- old/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/LinuxResources_zh_CN.properties 2019-08-19 12:21:00.746778100 -0400 +++ new/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/LinuxResources_zh_CN.properties 2019-08-19 12:20:59.399849200 -0400 @@ -35,7 +35,7 @@ resource.deb-prerm-script=DEB prerm script resource.deb-postinstall-script=DEB postinstall script resource.deb-postrm-script=DEB postrm script -resource.deb-copyright-file=DEB copyright file +resource.copyright-file=Copyright file resource.menu-shortcut-descriptor=Menu shortcut descriptor resource.menu-icon=menu icon resource.rpm-spec-file=RPM spec file --- old/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.copyright 2019-08-19 12:21:10.185565300 -0400 +++ new/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.copyright 2019-08-19 12:21:08.743974700 -0400 @@ -1,8 +1,5 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Copyright: - - APPLICATION_COPYRIGHT - -License: - - APPLICATION_LICENSE_TEXT +Files: * +Copyright: APPLICATION_COPYRIGHT +License: APPLICATION_LICENSE_TEXT --- old/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AddLauncherArguments.java 2019-08-19 12:21:19.483676900 -0400 +++ new/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AddLauncherArguments.java 2019-08-19 12:21:18.109467200 -0400 @@ -108,6 +108,9 @@ putUnlessNull(bundleParams, CLIOptions.LINUX_CATEGORY.getId(), getOptionValue(CLIOptions.LINUX_CATEGORY)); + + putUnlessNull(bundleParams, CLIOptions.LINUX_DEB_COPYRIGHT_FILE.getId(), + getOptionValue(CLIOptions.LINUX_DEB_COPYRIGHT_FILE)); putUnlessNull(bundleParams, CLIOptions.WIN_CONSOLE_HINT.getId(), --- old/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java 2019-08-19 12:21:28.719064700 -0400 +++ new/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java 2019-08-19 12:21:27.370233100 -0400 @@ -324,6 +324,9 @@ LINUX_DEB_MAINTAINER ("linux-deb-maintainer", OptionCategories.PLATFORM_LINUX), + + LINUX_DEB_COPYRIGHT_FILE ("linux-deb-copyright-file", + OptionCategories.PLATFORM_LINUX), LINUX_CATEGORY ("linux-app-category", OptionCategories.PLATFORM_LINUX), --- old/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ValidOptions.java 2019-08-19 12:21:38.265189000 -0400 +++ new/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ValidOptions.java 2019-08-19 12:21:36.902647500 -0400 @@ -122,6 +122,7 @@ if (Platform.getPlatform() == Platform.LINUX) { options.put(CLIOptions.LINUX_BUNDLE_NAME.getId(), USE.INSTALL); options.put(CLIOptions.LINUX_DEB_MAINTAINER.getId(), USE.INSTALL); + options.put(CLIOptions.LINUX_DEB_COPYRIGHT_FILE.getId(), USE.INSTALL); options.put(CLIOptions.LINUX_CATEGORY.getId(), USE.INSTALL); options.put(CLIOptions.LINUX_RPM_LICENSE_TYPE.getId(), USE.INSTALL); options.put(CLIOptions.LINUX_PACKAGE_DEPENDENCIES.getId(), --- old/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources.properties 2019-08-19 12:21:47.652067900 -0400 +++ new/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources.properties 2019-08-19 12:21:46.305160100 -0400 @@ -250,6 +250,9 @@ \ Name for Linux bundle, defaults to the application name\n\ \ --linux-deb-maintainer \n\ \ Maintainer for .deb bundle\n\ +\ --linux-deb-copyright-file \n\ +\ Path to custom copyright file for Debian packaging\n\ +\ (absolute path or relative to the current directory)\n\ \ --linux-menu-group \n\ \ Menu group this application is placed in\n\ \ --linux-package-deps\n\ --- old/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_ja.properties 2019-08-19 12:21:57.762606400 -0400 +++ new/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_ja.properties 2019-08-19 12:21:56.303446900 -0400 @@ -250,6 +250,9 @@ \ Name for Linux bundle, defaults to the application name\n\ \ --linux-deb-maintainer \n\ \ Maintainer for .deb bundle\n\ +\ --linux-deb-copyright-file \n\ +\ Path to custom copyright file for Debian packaging\n\ +\ (absolute path or relative to the current directory)\n\ \ --linux-menu-group \n\ \ Menu group this application is placed in\n\ \ --linux-package-deps\n\ --- old/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_zh_CN.properties 2019-08-19 12:22:08.074217500 -0400 +++ new/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_zh_CN.properties 2019-08-19 12:22:06.707780400 -0400 @@ -250,6 +250,9 @@ \ Name for Linux bundle, defaults to the application name\n\ \ --linux-deb-maintainer \n\ \ Maintainer for .deb bundle\n\ +\ --linux-deb-copyright-file \n\ +\ Path to custom copyright file for Debian packaging\n\ +\ (absolute path or relative to the current directory)\n\ \ --linux-menu-group \n\ \ Menu group this application is placed in\n\ \ --linux-package-deps\n\ --- old/test/jdk/tools/jpackage/linux/base/LicenseBase.java 2019-08-19 12:22:17.662492300 -0400 +++ new/test/jdk/tools/jpackage/linux/base/LicenseBase.java 2019-08-19 12:22:16.332203400 -0400 @@ -50,8 +50,15 @@ String app = JPackagePath.getLinuxInstalledApp(TEST_NAME); JPackageInstallerHelper.validateApp(app); + File licenseFile = null; if (EXT.equals("rpm")) { - verifyInstallRpm(); + licenseFile = getRpmLicenseFileInstallLocation(); + } else if (EXT.equals("deb")) { + licenseFile = getDebLicenseFileInstallLocation(); + } + if (!licenseFile.exists()) { + throw new AssertionError( + "Error: " + licenseFile.getAbsolutePath() + " not found"); } } @@ -67,8 +74,8 @@ "(\\r|\\n)", ""); retVal = JPackageHelper.execute(new File(infoResult), "rpm", - "-qp", "--queryformat", "%{name}-%{version}", - OUTPUT.toLowerCase()); + "-q", "--queryformat", "%{name}-%{version}", + TEST_NAME.toLowerCase()); if (retVal != 0) { throw new AssertionError("rpm exited with error: " + retVal); } @@ -79,12 +86,9 @@ JPackagePath.getLicenseFilePath()).getName()).toFile(); } - private static void verifyInstallRpm() throws Exception { - final File licenseFile = getRpmLicenseFileInstallLocation(); - if (!licenseFile.exists()) { - throw new AssertionError( - "Error: " + licenseFile.getAbsolutePath() + " not found"); - } + private static File getDebLicenseFileInstallLocation() throws Exception { + return Path.of("/usr", "share", "doc", TEST_NAME.toLowerCase(), + "copyright").toFile(); } private static void verifyUnInstall() throws Exception { @@ -100,6 +104,12 @@ if (folder.exists()) { throw new AssertionError( "Error: " + licenseFileFolder.getAbsolutePath() + " exist"); + } + } else if (EXT.equals("deb")) { + final File licenseFileFolder = getDebLicenseFileInstallLocation().getParentFile(); + if (folder.exists()) { + throw new AssertionError( + "Error: " + licenseFileFolder.getAbsolutePath() + " exist"); } } }