--- old/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebBundler.java 2019-08-19 12:38:42.538205000 -0400 +++ new/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebBundler.java 2019-08-19 12:38:41.154251100 -0400 @@ -29,8 +29,13 @@ import java.awt.image.BufferedImage; import java.io.*; import java.nio.charset.StandardCharsets; +import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.StandardCopyOption; +import java.nio.file.attribute.BasicFileAttributes; + import java.nio.file.attribute.PosixFilePermission; import java.nio.file.attribute.PosixFilePermissions; import java.text.MessageFormat; @@ -315,19 +320,22 @@ private boolean prepareProto(Map params) throws PackagerException, IOException { File appImage = StandardBundlerParam.getPredefinedAppImage(params); - File appDir = null; // we either have an application image or need to build one if (appImage != null) { - appDir = new File(APP_IMAGE_ROOT.fetchFrom(params), - APP_NAME.fetchFrom(params)); // copy everything from appImage dir into appDir/name - IOUtils.copyRecursive(appImage.toPath(), appDir.toPath()); + IOUtils.copyRecursive(appImage.toPath(), + getConfig_RootDirectory(params).toPath()); } else { - appDir = APP_BUNDLER.fetchFrom(params).doBundle(params, + File bundleDir = APP_BUNDLER.fetchFrom(params).doBundle(params, APP_IMAGE_ROOT.fetchFrom(params), true); + if (bundleDir == null) { + return false; + } + Files.move(bundleDir.toPath(), getConfig_RootDirectory( + params).toPath(), StandardCopyOption.REPLACE_EXISTING); } - return appDir != null; + return true; } public File bundle(Map params, @@ -355,6 +363,7 @@ imageDir.mkdirs(); configDir.mkdirs(); if (prepareProto(params) && prepareProjectConfig(params)) { + adjustPermissionsRecursive(imageDir); return buildDeb(params, outdir); } return null; @@ -412,11 +421,38 @@ return count; } + private void adjustPermissionsRecursive(File dir) throws IOException { + Files.walkFileTree(dir.toPath(), new SimpleFileVisitor() { + @Override + public FileVisitResult visitFile(Path file, + BasicFileAttributes attrs) + throws IOException { + if (file.endsWith(".so") || !Files.isExecutable(file)) { + setPermissions(file.toFile(), "rw-r--r--"); + } else if (Files.isExecutable(file)) { + setPermissions(file.toFile(), "rwxr-xr-x"); + } + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException e) + throws IOException { + if (e == null) { + setPermissions(dir.toFile(), "rwxr-xr-x"); + return FileVisitResult.CONTINUE; + } else { + // directory iteration failed + throw e; + } + } + }); + } + private boolean prepareProjectConfig(Map params) throws IOException { Map data = createReplacementData(params); - File rootDir = LinuxAppBundler.getRootDir(APP_IMAGE_ROOT.fetchFrom( - params), params); + File rootDir = getConfig_RootDirectory(params); File binDir = new File(rootDir, "bin"); File iconTarget = getConfig_IconFile(binDir, params); @@ -576,7 +612,7 @@ .append(LINUX_INSTALL_DIR.fetchFrom(params)) .append("/") .append(data.get("APPLICATION_FS_NAME")) - .append("/") + .append("/bin/") .append(mimeInfoFile) .append("\n"); @@ -584,7 +620,7 @@ .append(LINUX_INSTALL_DIR.fetchFrom(params)) .append("/") .append(data.get("APPLICATION_FS_NAME")) - .append("/") + .append("/bin/") .append(mimeInfoFile) .append("\n"); addedEntry = true; @@ -759,7 +795,8 @@ String launcher = LinuxAppImageBuilder.getLauncherRelativePath(params); data.put("APPLICATION_NAME", APP_NAME.fetchFrom(params)); - data.put("APPLICATION_FS_NAME", APP_NAME.fetchFrom(params)); + data.put("APPLICATION_FS_NAME", + getConfig_RootDirectory(params).getName()); data.put("APPLICATION_PACKAGE", BUNDLE_NAME.fetchFrom(params)); data.put("APPLICATION_VENDOR", VENDOR.fetchFrom(params)); data.put("APPLICATION_MAINTAINER", MAINTAINER.fetchFrom(params)); @@ -776,9 +813,8 @@ data.put("APPLICATION_ARCH", getDebArch()); data.put("APPLICATION_INSTALLED_SIZE", Long.toString(getInstalledSizeKB(params))); - String deps = LINUX_PACKAGE_DEPENDENCIES.fetchFrom(params); - data.put("PACKAGE_DEPENDENCIES", - deps.isEmpty() ? "" : "Depends: " + deps); + data.put("PACKAGE_DEPENDENCIES", LINUX_PACKAGE_DEPENDENCIES.fetchFrom( + params)); data.put("RUNTIME_INSTALLER", "" + StandardBundlerParam.isRuntimeInstaller(params)); @@ -820,6 +856,12 @@ "share", "doc", BUNDLE_NAME.fetchFrom(params), "copyright").toFile(); } + private File getConfig_RootDirectory( + Map params) { + return Path.of(APP_IMAGE_ROOT.fetchFrom(params).getAbsolutePath(), + BUNDLE_NAME.fetchFrom(params)).toFile(); + } + private File buildDeb(Map params, File outdir) throws IOException { File outFile = new File(outdir, --- old/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxRpmBundler.java 2019-08-19 12:38:51.837685000 -0400 +++ new/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxRpmBundler.java 2019-08-19 12:38:50.503492600 -0400 @@ -449,7 +449,7 @@ .append(LINUX_INSTALL_DIR.fetchFrom(params)) .append("/") .append(data.get("APPLICATION_FS_NAME")) - .append("/") + .append("/bin/") .append(mimeInfoFile) .append("\n"); @@ -457,7 +457,7 @@ .append(LINUX_INSTALL_DIR.fetchFrom(params)) .append("/") .append(data.get("APPLICATION_FS_NAME")) - .append("/") + .append("/bin/") .append(mimeInfoFile) .append("\n"); addedEntry = true; --- old/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.control 2019-08-19 12:39:01.026858000 -0400 +++ new/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.control 2019-08-19 12:38:59.667260100 -0400 @@ -7,5 +7,5 @@ Architecture: APPLICATION_ARCH Provides: APPLICATION_PACKAGE Description: APPLICATION_DESCRIPTION +Depends: PACKAGE_DEPENDENCIES Installed-Size: APPLICATION_INSTALLED_SIZE -PACKAGE_DEPENDENCIES --- old/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.postinst 2019-08-19 12:39:10.098891400 -0400 +++ new/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.postinst 2019-08-19 12:39:08.764373600 -0400 @@ -25,23 +25,6 @@ xdg-desktop-menu install --novendor INSTALLATION_DIRECTORY/APPLICATION_FS_NAME/APPLICATION_LAUNCHER_FILENAME.desktop FILE_ASSOCIATION_INSTALL fi - if [ "SERVICE_HINT" = "true" ]; then - echo Installing daemon - cp INSTALLATION_DIRECTORY/APPLICATION_FS_NAME/APPLICATION_PACKAGE.init /etc/init.d/APPLICATION_PACKAGE - - if [ -x "/etc/init.d/APPLICATION_PACKAGE" ]; then - update-rc.d APPLICATION_PACKAGE defaults - - if [ "START_ON_INSTALL" = "true" ]; then - if which invoke-rc.d >/dev/null 2>&1; then - invoke-rc.d APPLICATION_PACKAGE start - else - /etc/init.d/APPLICATION_PACKAGE start - fi - fi - fi - - fi ;; abort-upgrade|abort-remove|abort-deconfigure) @@ -53,9 +36,4 @@ ;; esac -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - exit 0 --- old/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.postrm 2019-08-19 12:39:19.510471500 -0400 +++ new/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.postrm 2019-08-19 12:39:18.148948900 -0400 @@ -20,14 +20,6 @@ case "$1" in purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) - if [ "$1" = "purge" ] ; then - if [ "SERVICE_HINT" = "true" ]; then - echo Uninstalling daemon - rm -f /etc/init.d/APPLICATION_PACKAGE - - update-rc.d APPLICATION_PACKAGE remove - fi - fi ;; *) @@ -36,9 +28,4 @@ ;; esac -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - exit 0 --- old/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.preinst 2019-08-19 12:39:29.162281800 -0400 +++ new/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.preinst 2019-08-19 12:39:27.792950600 -0400 @@ -27,9 +27,4 @@ ;; esac -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - exit 0 --- old/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.prerm 2019-08-19 12:39:38.451978700 -0400 +++ new/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.prerm 2019-08-19 12:39:37.112908600 -0400 @@ -36,10 +36,5 @@ ;; esac -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - exit 0 --- old/test/jdk/tools/jpackage/helpers/JPackagePath.java 2019-08-19 12:39:47.728720800 -0400 +++ new/test/jdk/tools/jpackage/helpers/JPackagePath.java 2019-08-19 12:39:46.404251700 -0400 @@ -223,10 +223,7 @@ } public static String getLinuxInstalledApp(String subDir, String testName) { - return File.separator + "opt" - + File.separator + subDir - + File.separator + testName - + File.separator + testName; + return Path.of("/opt", subDir, testName, "bin", testName).toString(); } public static String getWinInstallFolder(String testName) { --- old/test/jdk/tools/jpackage/linux/base/MaintainerBase.java 2019-08-19 12:39:57.187133000 -0400 +++ new/test/jdk/tools/jpackage/linux/base/MaintainerBase.java 2019-08-19 12:39:55.807065400 -0400 @@ -53,9 +53,18 @@ throw new AssertionError(infoResult + " was not created"); } - String output = Files.readString(outfile.toPath()); - if (!output.contains("Maintainer: " + EMAIL)) { - throw new AssertionError("Unexpected result: " + output); + boolean maintainerFound = false; + for (String line: Files.readAllLines(outfile.toPath())) { + if (line.matches("^[ ]*Maintainer:.*$")) { + maintainerFound = true; + if (!line.contains(EMAIL)) { + throw new AssertionError("Unexpected result: " + line); + } + } + } + + if (!maintainerFound) { + throw new AssertionError("Maintainer field not found"); } } --- old/test/jdk/tools/jpackage/linux/deb/BundleNameTest.java 2019-08-19 12:40:06.519967600 -0400 +++ new/test/jdk/tools/jpackage/linux/deb/BundleNameTest.java 2019-08-19 12:40:05.169146600 -0400 @@ -36,7 +36,7 @@ * @run main/othervm/timeout=360 -Xmx512m BundleNameTest */ public class BundleNameTest { - private static final String TEST_NAME = "BundleNameTest"; + private static final String TEST_NAME = "bundlenametest"; private static final String EXT = "deb"; public static void main(String[] args) throws Exception { --- old/test/jdk/tools/jpackage/linux/deb/FileAssociationsTest.java 2019-08-19 12:40:16.146576000 -0400 +++ new/test/jdk/tools/jpackage/linux/deb/FileAssociationsTest.java 2019-08-19 12:40:14.809453600 -0400 @@ -36,7 +36,7 @@ * @run main/othervm/timeout=360 -Xmx512m FileAssociationsTest */ public class FileAssociationsTest { - private static final String TEST_NAME = "FileAssociationsTest"; + private static final String TEST_NAME = "fileassociationstest"; private static final String EXT = "deb"; public static void main(String[] args) throws Exception { --- old/test/jdk/tools/jpackage/linux/deb/InstallDirTest.java 2019-08-19 12:40:25.281929800 -0400 +++ new/test/jdk/tools/jpackage/linux/deb/InstallDirTest.java 2019-08-19 12:40:23.934073600 -0400 @@ -36,7 +36,7 @@ * @run main/othervm/timeout=360 -Xmx512m InstallDirTest */ public class InstallDirTest { - private static final String TEST_NAME = "InstallDirTest"; + private static final String TEST_NAME = "installdirtest"; private static final String EXT = "deb"; public static void main(String[] args) throws Exception { --- old/test/jdk/tools/jpackage/linux/deb/LicenseTest.java 2019-08-19 12:40:34.436889300 -0400 +++ new/test/jdk/tools/jpackage/linux/deb/LicenseTest.java 2019-08-19 12:40:33.155399600 -0400 @@ -36,7 +36,7 @@ * @run main/othervm/timeout=360 -Xmx512m LicenseTest */ public class LicenseTest { - private static final String TEST_NAME = "LicenseTest"; + private static final String TEST_NAME = "licensetest"; private static final String EXT = "deb"; public static void main(String[] args) throws Exception { --- old/test/jdk/tools/jpackage/linux/deb/MaintainerTest.java 2019-08-19 12:40:43.647737600 -0400 +++ new/test/jdk/tools/jpackage/linux/deb/MaintainerTest.java 2019-08-19 12:40:42.336745800 -0400 @@ -36,7 +36,7 @@ * @run main/othervm/timeout=360 -Xmx512m MaintainerTest */ public class MaintainerTest { - private static final String TEST_NAME = "MaintainerTest"; + private static final String TEST_NAME = "maintainertest"; private static final String EXT = "deb"; public static void main(String[] args) throws Exception { --- old/test/jdk/tools/jpackage/linux/deb/PackageDepsTest.java 2019-08-19 12:40:53.299930900 -0400 +++ new/test/jdk/tools/jpackage/linux/deb/PackageDepsTest.java 2019-08-19 12:40:51.991114000 -0400 @@ -36,7 +36,7 @@ * @run main/othervm/timeout=420 -Xmx512m PackageDepsTest */ public class PackageDepsTest { - private static final String TEST_NAME = "PackageDepsTest"; + private static final String TEST_NAME = "packagedepstest"; private static final String EXT = "deb"; public static void main(String[] args) throws Exception { --- old/test/jdk/tools/jpackage/linux/deb/Test.java 2019-08-19 12:41:02.501182100 -0400 +++ new/test/jdk/tools/jpackage/linux/deb/Test.java 2019-08-19 12:41:01.164984400 -0400 @@ -36,7 +36,7 @@ * @run main/othervm/timeout=300 -Xmx512m Test */ public class Test { - private static final String TEST_NAME = "Test"; + private static final String TEST_NAME = "test"; private static final String EXT = "deb"; public static void main(String[] args) throws Exception {