Skip to content

Commit

Permalink
[build+macOS] Remove quarantine from OpenJDK installations (#9652)
Browse files Browse the repository at this point in the history
Context: #9651

Recent versions of macOS, Safari, and **tar**(1) [^0] interact such
that if you manually download a tarball and extract it,
*all the extracted files* contain the `com.apple.quarantine`
extended attribute.  This is a security feature, but it also means
that the provisioned JDK *cannot be used*:

	% $HOME/android-toolchain/jdk-21/bin/javac
	zsh: operation not permitted: ./jdk-21/bin/javac

Which in turn means if you do something "reasonable" like download
Microsoft OpenJDK and place it into `$HOME/android-archives` -- so
that `xaprepare` doesn't need to download it *again* -- then the
provisioned JDK will be *unusable*.  Which makes @jonpryor sad.

Update `Step_InstallAdoptOpenJDK.MacOS.cs` to run
`xattr -d -r com.apple.quarantine $HOME/android-toolchain/jdk-21`.
This will *delete* the offending extended attribute, allowing e.g.
`javac` to run without error.

[^0]: Which versions?  ¯\\_(ツ)_/¯
  • Loading branch information
jonpryor authored Jan 7, 2025
1 parent 217b244 commit aec2b0b
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ void MoveContents (string sourceDir, string destinationDir)
{
string realSourceDir = Path.Combine (sourceDir, "Contents", "Home");
Utilities.MoveDirectoryContentsRecursively (realSourceDir, destinationDir);

var xattr_d = new ProcessRunner ("xattr", "-d", "-r", "com.apple.quarantine", ".") {
EchoStandardError = true,
WorkingDirectory = destinationDir,
};
xattr_d.Run ();
}
}
}

0 comments on commit aec2b0b

Please sign in to comment.