--- old/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacPkgBundler.java 2020-02-21 12:01:41.136028100 -0500 +++ new/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacPkgBundler.java 2020-02-21 12:01:39.790197500 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2020, 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 @@ -362,6 +362,7 @@ String root = appLocation.getParent() == null ? "." : appLocation.getParent(); File rootDir = new File(root); + File[] list = rootDir.listFiles(); if (list != null) { // Should not happend // We should only have app image and/or .DS_Store @@ -378,11 +379,25 @@ // Copy to new root Path newRoot = Files.createTempDirectory( - TEMP_ROOT.fetchFrom(params).toPath(), - "root-"); + TEMP_ROOT.fetchFrom(params).toPath(), "root-"); + + Path source, dest; - IOUtils.copyRecursive(appLocation.toPath(), - newRoot.resolve(appLocation.getName())); + if (StandardBundlerParam.isRuntimeInstaller(params)) { + // firs, is this already a runtime with + // /Contents/Home - if so we need the Home dir + Path original = appLocation.toPath(); + Path home = original.resolve("Contents/Home"); + source = (Files.exists(home)) ? home : original; + + // Then we need to put back the /Content/Home + dest = newRoot.resolve( + MAC_CF_BUNDLE_IDENTIFIER.fetchFrom(params) + "/Contents/Home"); + } else { + source = appLocation.toPath(); + dest = newRoot.resolve(appLocation.getName()); + } + IOUtils.copyRecursive(source, dest); return newRoot.toString(); } @@ -422,6 +437,8 @@ cpl.getAbsolutePath(), "--scripts", SCRIPTS_DIR.fetchFrom(params).getAbsolutePath(), + "--identifier", + MAC_CF_BUNDLE_IDENTIFIER.fetchFrom(params), appPKG.getAbsolutePath()); IOUtils.exec(pb);