Skip to content

Commit

Permalink
8267403: tools/jpackage/share/FileAssociationsTest.java#id0 failed wi…
Browse files Browse the repository at this point in the history
…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 5aa45f2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
Expand Up @@ -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);

Expand All @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
15 changes: 13 additions & 2 deletions src/jdk.jpackage/share/classes/jdk/jpackage/internal/IOUtils.java
@@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
@@ -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
Expand Down Expand Up @@ -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) {
Expand Down
15 changes: 10 additions & 5 deletions src/jdk.jpackage/share/classes/jdk/jpackage/internal/Log.java
@@ -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
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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

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.