8237908: [TESTBUG] [macos] Add support to jtreg helpers to unpack pkg packages

Reviewed-by: herrick, asemenyuk
This commit is contained in:
Alexander Matveev 2020-05-27 09:30:46 -04:00
parent 93d89d3bf3
commit 6f5e8a2aa3

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 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
@ -135,6 +135,20 @@ public class MacHelper {
.addArguments("-target", "/")
.execute();
};
pkg.unpackHandler = (cmd, destinationDir) -> {
cmd.verifyIsOfType(PackageType.MAC_PKG);
Executor.of("pkgutil", "--expand")
.addArgument(cmd.outputBundle())
.addArgument(destinationDir.resolve("data")) // We need non-existing folder
.execute();
Executor.of("tar", "-C")
.addArgument(destinationDir)
.addArgument("-xvf")
.addArgument(Path.of(destinationDir.toString(), "data",
cmd.name() + "-app.pkg", "Payload"))
.execute();
return destinationDir.resolve(cmd.name() + ".app");
};
pkg.uninstallHandler = cmd -> {
cmd.verifyIsOfType(PackageType.MAC_PKG);
Executor.of("sudo", "rm", "-rf")