71 Commits

Author SHA1 Message Date
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
835466ecd8
unpack_strategy: use Mktemp instead of Dir.mktmpdir 2024-10-16 12:53:08 -04:00
Michael Cho
f223fef218
unpack_strategy: fix unpack Dir.mktmpdir group
Otherwise the files will be unpacked with group wheel on macOS which
gets copied over when running `cp -al`.
2024-10-13 13:56:23 -04:00
Douglas Eichelberger
eeb31d3050 Fix violations 2024-09-20 11:07:00 -07:00
Bo Anderson
6db4ed2793
Replace some include Kernel usages with requires_ancestor 2024-08-20 19:10:14 +01:00
Bevan Kay
98ec6a9722
unpack_strategy: update types 2024-07-28 22:31:38 +10:00
Issy Long
bffb470c57
unpack_strategy: Fix ref_type type (Symbol, not String)
- I put a debugger call in the test that was failing.
- Running the install command at that debug prompt and lo,
  the typing bug was staring me in the face:

```
Error: An exception occurred within a child process:
  TypeError: Parameter 'ref_type': Expected type T.nilable(String), got type Symbol with value :branch
Caller: /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.3.0/gems/sorbet-runtime-0.5.11471/lib/types/private/methods/call_validation.rb:215
Definition: /opt/homebrew/Library/Homebrew/unpack_strategy.rb:102 (UnpackStrategy.detect)
```
2024-07-11 19:37:46 +01:00
Douglas Eichelberger
0076a88541 Apply suggested changes 2024-07-08 12:56:19 +01:00
Douglas Eichelberger
4ebf1116d7 Introduce UnpackStrategyImpl 2024-07-08 12:56:19 +01:00
Issy Long
0a18f77de4
Apply suggestions from code review 2024-07-06 15:22:08 +01:00
Issy Long
cd1869437d
unpack_strategy: Convert to Sorbet typed: strict 2024-07-05 18:48:02 +01:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02: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
Douglas Eichelberger
0191af7899 resolve typecheck errors 2023-11-05 08:55:58 -08: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
7a2aa85225
Only make directories writable when extracting. 2023-02-24 12:28:05 +01:00
Markus Reiter
347bc4535f
Fix permissions for extracted files. 2023-02-24 12:28:04 +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
Markus Reiter
eaca86b0a8
Fix permissions before moving extracted files. 2023-02-19 19:29:21 +01:00
Alexander Bayandin
fe9a039774
unpack_strategy: add zstd 2021-09-20 14:12:30 +01:00
Peter Lewis
362c64855c unpack_strategy: Move Dmg to above Xz and Lzma 2020-11-17 13:10:29 +01:00
Markus Reiter
ab33bc638d Add type signatures for UnpackStrategy::Zip. 2020-10-20 09:50:21 +02:00
Markus Reiter
61b79318ed Move include Kernel into .rbi files again and split up existing .rbi files. 2020-10-10 19:10:58 +02:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
0e7f18a51e Document UnpackStrategy. 2020-08-26 03:13:58 +02:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
L. E. Segovia
c6894a23c1
Only merge extended attributes if required 2019-04-09 21:45:35 +00:00
Mike McQuaid
20e4262fb9
unpack_strategy: prioritise extension instead.
Instead of only looking at the extension when invoked as part of
Homebrew's formulae' download strategies instead prioritise the
extension if it actually exists. When it does not, fall back to the
magic detection logic which is likely to be more reliable.

Fixes https://github.com/Homebrew/brew/issues/5895
2019-04-03 10:32:29 +01:00
Markus Reiter
9db5a41c72 Always make nested container readable and writable. 2018-11-04 17:53:31 +01:00
Mike McQuaid
737b84b54b
brew style --fix fixes. 2018-11-02 17:29:23 +00:00
Markus Reiter
98a6399e46 Force chmod_R after extracting. 2018-10-02 13:33:00 +02:00
Markus Reiter
d9da9b66f0 Make all extracted files writable after extracting. 2018-09-29 10:51:38 +02:00
Markus Reiter
06549c751b Fix extracting .pax archives. 2018-09-11 19:22:19 +02:00
Markus Reiter
b00b1f5ecd Fix detecting P7Zip from symbol. 2018-09-05 00:27:22 +02:00
Mike McQuaid
80d75bc0d8
Homebrew/.rubocop: tweak rules.
Adjust the rules based on the current codebase. Remove various enable,
disables and default values that are unnecessary. Add more comments
explaining why. Make minor changes needed to enable a few more rules.
2018-09-02 20:15:09 +01:00
Markus Reiter
4c80f827ad Only search by extension when unpacking formulae. 2018-08-01 04:16:27 +02:00
Markus Reiter
281ead3096 Look for extension first, then fall back to magic number. 2018-08-01 00:56:36 +02:00
Markus Reiter
a21e7ff742 Move Tar up. 2018-08-01 00:56:36 +02:00
Markus Reiter
e8f7a88976 Only call hdiutil if it’s a bzip2 or zlib. 2018-08-01 00:56:36 +02:00
Markus Reiter
278eace2fa Reorder unpack strategies again. 2018-08-01 00:56:36 +02:00
Markus Reiter
7cf8bb4f8c Add Diff unpack strategy. 2018-08-01 00:56:36 +02:00
Markus Reiter
fc15865760 Reorder unpack strategies. 2018-08-01 00:56:36 +02:00
Markus Reiter
eccd20e276 Merge Hbc::Container classes into UnpackStrategy. 2018-07-24 16:44:27 +02:00
Markus Reiter
b6e54a06e0 Refactor unpack strategies into separate files. 2018-07-23 20:59:28 +02:00
Markus Reiter
c29ab2d707 Fix DirectoryUnpackStrategy permissions. 2018-07-22 22:03:28 +02:00