374 Commits

Author SHA1 Message Date
Mike McQuaid
dc71b7c8f6
Cleanup extend/ directory usage.
- move some things out of `extend` that don't really fit there e.g.
  `Module`s that are included but not doing any
  overriding/monkeypatching
- move some code into `extend/os` to fix all remaining
  `rubocop:todo Homebrew/MoveToExtendOS`s
- remove some unneeded `bundle` skipper code that doesn't really make
  sense given our current bottling strategy
- extract some `Pathname` extensions to `extend/pathname` for separate
  files
- move a `ENV` `Kernel` extension into `kernel.rb`
- `odeprecate` a seemingly unused backwards compatibility method
- move `readline_nonblock` from a monkeypatch to a
  `ReadlineNonblock.read` method as its only used in one place
- fix up a link in documentation
2025-06-09 19:06:16 +01:00
Mike McQuaid
c72386e3c3
bundle/commands/cleanup: correctly handle .keepme references.
Extract the relevant logic from `formula.rb`, moving to `keg.rb` and
then use this logic in `bundle/commands/cleanup.rb` to ensure that we
don't say we need to uninstall formulae that should be still kept.
2025-04-01 15:12:12 +01:00
Caleb Xu
7f28b979af
keg: fix normalize_pod2man_outputs! for non-UTF-8 manpages 2025-03-10 03:06:46 -04:00
Heath Stewart
42caf20fa4
Add PowerShell (pwsh) completion support
Resolves #19403
2025-03-02 18:17:38 -08:00
Caleb Xu
b5db95bee5
keg: fix normalize_pod2man_outputs! for compressed manpages 2025-02-28 03:30:27 -05:00
Caleb Xu
0c2c76351c
Merge pull request #19174 from alebcay/pod2man-shim
Clean pod2man-generated manpages after formula build
2025-02-26 13:55:34 +00:00
Sam Ford
a7cacfff1c
livecheck: refactor HEAD-only formula handling
The existing code for handling a `HEAD`-only formula involves two
return values that can be `nil` but this isn't apparent because the
related methods aren't typed. This adds type signatures to the
methods and updates the livecheck code to account for `nil` return
values (making it clear which methods can return `nil`).

Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2025-02-20 22:39:18 -05:00
Caleb Xu
652f5966d4
Clean pod2man-generated manpages after formula build 2025-02-03 23:21:44 -05:00
Douglas Eichelberger
ed4129b580 Remove removable constants 2024-10-07 19:45:48 -07:00
Douglas Eichelberger
8033fcf4a6 Fix brew style docs 2024-10-07 18:59:27 -07:00
Douglas Eichelberger
2d16333bbc Replace removable constants with overridable methods 2024-10-07 18:33:03 -07: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
Ruiyang Wu
401b45fb01 keg: Install gziped info files during linking
Currently, `brew link` installs `*.info` files to
`#{HOMEBREW_PREFIX}/share/info/dir` using the `install_info` method.
However, some formulae (e.g., `Emacs`) also ship `*.info.gz` files,
which are only `symlink`ed but not installed.

This commit allows `*.info.gz` files to be installed during linking in
addition to the `*.info` files.
2024-09-21 22:28:24 -04:00
Michael Cho
39ab6d70db
keg: avoid attempting rmdir on must exist subdirs 2024-09-05 13:37:25 -04:00
Issy Long
45978435e7
rubocop: Use Sorbet/StrictSigil as it's better than comments
- Previously I thought that comments were fine to discourage people from
  wasting their time trying to bump things that used `undef` that Sorbet
  didn't support. But RuboCop is better at this since it'll complain if
  the comments are unnecessary.

- Suggested in https://github.com/Homebrew/brew/pull/18018#issuecomment-2283369501.

- I've gone for a mixture of `rubocop:disable` for the files that can't
  be `typed: strict` (use of undef, required before everything else, etc)
  and `rubocop:todo` for everything else that should be tried to make
  strictly typed. There's no functional difference between the two as
  `rubocop:todo` is `rubocop:disable` with a different name.

- And I entirely disabled the cop for the docs/ directory since
  `typed: strict` isn't going to gain us anything for some Markdown
  linting config files.

- This means that now it's easier to track what needs to be done rather
  than relying on checklists of files in our big Sorbet issue:

```shell
$ git grep 'typed: true # rubocop:todo Sorbet/StrictSigil' | wc -l
    268
```

- And this is confirmed working for new files:

```shell
$ git status
On branch use-rubocop-for-sorbet-strict-sigils
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Library/Homebrew/bad.rb
        Library/Homebrew/good.rb

nothing added to commit but untracked files present (use "git add" to track)

$ brew style
Offenses:

bad.rb:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
^^^^^^^^^^^^^

1340 files inspected, 1 offense detected
```
2024-08-12 15:24:27 +01:00
Mike McQuaid
c5dbd3ca24
Rearrange requires
This improves the load time of most brew commands. For an example of
one of the simplest commands this speeds up:

Without Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     525.0 ms ±  35.8 ms    [User: 229.9 ms, System: 113.1 ms]
  Range (min … max):   465.3 ms … 576.6 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     383.3 ms ±  25.1 ms    [User: 133.0 ms, System: 72.1 ms]
  Range (min … max):   353.0 ms … 443.6 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.37 ± 0.13 times faster than git checkout master; brew help
```

With Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     386.0 ms ±  30.9 ms    [User: 130.2 ms, System: 93.8 ms]
  Range (min … max):   359.5 ms … 469.3 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     330.2 ms ±  32.4 ms    [User: 93.4 ms, System: 73.0 ms]
  Range (min … max):   302.9 ms … 413.9 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.17 ± 0.15 times faster than git checkout master; brew help
```
2024-07-14 08:49:39 -04:00
Markus Reiter
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02:00
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Markus Reiter
0b56d0be4a
Document Tab.for_keg and use Keg#tab where possible. 2024-04-28 20:50:13 +02:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Markus Reiter
c76170a456
Hide #to_s in docs. 2024-04-26 14:04:55 +02:00
Markus Reiter
fe4ef62aa9
Hide #inspect in docs. 2024-04-26 13:20:05 +02:00
Mike McQuaid
4c0a1c7a02
keg: remove unused python methods. 2024-04-15 08:35:32 +01:00
Michael Cho
060fb92527
keg: comment to odeprecated some Python 2 related methods
Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-04-14 19:58:16 -04:00
Michael Cho
514059da4b
keg: mkpath on main postgresql@X directories
Fix logic in #16966 as it only matched subdirectories

Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-04-11 10:26:28 -04:00
apainintheneck
db507be41a keg: update sorting by version logic
This updates logic to add a `#scheme_and_version` method to be used
with `.sort_by` and `.max_by`. Using `Keg#version` by itself can be
inaccurate when different version schemes are present. This also
updates the behavior of `Formula#eligible_kegs_for_cleanup` to match
the previous behavior. We were dropping the wrong keg based on the
sort being reversed in a previous PR.
2024-03-31 17:52:32 -07:00
Bo Anderson
dd382487c7
Sort kegs based on version scheme 2024-03-29 23:33:41 +00:00
Michael Cho
babb352aef
keg: mkpath while linking {include,lib,share}/postgresql@X
Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-03-28 17:26:58 -04:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Markus Reiter
3472362ddd
Don't stub all Pathnames in tests. 2024-02-13 18:46:58 +01:00
Jason Karns
79a8279b2c
Improve user ergonomics of brew link --overwrite help
When a Keg is unlinked, brew-link gives a helpful message for how to proceed: adding the `--overwrite` flag.

For safety, it also recommends running in `--dry-run` mode first to see what would be deleted.

So a user's common flow would be:

1. run `brew link foo`
2. get error message with guidance
3. run `brew link --overwrite --dry-run foo`
4. inspect
5. run `brew link --overwrite foo`

In this flow, steps 3-5 are likely very common. Common enough that a user may use their shell history to re-populate their prompt with step 3's command, delete the `--dry-run` flag, and re-run. (The end goal, of course, is to link `foo`.)

The `--dry-run` flag needs to be removed from the command, of course. If it had been at the _end_ of the command, it would make the subsequent  modification easier.

Instead of "up arrow, left-arrow a bunch, then backspace over --dry-run, hopefully not backspacing over the formula name", it would be easier for the user if the dry-run flag were already at the end of the command. Then the user can "up arrow, backspace a few times and hit enter".

What's more, if the last arg were `--dry-run`, a more advanced bash user could even use `!:-` to re-run the link command with all-but-the-last-arg.
2024-02-12 09:29:21 -05:00
Issy Long
f682147598
Fix RuboCop Style/RedundantFreeze offenses 2024-01-18 22:20:01 +00:00
Bo Anderson
a696bd8203
Support multiple oldnames for formulae 2023-04-27 05:15:43 +01:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Douglas Eichelberger
adfd12cfd0 Enable more typing 2023-03-21 21:42:51 -07:00
Douglas Eichelberger
1943132cf6 Move i18n out of global 2023-03-11 17:27:53 -08:00
hyuraku
3f553a8ead add linux's binary_executable_or_library_files to keg 2023-01-26 21:41:45 +09:00
Mike McQuaid
4a0e16fbd9
dev-cmd/bottle: use gnu-tar's --mtime.
This allows us to remove all the manual timestamp fiddling and lets
`gnu-tar` handle it for us instead (as-per the most recent
recommendations on https://reproducible-builds.org/docs/archives/).
2022-12-12 16:47:56 +00:00
Lukas Oberhuber
e46a61e181 rename & inline dsymutil to prepare_debug_symbols 2022-07-30 11:08:52 +01:00
Lukas Oberhuber
f4cb9a40a6
remove macos specific dummy call
Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
2022-07-26 11:26:03 +01:00
Lukas Oberhuber
e1ea9da507 Conceptual draft of dsym support for macos 2022-07-26 00:00:45 +01:00
Carlo Cabrera
0780d06015
keg: create subdirectories of lib/lua instead of symlinks
Some formulae (e.g. `luv`) have a `lib/lua/5.1` subdirectory inside
their keg. Before this change, the `5.1` subdirectory is symlinked into
`HOMEBREW_PREFIX`.

This can result in `luarocks` installing things into a formula's keg,
which we don't want.

Let's fix that by making sure that `brew link` creates these
subdirectories instead of symlinking them. We already do this for
subdirectories of `share/lua`:

8dd96ae8ba/Library/Homebrew/keg.rb (L430)
2022-07-11 10:10:38 +08:00
danielnachun
3b089ee901
keg.rb: add generic codesign_patched_binary method 2022-04-08 18:09:18 -07:00
Bo Anderson
ebda92f908
Revert "Binary patching of build prefixes " 2022-03-21 18:22:36 +00:00
danielnachun
35f426e3e2
keg.rb: add generic codesign_patched_binary method 2022-03-12 17:46:09 -08:00
Carlo Cabrera
10edae9b94
Merge pull request #11644 from carlocab/cpuid-check
formula_cellar_checks: check for `cpuid` instruction when needed
2021-07-06 06:29:27 -07:00
Carlo Cabrera
c59a42b24e
formula_cellar_checks: check for cpuid instruction when needed
This implements the second audit discussed in #11608.
2021-07-04 00:31:31 +01:00
Carlo Cabrera
d88576a89b
keg, cmd/--prefix: handle python3.10 2021-07-03 23:33:09 +01:00
nandahkrishna
f7f9433443
Keg.find_some_installed_dependents: move to installed_dependents.rb 2021-02-12 01:42:17 +05:30
nandahkrishna
56ebffff7a
Refactor code to find dependents of kegs 2021-02-10 11:41:48 +05:30