Skip to content
Permalink
Browse files
8267403: tools/jpackage/share/FileAssociationsTest.java#id0 failed wi…
…th "Error: Bundler "Mac PKG Package" (pkg) failed to produce a package"

Reviewed-by: herrick, asemenyuk
  • Loading branch information
Alexander Matveev committed May 25, 2021
1 parent c20ca42 commit 5aa45f2edf278bab4403704ab4b6644096f8c077
Showing 5 changed files with 30 additions and 15 deletions.
@@ -451,7 +451,7 @@ private Path createPKG(Map<String, ? super Object> params,
"--analyze",
cpl.toAbsolutePath().toString());

IOUtils.exec(pb);
IOUtils.exec(pb, false, null, true, Executor.INFINITE_TIMEOUT);

patchCPLFile(cpl);

@@ -467,7 +467,7 @@ private Path createPKG(Map<String, ? super Object> params,
"--identifier",
MAC_CF_BUNDLE_IDENTIFIER.fetchFrom(params),
appPKG.toAbsolutePath().toString());
IOUtils.exec(pb);
IOUtils.exec(pb, false, null, true, Executor.INFINITE_TIMEOUT);
} else {
preparePackageScripts(params);
pb = new ProcessBuilder("/usr/bin/pkgbuild",
@@ -483,7 +483,7 @@ private Path createPKG(Map<String, ? super Object> params,
"--identifier",
MAC_CF_BUNDLE_IDENTIFIER.fetchFrom(params),
appPKG.toAbsolutePath().toString());
IOUtils.exec(pb);
IOUtils.exec(pb, false, null, true, Executor.INFINITE_TIMEOUT);
}

// build final package
@@ -541,7 +541,7 @@ private Path createPKG(Map<String, ? super Object> params,
commandLine.add(finalPKG.toAbsolutePath().toString());

pb = new ProcessBuilder(commandLine);
IOUtils.exec(pb);
IOUtils.exec(pb, false, null, true, Executor.INFINITE_TIMEOUT);

return finalPKG;
} catch (Exception ignored) {
@@ -33,7 +33,6 @@
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public final class Executor {
@@ -182,7 +181,7 @@ int execute() throws IOException {
code = p.waitFor();
}
if (!quietCommand) {
Log.verbose(pb.command(), getOutput(), code);
Log.verbose(pb.command(), getOutput(), code, IOUtils.getPID(p));
}
return code;
} catch (InterruptedException ex) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2021, 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
@@ -243,7 +243,7 @@ public static int getProcessOutput(List<String> result, String... args)
t.start();

int ret = p.waitFor();
Log.verbose(pb.command(), list, ret);
Log.verbose(pb.command(), list, ret, IOUtils.getPID(p));

result.clear();
result.addAll(list);
@@ -335,6 +335,17 @@ public static Path getFileName(Path p) {
return filename;
}

public static long getPID(Process p) {
try {
return p.pid();
} catch (UnsupportedOperationException ex) {
Log.verbose(ex); // Just log exception and ignore it. This method
// is used for verbose output, so not a problem
// if unsupported.
return -1;
}
}

private static class PrettyPrintHandler implements InvocationHandler {

PrettyPrintHandler(XMLStreamWriter target) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, 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
@@ -192,7 +192,7 @@ private static void runJLink(Path output, List<Path> modulePath,
String jlinkOut = writer.toString();

args.add(0, "jlink");
Log.verbose(args, List.of(jlinkOut), retVal);
Log.verbose(args, List.of(jlinkOut), retVal, -1);


if (retVal != 0) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2021, 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
@@ -106,9 +106,13 @@ public void verbose(String msg) {
}

public void verbose(List<String> strings,
List<String> output, int returnCode) {
List<String> output, int returnCode, long pid) {
if (verbose) {
StringBuffer sb = new StringBuffer("Command:\n ");
StringBuffer sb = new StringBuffer();
sb.append("Command [PID: ");
sb.append(pid);
sb.append("]:\n ");

for (String s : strings) {
sb.append(" " + s);
}
@@ -174,7 +178,8 @@ public static void verbose(Throwable t) {
instance.get().verbose(t);
}

public static void verbose(List<String> strings, List<String> out, int ret) {
instance.get().verbose(strings, out, ret);
public static void verbose(List<String> strings, List<String> out,
int ret, long pid) {
instance.get().verbose(strings, out, ret, pid);
}
}

1 comment on commit 5aa45f2

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 5aa45f2 May 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.