8246792: Mac signing tests failed (unsealed contents present in the bundle root)
Reviewed-by: herrick, almatvee
This commit is contained in:
parent
03642a01af
commit
95730995b6
@ -310,6 +310,19 @@ public class MacAppImageBuilder extends AbstractAppImageBuilder {
|
|||||||
// generate java runtime info.plist
|
// generate java runtime info.plist
|
||||||
writeRuntimeInfoPlist(
|
writeRuntimeInfoPlist(
|
||||||
runtimeDir.resolve("Contents/Info.plist").toFile(), params);
|
runtimeDir.resolve("Contents/Info.plist").toFile(), params);
|
||||||
|
|
||||||
|
// copy library
|
||||||
|
Path runtimeMacOSDir = Files.createDirectories(
|
||||||
|
runtimeDir.resolve("Contents/MacOS"));
|
||||||
|
|
||||||
|
final Path jliName = Path.of("libjli.dylib");
|
||||||
|
try (Stream<Path> walk = Files.walk(runtimeRoot.resolve("lib"))) {
|
||||||
|
final Path jli = walk
|
||||||
|
.filter(file -> file.getFileName().equals(jliName))
|
||||||
|
.findFirst()
|
||||||
|
.get();
|
||||||
|
Files.copy(jli, runtimeMacOSDir.resolve(jliName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sign(Map<String, ? super Object> params) throws IOException {
|
private void sign(Map<String, ? super Object> params) throws IOException {
|
||||||
|
@ -336,10 +336,6 @@ public class MacDmgBundler extends MacBaseInstallerBundler {
|
|||||||
File mountedRoot = new File(imagesRoot.getAbsolutePath(),
|
File mountedRoot = new File(imagesRoot.getAbsolutePath(),
|
||||||
APP_NAME.fetchFrom(params));
|
APP_NAME.fetchFrom(params));
|
||||||
try {
|
try {
|
||||||
Files.deleteIfExists(AppImageFile.getPathInAppImage(
|
|
||||||
mountedRoot.toPath().resolve(APP_NAME.fetchFrom(params)
|
|
||||||
+ ".app")));
|
|
||||||
|
|
||||||
// background image
|
// background image
|
||||||
File bgdir = new File(mountedRoot, BACKGROUND_IMAGE_FOLDER);
|
File bgdir = new File(mountedRoot, BACKGROUND_IMAGE_FOLDER);
|
||||||
bgdir.mkdirs();
|
bgdir.mkdirs();
|
||||||
|
@ -407,8 +407,6 @@ public class MacPkgBundler extends MacBaseInstallerBundler {
|
|||||||
root,
|
root,
|
||||||
"--install-location",
|
"--install-location",
|
||||||
getInstallDir(params),
|
getInstallDir(params),
|
||||||
"--filter",
|
|
||||||
AppImageFile.getPathInAppImage(Path.of("")).toString(),
|
|
||||||
"--analyze",
|
"--analyze",
|
||||||
cpl.getAbsolutePath());
|
cpl.getAbsolutePath());
|
||||||
|
|
||||||
@ -424,8 +422,6 @@ public class MacPkgBundler extends MacBaseInstallerBundler {
|
|||||||
root,
|
root,
|
||||||
"--install-location",
|
"--install-location",
|
||||||
getInstallDir(params),
|
getInstallDir(params),
|
||||||
"--filter",
|
|
||||||
AppImageFile.getPathInAppImage(Path.of("")).toString(),
|
|
||||||
"--component-plist",
|
"--component-plist",
|
||||||
cpl.getAbsolutePath(),
|
cpl.getAbsolutePath(),
|
||||||
"--scripts",
|
"--scripts",
|
||||||
|
@ -95,7 +95,10 @@ public class AppImageFile {
|
|||||||
* @param appImageDir - path to application image
|
* @param appImageDir - path to application image
|
||||||
*/
|
*/
|
||||||
public static Path getPathInAppImage(Path appImageDir) {
|
public static Path getPathInAppImage(Path appImageDir) {
|
||||||
return appImageDir.resolve(FILENAME);
|
return ApplicationLayout.platformAppImage()
|
||||||
|
.resolveAt(appImageDir)
|
||||||
|
.appDirectory()
|
||||||
|
.resolve(FILENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -251,6 +251,7 @@ public class IOUtils {
|
|||||||
public static void createXml(Path dstFile, XmlConsumer xmlConsumer) throws
|
public static void createXml(Path dstFile, XmlConsumer xmlConsumer) throws
|
||||||
IOException {
|
IOException {
|
||||||
XMLOutputFactory xmlFactory = XMLOutputFactory.newInstance();
|
XMLOutputFactory xmlFactory = XMLOutputFactory.newInstance();
|
||||||
|
Files.createDirectories(dstFile.getParent());
|
||||||
try (Writer w = Files.newBufferedWriter(dstFile)) {
|
try (Writer w = Files.newBufferedWriter(dstFile)) {
|
||||||
// Wrap with pretty print proxy
|
// Wrap with pretty print proxy
|
||||||
XMLStreamWriter xml = (XMLStreamWriter) Proxy.newProxyInstance(
|
XMLStreamWriter xml = (XMLStreamWriter) Proxy.newProxyInstance(
|
||||||
|
@ -38,6 +38,7 @@ import java.util.function.Supplier;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
import jdk.incubator.jpackage.internal.AppImageFile;
|
||||||
import jdk.incubator.jpackage.internal.ApplicationLayout;
|
import jdk.incubator.jpackage.internal.ApplicationLayout;
|
||||||
import jdk.jpackage.test.Functional.ThrowingConsumer;
|
import jdk.jpackage.test.Functional.ThrowingConsumer;
|
||||||
import jdk.jpackage.test.Functional.ThrowingFunction;
|
import jdk.jpackage.test.Functional.ThrowingFunction;
|
||||||
@ -235,9 +236,7 @@ public final class JPackageCommand extends CommandArguments<JPackageCommand> {
|
|||||||
|
|
||||||
Files.createDirectories(fakeRuntimeDir);
|
Files.createDirectories(fakeRuntimeDir);
|
||||||
|
|
||||||
if (TKit.isWindows() || TKit.isLinux()) {
|
if (TKit.isLinux()) {
|
||||||
// Needed to make WindowsAppBundler happy as it copies MSVC dlls
|
|
||||||
// from `bin` directory.
|
|
||||||
// Need to make the code in rpm spec happy as it assumes there is
|
// Need to make the code in rpm spec happy as it assumes there is
|
||||||
// always something in application image.
|
// always something in application image.
|
||||||
fakeRuntimeDir.resolve("bin").toFile().mkdir();
|
fakeRuntimeDir.resolve("bin").toFile().mkdir();
|
||||||
@ -246,7 +245,7 @@ public final class JPackageCommand extends CommandArguments<JPackageCommand> {
|
|||||||
if (TKit.isOSX()) {
|
if (TKit.isOSX()) {
|
||||||
// Make MacAppImageBuilder happy
|
// Make MacAppImageBuilder happy
|
||||||
createBulkFile.accept(fakeRuntimeDir.resolve(Path.of(
|
createBulkFile.accept(fakeRuntimeDir.resolve(Path.of(
|
||||||
"Contents/Home/lib/jli/libjli.dylib")));
|
"lib/jli/libjli.dylib")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mak sure fake runtime takes some disk space.
|
// Mak sure fake runtime takes some disk space.
|
||||||
@ -680,6 +679,44 @@ public final class JPackageCommand extends CommandArguments<JPackageCommand> {
|
|||||||
|
|
||||||
public JPackageCommand assertImageCreated() {
|
public JPackageCommand assertImageCreated() {
|
||||||
verifyIsOfType(PackageType.IMAGE);
|
verifyIsOfType(PackageType.IMAGE);
|
||||||
|
assertAppLayout();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
JPackageCommand assertAppLayout() {
|
||||||
|
if (isPackageUnpacked() || isImagePackageType()) {
|
||||||
|
final Path rootDir = isPackageUnpacked() ? pathToUnpackedPackageFile(
|
||||||
|
appInstallationDirectory()) : outputBundle();
|
||||||
|
final Path appImageFileName = AppImageFile.getPathInAppImage(
|
||||||
|
Path.of("")).getFileName();
|
||||||
|
try (Stream<Path> walk = ThrowingSupplier.toSupplier(
|
||||||
|
() -> Files.walk(rootDir)).get()) {
|
||||||
|
List<String> appImageFiles = walk
|
||||||
|
.filter(path -> path.getFileName().equals(appImageFileName))
|
||||||
|
.map(Path::toString)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (isImagePackageType() || TKit.isOSX()) {
|
||||||
|
List<String> expected = List.of(
|
||||||
|
AppImageFile.getPathInAppImage(rootDir).toString());
|
||||||
|
TKit.assertStringListEquals(expected, appImageFiles,
|
||||||
|
String.format(
|
||||||
|
"Check there is only one file with [%s] name in the package",
|
||||||
|
appImageFileName));
|
||||||
|
} else {
|
||||||
|
TKit.assertStringListEquals(List.of(), appImageFiles,
|
||||||
|
String.format(
|
||||||
|
"Check there are no files with [%s] name in the package",
|
||||||
|
appImageFileName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (TKit.isOSX()) {
|
||||||
|
TKit.assertFileExists(AppImageFile.getPathInAppImage(
|
||||||
|
appInstallationDirectory()));
|
||||||
|
} else {
|
||||||
|
TKit.assertPathExists(AppImageFile.getPathInAppImage(
|
||||||
|
appInstallationDirectory()), false);
|
||||||
|
}
|
||||||
|
|
||||||
TKit.assertDirectoryExists(appRuntimeDirectory());
|
TKit.assertDirectoryExists(appRuntimeDirectory());
|
||||||
|
|
||||||
if (!isRuntime()) {
|
if (!isRuntime()) {
|
||||||
@ -687,6 +724,11 @@ public final class JPackageCommand extends CommandArguments<JPackageCommand> {
|
|||||||
TKit.assertFileExists(appLauncherCfgPath(null));
|
TKit.assertFileExists(appLauncherCfgPath(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TKit.isOSX()) {
|
||||||
|
TKit.assertFileExists(appRuntimeDirectory().resolve(
|
||||||
|
"Contents/MacOS/libjli.dylib"));
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -785,14 +827,6 @@ public final class JPackageCommand extends CommandArguments<JPackageCommand> {
|
|||||||
}).collect(Collectors.joining(" "));
|
}).collect(Collectors.joining(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Path relativePathInRuntime(JavaTool tool) {
|
|
||||||
Path path = tool.relativePathInJavaHome();
|
|
||||||
if (TKit.isOSX()) {
|
|
||||||
path = Path.of("Contents/Home").resolve(path);
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Stream<String> filterOutput(Stream<String> jpackageOutput) {
|
public static Stream<String> filterOutput(Stream<String> jpackageOutput) {
|
||||||
// Skip "WARNING: Using incubator ..." first line of output
|
// Skip "WARNING: Using incubator ..." first line of output
|
||||||
return jpackageOutput.skip(1);
|
return jpackageOutput.skip(1);
|
||||||
|
@ -553,30 +553,14 @@ public final class PackageTest extends RunnablePackageTest {
|
|||||||
}
|
}
|
||||||
TKit.trace(String.format(formatString, cmd.getPrintableCommandLine()));
|
TKit.trace(String.format(formatString, cmd.getPrintableCommandLine()));
|
||||||
|
|
||||||
TKit.assertDirectoryExists(cmd.appRuntimeDirectory());
|
|
||||||
if (!cmd.isRuntime()) {
|
if (!cmd.isRuntime()) {
|
||||||
TKit.assertExecutableFileExists(cmd.appLauncherPath());
|
|
||||||
|
|
||||||
if (PackageType.WINDOWS.contains(cmd.packageType())
|
if (PackageType.WINDOWS.contains(cmd.packageType())
|
||||||
&& !cmd.isPackageUnpacked(
|
&& !cmd.isPackageUnpacked(
|
||||||
"Not verifying desktop integration")) {
|
"Not verifying desktop integration")) {
|
||||||
new WindowsHelper.DesktopIntegrationVerifier(cmd);
|
new WindowsHelper.DesktopIntegrationVerifier(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cmd.assertAppLayout();
|
||||||
if (cmd.isPackageUnpacked()) {
|
|
||||||
final Path appImageFile = AppImageFile.getPathInAppImage(
|
|
||||||
Path.of(""));
|
|
||||||
try (Stream<Path> walk = ThrowingSupplier.toSupplier(
|
|
||||||
() -> Files.walk(cmd.unpackedPackageDirectory())).get()) {
|
|
||||||
walk.filter(path -> path.getFileName().equals(appImageFile))
|
|
||||||
.findFirst()
|
|
||||||
.ifPresent(path -> TKit.assertPathExists(path, false));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
TKit.assertPathExists(AppImageFile.getPathInAppImage(
|
|
||||||
cmd.appInstallationDirectory()), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
installVerifiers.forEach(v -> v.accept(cmd));
|
installVerifiers.forEach(v -> v.accept(cmd));
|
||||||
}
|
}
|
||||||
|
@ -335,6 +335,15 @@ public final class BasicTest {
|
|||||||
"--no-header-files",
|
"--no-header-files",
|
||||||
"--no-man-pages");
|
"--no-man-pages");
|
||||||
|
|
||||||
|
TKit.trace("jlink output BEGIN");
|
||||||
|
try (Stream<Path> paths = Files.walk(runtimeDir)) {
|
||||||
|
paths.filter(Files::isRegularFile)
|
||||||
|
.map(runtimeDir::relativize)
|
||||||
|
.map(Path::toString)
|
||||||
|
.forEach(TKit::trace);
|
||||||
|
}
|
||||||
|
TKit.trace("jlink output END");
|
||||||
|
|
||||||
if (moduleName != null) {
|
if (moduleName != null) {
|
||||||
jlink.addArguments("--add-modules", moduleName, "--module-path",
|
jlink.addArguments("--add-modules", moduleName, "--module-path",
|
||||||
Path.of(cmd.getArgumentValue("--module-path")).resolve(
|
Path.of(cmd.getArgumentValue("--module-path")).resolve(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user