This reduces the surface area of our `Kernel` monkeypatch and removes
the need to `include Kernel` in a bunch of modules.
While we're here, also move `Kernel#require?` to `Homebrew` and fully
scope the calls to it.
`mv` should preserve hardlinks and allow faster unpack on the same
filesystem. A secondary pass is done with `cp` to copy over attributes
onto any existing directories.
We only run this for nested unpacks as most direct Directory strategy
usage is for repositories where moving files breaks existing code.
This uses `cp -pR` for non-move as some potential user reported issues
could be due to Apple's `cp -l` on specific macOS versions. Can
consider re-adding `cp -l` with better handling for older macOS.
Try running `cp -al` to preserve hardlinks on both macOS and Linux.
If that fails, fall back on `cp -a` which can preserve hardlinks on
Linux (but not macOS) assuming target filesystem supports them.
`T.nilable` was removed from the `P7Zip#dependencies` type signature
in a previous commit, as `UnpackStrategy#dependencies` doesn't allow
for a nilable return type. This updates the type signature for the
other `#dependencies` methods to also remove `T.nilable`, as they
would produce a runtime error otherwise.
This replaces `FileUtils.cp` and `system_command! "cp"` with the new
`Utils::Cp` utility where it is expected that the performance
improvement outweighs the cost of the system command invocation.
`ditto` behaves weirdly when the EUID is different from the UID. This
fix ensures that the BOM file is written with the correct permissions
in this case.
- This was done with `brew typecheck --update --suggest-typed` which
(as of the previous commit) uses Spoom, yet another gem. I thought I'd
see how well it works. There are no Sorbet errors after these changes!
Also, use `--no-same-permissions` instead of `-o` (which does nothing
without `-p` being passed and run as `root`) for the more explicit
description of the behaviour we want.