Skip to content

Commit 9573099

Browse files
author
Alexey Semenyuk
committedJun 11, 2020
8246792: Mac signing tests failed (unsealed contents present in the bundle root)
Reviewed-by: herrick, almatvee
1 parent 03642a0 commit 9573099

File tree

8 files changed

+74
-38
lines changed

8 files changed

+74
-38
lines changed
 

‎src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacAppImageBuilder.java

+13
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,19 @@ private void copyRuntimeFiles(Map<String, ? super Object> params)
310310
// generate java runtime info.plist
311311
writeRuntimeInfoPlist(
312312
runtimeDir.resolve("Contents/Info.plist").toFile(), params);
313+
314+
// copy library
315+
Path runtimeMacOSDir = Files.createDirectories(
316+
runtimeDir.resolve("Contents/MacOS"));
317+
318+
final Path jliName = Path.of("libjli.dylib");
319+
try (Stream<Path> walk = Files.walk(runtimeRoot.resolve("lib"))) {
320+
final Path jli = walk
321+
.filter(file -> file.getFileName().equals(jliName))
322+
.findFirst()
323+
.get();
324+
Files.copy(jli, runtimeMacOSDir.resolve(jliName));
325+
}
313326
}
314327

315328
private void sign(Map<String, ? super Object> params) throws IOException {

‎src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacDmgBundler.java

-4
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,6 @@ private File buildDMG( Map<String, ? super Object> params,
336336
File mountedRoot = new File(imagesRoot.getAbsolutePath(),
337337
APP_NAME.fetchFrom(params));
338338
try {
339-
Files.deleteIfExists(AppImageFile.getPathInAppImage(
340-
mountedRoot.toPath().resolve(APP_NAME.fetchFrom(params)
341-
+ ".app")));
342-
343339
// background image
344340
File bgdir = new File(mountedRoot, BACKGROUND_IMAGE_FOLDER);
345341
bgdir.mkdirs();

‎src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacPkgBundler.java

-4
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,6 @@ private File createPKG(Map<String, ? super Object> params,
407407
root,
408408
"--install-location",
409409
getInstallDir(params),
410-
"--filter",
411-
AppImageFile.getPathInAppImage(Path.of("")).toString(),
412410
"--analyze",
413411
cpl.getAbsolutePath());
414412

@@ -424,8 +422,6 @@ private File createPKG(Map<String, ? super Object> params,
424422
root,
425423
"--install-location",
426424
getInstallDir(params),
427-
"--filter",
428-
AppImageFile.getPathInAppImage(Path.of("")).toString(),
429425
"--component-plist",
430426
cpl.getAbsolutePath(),
431427
"--scripts",

‎src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/AppImageFile.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ void verifyCompatible() throws ConfigException {
9595
* @param appImageDir - path to application image
9696
*/
9797
public static Path getPathInAppImage(Path appImageDir) {
98-
return appImageDir.resolve(FILENAME);
98+
return ApplicationLayout.platformAppImage()
99+
.resolveAt(appImageDir)
100+
.appDirectory()
101+
.resolve(FILENAME);
99102
}
100103

101104
/**

‎src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/IOUtils.java

+1
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ public static interface XmlConsumer {
251251
public static void createXml(Path dstFile, XmlConsumer xmlConsumer) throws
252252
IOException {
253253
XMLOutputFactory xmlFactory = XMLOutputFactory.newInstance();
254+
Files.createDirectories(dstFile.getParent());
254255
try (Writer w = Files.newBufferedWriter(dstFile)) {
255256
// Wrap with pretty print proxy
256257
XMLStreamWriter xml = (XMLStreamWriter) Proxy.newProxyInstance(

‎test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java

+46-12
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import java.util.regex.Pattern;
3939
import java.util.stream.Collectors;
4040
import java.util.stream.Stream;
41+
import jdk.incubator.jpackage.internal.AppImageFile;
4142
import jdk.incubator.jpackage.internal.ApplicationLayout;
4243
import jdk.jpackage.test.Functional.ThrowingConsumer;
4344
import jdk.jpackage.test.Functional.ThrowingFunction;
@@ -235,9 +236,7 @@ public JPackageCommand setFakeRuntime() {
235236

236237
Files.createDirectories(fakeRuntimeDir);
237238

238-
if (TKit.isWindows() || TKit.isLinux()) {
239-
// Needed to make WindowsAppBundler happy as it copies MSVC dlls
240-
// from `bin` directory.
239+
if (TKit.isLinux()) {
241240
// Need to make the code in rpm spec happy as it assumes there is
242241
// always something in application image.
243242
fakeRuntimeDir.resolve("bin").toFile().mkdir();
@@ -246,7 +245,7 @@ public JPackageCommand setFakeRuntime() {
246245
if (TKit.isOSX()) {
247246
// Make MacAppImageBuilder happy
248247
createBulkFile.accept(fakeRuntimeDir.resolve(Path.of(
249-
"Contents/Home/lib/jli/libjli.dylib")));
248+
"lib/jli/libjli.dylib")));
250249
}
251250

252251
// Mak sure fake runtime takes some disk space.
@@ -680,13 +679,56 @@ public Executor.Result executeAndAssertImageCreated() {
680679

681680
public JPackageCommand assertImageCreated() {
682681
verifyIsOfType(PackageType.IMAGE);
682+
assertAppLayout();
683+
return this;
684+
}
685+
686+
JPackageCommand assertAppLayout() {
687+
if (isPackageUnpacked() || isImagePackageType()) {
688+
final Path rootDir = isPackageUnpacked() ? pathToUnpackedPackageFile(
689+
appInstallationDirectory()) : outputBundle();
690+
final Path appImageFileName = AppImageFile.getPathInAppImage(
691+
Path.of("")).getFileName();
692+
try (Stream<Path> walk = ThrowingSupplier.toSupplier(
693+
() -> Files.walk(rootDir)).get()) {
694+
List<String> appImageFiles = walk
695+
.filter(path -> path.getFileName().equals(appImageFileName))
696+
.map(Path::toString)
697+
.collect(Collectors.toList());
698+
if (isImagePackageType() || TKit.isOSX()) {
699+
List<String> expected = List.of(
700+
AppImageFile.getPathInAppImage(rootDir).toString());
701+
TKit.assertStringListEquals(expected, appImageFiles,
702+
String.format(
703+
"Check there is only one file with [%s] name in the package",
704+
appImageFileName));
705+
} else {
706+
TKit.assertStringListEquals(List.of(), appImageFiles,
707+
String.format(
708+
"Check there are no files with [%s] name in the package",
709+
appImageFileName));
710+
}
711+
}
712+
} else if (TKit.isOSX()) {
713+
TKit.assertFileExists(AppImageFile.getPathInAppImage(
714+
appInstallationDirectory()));
715+
} else {
716+
TKit.assertPathExists(AppImageFile.getPathInAppImage(
717+
appInstallationDirectory()), false);
718+
}
719+
683720
TKit.assertDirectoryExists(appRuntimeDirectory());
684721

685722
if (!isRuntime()) {
686723
TKit.assertExecutableFileExists(appLauncherPath());
687724
TKit.assertFileExists(appLauncherCfgPath(null));
688725
}
689726

727+
if (TKit.isOSX()) {
728+
TKit.assertFileExists(appRuntimeDirectory().resolve(
729+
"Contents/MacOS/libjli.dylib"));
730+
}
731+
690732
return this;
691733
}
692734

@@ -785,14 +827,6 @@ public static String escapeAndJoin(List<String> args) {
785827
}).collect(Collectors.joining(" "));
786828
}
787829

788-
public static Path relativePathInRuntime(JavaTool tool) {
789-
Path path = tool.relativePathInJavaHome();
790-
if (TKit.isOSX()) {
791-
path = Path.of("Contents/Home").resolve(path);
792-
}
793-
return path;
794-
}
795-
796830
public static Stream<String> filterOutput(Stream<String> jpackageOutput) {
797831
// Skip "WARNING: Using incubator ..." first line of output
798832
return jpackageOutput.skip(1);

‎test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageTest.java

+1-17
Original file line numberDiff line numberDiff line change
@@ -553,30 +553,14 @@ private void verifyPackageInstalled(JPackageCommand cmd) {
553553
}
554554
TKit.trace(String.format(formatString, cmd.getPrintableCommandLine()));
555555

556-
TKit.assertDirectoryExists(cmd.appRuntimeDirectory());
557556
if (!cmd.isRuntime()) {
558-
TKit.assertExecutableFileExists(cmd.appLauncherPath());
559-
560557
if (PackageType.WINDOWS.contains(cmd.packageType())
561558
&& !cmd.isPackageUnpacked(
562559
"Not verifying desktop integration")) {
563560
new WindowsHelper.DesktopIntegrationVerifier(cmd);
564561
}
565562
}
566-
567-
if (cmd.isPackageUnpacked()) {
568-
final Path appImageFile = AppImageFile.getPathInAppImage(
569-
Path.of(""));
570-
try (Stream<Path> walk = ThrowingSupplier.toSupplier(
571-
() -> Files.walk(cmd.unpackedPackageDirectory())).get()) {
572-
walk.filter(path -> path.getFileName().equals(appImageFile))
573-
.findFirst()
574-
.ifPresent(path -> TKit.assertPathExists(path, false));
575-
}
576-
} else {
577-
TKit.assertPathExists(AppImageFile.getPathInAppImage(
578-
cmd.appInstallationDirectory()), false);
579-
}
563+
cmd.assertAppLayout();
580564

581565
installVerifiers.forEach(v -> v.accept(cmd));
582566
}

‎test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java

+9
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,15 @@ public void testJLinkRuntime(String javaAppDesc) throws IOException {
335335
"--no-header-files",
336336
"--no-man-pages");
337337

338+
TKit.trace("jlink output BEGIN");
339+
try (Stream<Path> paths = Files.walk(runtimeDir)) {
340+
paths.filter(Files::isRegularFile)
341+
.map(runtimeDir::relativize)
342+
.map(Path::toString)
343+
.forEach(TKit::trace);
344+
}
345+
TKit.trace("jlink output END");
346+
338347
if (moduleName != null) {
339348
jlink.addArguments("--add-modules", moduleName, "--module-path",
340349
Path.of(cmd.getArgumentValue("--module-path")).resolve(

0 commit comments

Comments
 (0)
Please sign in to comment.