113 Commits

Author SHA1 Message Date
Douglas Eichelberger
fb6c51da07
Enable strict typing in SystemCommand 2025-09-02 10:26:40 -07:00
Douglas Eichelberger
d97933b38c
Refactor T.must called on .first 2025-08-25 20:27:47 -07:00
Mike McQuaid
a1f112f3fe
Move o* output methods to Utils::Output
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.
2025-08-20 19:20:19 +01:00
botantony
d3cfc3d193
unpack .dmg: ignore .HFS+ Private* metadata directories
Signed-off-by: botantony <antonsm21@gmail.com>
2025-03-18 12:59:21 +01:00
Michael Cho
13be3c3073
unpack_strategy/directory: use mv for nested unpack
`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.
2024-10-20 11:29:30 -04:00
Michael Cho
cfb8ebb5d8
unpack_strategy/directory: try preserving hardlinks
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.
2024-10-03 20:30:41 -04:00
Carlo Cabrera
86b27eb0f3
unpack_strategy/dmg: more UID handling fixes
Follow-up to #18040.
2024-09-27 17:55:32 +08:00
Mike McQuaid
94416e82f0
Add new odeprecated, odisabled, remove disabled code.
Prepare the usual deprecation cycle for Homebrew 4.4.0.
2024-09-24 10:15:34 +01:00
Bo Anderson
467666c8b3
unpack_strategy/dmg: fix UID handling 2024-08-13 17:50:34 +01:00
Sam Ford
a196898ad3
unpack_strategy/cab: align method order
This simply moves the `Cab#dependencies` method above
`#extract_to_dir`, to align it with the other strategies.
2024-07-28 10:17:23 -04:00
Sam Ford
6918160fd9
UnpackStrategy: Make #dependencies non-nilable
`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.
2024-07-28 10:15:02 -04:00
Bevan Kay
0a658a3290
unpack_strategy/p7zip: update types 2024-07-28 22:31:38 +10:00
Issy Long
af6e1194d2
unpack_strategy/dmg: Convert to Sorbet typed: strict
- I missed this, whoops.
2024-07-11 21:34:26 -04:00
Issy Long
edb8055c76
unpack_strategy/*: Convert to Sorbet typed: strict 2024-07-11 21:18:27 -04:00
Issy Long
9c6430954b
All the extract_to_dirs return void now 2024-07-11 11:05:47 +01:00
Douglas Eichelberger
4ebf1116d7 Introduce UnpackStrategyImpl 2024-07-08 12:56:19 +01:00
Kevin
c3c1528611
Revert "Use cp -c when copying files" 2024-06-17 21:17:10 -07:00
Mike McQuaid
1e0add6d66
Merge pull request #17373 from tesaguri/cp-reflink 2024-06-13 08:57:20 +01:00
Daiki Mizukami
028cfe1ea6
Utils::Cp: Rename to Utils::Copy
As per review feedback:

https://github.com/Homebrew/brew/pull/17373#discussion_r1633217748
2024-06-11 20:31:34 +09:00
Daiki Mizukami
67f280eb53
Utils::Cp: Add force_system keyword argument
This fixes the test for `UnpackStrategy::Directory`, which needs the
`cp` command.
2024-06-09 07:57:56 +09:00
Daiki Mizukami
b2ddeecdd9
Utils::Cp: Remove copy prefix from method name
As per review feedback:

https://github.com/Homebrew/brew/pull/17373#pullrequestreview-2104523770

Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2024-06-08 07:58:20 +09:00
Daiki Mizukami
58852106c1
Utils::Cp: Rename copy* methods to copy*_with_attributes
As per review feedback:

https://github.com/Homebrew/brew/pull/17373#pullrequestreview-2103870774
2024-06-07 19:03:33 +09:00
Issy Long
509fffab2b
Make more files Sorbet typed: strict
- According to Spoom, these could be bumped automatically with no errors.
2024-06-02 15:15:24 +01:00
Daiki Mizukami
deaac7ce47
Use Utils::Cp to copy files
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.
2024-05-27 12:11:41 +09:00
Justin Krehel
344a5021d8
cask/audit.rb: update signing checks for app, binary, and pkg 2024-05-22 10:29:47 -04:00
Mike McQuaid
0bbfa434cf
unpack_strategy/dmg: fix permissions when needed.
`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.
2024-04-01 09:49:10 +01:00
Michael Cho
7b46378a6c
unpack_strategy: allow unpacking .crate (as a gzipped tar)
Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-03-26 11:05:10 -04:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Bo Anderson
1d7101d8a3
Use HOMEBREW_TEMP more universally 2024-02-26 16:58:53 +00:00
Issy Long
f4218a6316
Fix RuboCop Performance/MapCompact offenses
- Rename an iterator variable since it would make the line too long.
2024-02-25 22:59:59 +00:00
Douglas Eichelberger
eb7c3e52a0 Require SystemInclude only where needed 2024-01-31 11:42:01 -08:00
Carlo Cabrera
0867534f3e
unpack_strategy/zip: avoid loading formulae unnecessarily
If we already have `unzip` in `PATH`, let's skip trying to load the
`unzip` formula.
2023-05-31 00:06:55 +08:00
Michael Wagner
78c07fd0e1
Fix Missing Download Strategy And Dependency 2023-05-17 16:30:00 -05:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Douglas Eichelberger
f38a672938 brew style --fix 2023-03-21 17:37:48 -07:00
Douglas Eichelberger
82dc57dfea Enable UnpackStrategy types 2023-03-21 17:37:46 -07:00
Markus Reiter
c6a5d79ef9
Remove explicit error for empty BOM retry. 2023-03-21 00:39:26 +01:00
Markus Reiter
1e0e12cc43
Retry if DMG BOM is empty. 2023-03-13 18:32:56 +01:00
Markus Reiter
4f04e9e599
Add signatures for extraction functions. 2023-02-22 22:15:53 +01:00
Mike McQuaid
d292dbdc2b
Revert "Fix permissions before moving extracted files." 2023-02-20 17:20:57 +00:00
Markus Reiter
7c5b6fd10d
Add signatures for extraction methods. 2023-02-19 19:29:21 +01:00
Mike McQuaid
6a25229567
brew style --fix 2023-01-02 19:18:51 +00:00
apainintheneck
65bce0ed3c Move unpack_strategy/zip check to extend/os 2022-11-23 20:39:59 -08:00
Issy Long
b7d997e80d
sorbet: Bump some files from typed: false to typed: true
- 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!
2022-10-11 01:09:03 +01:00
Bo Anderson
02164a35db
Use ORIGINAL_PATHS over envs; reject nil PATH 2022-06-17 19:47:57 +01:00
Bo Anderson
aa4ad964eb
unpack_strategy/zip: allow unzip formula to be used 2022-03-02 13:34:26 +00:00
Alexander Bayandin
e74f996b02
unpack_strategy/tar: fix zst subextraction 2021-10-01 10:45:49 +01:00
Alexander Bayandin
fe9a039774
unpack_strategy: add zstd 2021-09-20 14:12:30 +01:00
Bo Anderson
7ee76b85d5
unpack_strategy/zip: ensure consistent timezone management 2021-04-27 20:29:18 +01:00
Mike McQuaid
b57fe84f81
Use long/readable tar flags.
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.
2021-04-16 14:05:06 +01:00