132 Commits

Author SHA1 Message Date
Daeho Ro
cba6e40e77
keg_relocate: add more relocation paths 2025-09-05 14:48:12 +09:00
Bo Anderson
4d43063060
Fix formula installs without a tab 2025-08-18 20:23:19 +01:00
Mike McQuaid
8a7cebfbb0
keg_relocate: add more /usr/local relocation pairs.
This should get more of the cases where we install things into
HOMEBREW_PREFIX but scoping them to the formula's name to avoid
accidental unneccessary relocations preventing `cellar :any` bottles.
2025-08-18 15:06:17 +01:00
Mike McQuaid
22fdb11e00
**/keg_relocate.rb: add set Sorbet typed: strict
Other files have been changed where required.
2025-08-18 15:02:15 +01:00
copilot-swe-agent[bot]
9328a55c54
Fix overzealous /usr/local prefix replacement
Co-authored-by: MikeMcQuaid <125011+MikeMcQuaid@users.noreply.github.com>
2025-08-13 16:22:09 +01:00
Carlo Cabrera
c9060c3242
Improve test for bottling 2025-08-13 09:51:27 +08:00
Patrick Linnane
4513a43d53
Fix RuboCop failures.
Co-authored-by: Patrick Linnane <patrick@linnane.io>
Co-authored-by: Carlo Cabrera <github@carlo.cab>
Co-authored-by: Thierry Moisan <thierry.moisan@gmail.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2025-07-14 19:12:38 +01:00
Mike McQuaid
9ac306e464
Remove alias generic_* definitions in favour of using super
This is the pattern we've been adopting for a while and it's a bit
cleaner. Let's remove all of the existing usage of the existing pattern
to avoid confusion when adopting the new one.
2025-06-16 08:10:08 +00:00
Bo Anderson
28f19878e3
keg_relocate: fix error when dylib_id doesn't need changing 2024-10-26 06:31:05 +01:00
Douglas Eichelberger
eed660e784 Move remaining OS extensions to prepend 2024-10-05 12:18:29 -07:00
Michael Cho
04381b26dd
keg_relocate: allow spaces/tabs after shebang 2024-08-23 22:56:15 -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
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Douglas Eichelberger
c4db19232d git grep -lE '\(\&[A-Za-z._]+method\(:' | xargs gsed -i -E 's|\(\&([A-Za-z._]+)method\(:([a-z?_]+)\)\)| { \1\2(_1) }|g' 2024-03-03 18:55:56 -08:00
Issy Long
f682147598
Fix RuboCop Style/RedundantFreeze offenses 2024-01-18 22:20:01 +00:00
Douglas Eichelberger
caf8259ae6 Code review changes 2023-12-27 15:29:33 -08:00
Douglas Eichelberger
3abbf4447e Some minor regexp match perf improvements 2023-12-27 13:16:36 -08:00
Bo Anderson
e5346d8aac
keg_relocate: fix all text files being marked as changed 2023-07-28 00:43:30 +01:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Douglas Eichelberger
02fd0422aa Enable typing in a few more files 2023-03-09 13:42:06 -08:00
Michka Popoff
d271614872
install glibc/gcc automatically if too old.
Right now this is done through the gcc@5 formula.
See 9692318ca6/Formula/gcc%405.rb (L33)

This is fragile because when we will migrate to gcc@11
we have to think about migrating the installation from one gcc formula to another..
Also, not having the right glibc version results in a non-functional brew
installation on an older Linux: the glibc installation needs
to be done by brew, and not by a workaround in a specific formula

Co-Authored-By: Mike McQuaid <mike@mikemcquaid.com>
Co-Authored-By: Bo Anderson <mail@boanderson.me>
Co-Authored-By: Shaun Jackman <sjackman@gmail.com>
2022-08-25 11:04:37 +01:00
Mike McQuaid
c294dcc616
glibc related cleanup
Extracted from https://github.com/Homebrew/brew/pull/13577
2022-08-23 12:42:02 +01:00
Rylan Polster
ea1f2098ac
Move HOMEBREW_SIMULATE_MACOS_ON_LINUX handling to SimulateSystem 2022-07-28 15:04:25 -04:00
Bo Anderson
2ddce84225
Remove Keg.relocation_formulae
We no longer use any formulae for relocation.
2022-06-30 03:39:29 +01:00
danielnachun
c4032ac9c9
keg_relocate.rb: rebase 2022-04-12 15:53:03 -07:00
Bo Anderson
ebda92f908
Revert "Binary patching of build prefixes " 2022-03-21 18:22:36 +00:00
danielnachun
ce2d8adf38
keg_relocate.rb: rebase 2022-03-12 17:46:08 -08:00
danielnachun
3d2d1edaa3
keg_relocate.rb: add binary_file? method 2022-03-09 13:33:49 -08:00
Bo Anderson
62e1f41f9b
Revert "keg_relocate.rb: create generic codesign_patched_binary"
This reverts commit 39fc3862538fa5226f4d17e94f1e1c74b7eadeb2.
2022-03-04 18:53:24 +00:00
danielnachun
39fc386253
keg_relocate.rb: create generic codesign_patched_binary 2022-03-03 17:34:50 -08:00
danielnachun
989db5dfb5
keg_relocate.rb: add each_unique_binary_file 2022-02-28 08:59:33 -08:00
Mike McQuaid
a37f24f439
Revert "Binary patching of build prefixes" 2022-02-14 10:55:08 +00:00
danielnachun
606c4ed31d
keg_relocate.rb: move constant 2022-02-11 12:45:31 -08:00
danielnachun
edf8327497
keg_relocate.rb: add new methods 2022-02-10 22:48:44 -08:00
Rylan Polster
c07bf0d38f
Add -F to allowed prefixes
Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
2021-11-08 19:13:42 -05:00
Rylan Polster
febcdddf96
Keg::Relocation: allow -I, -L, -isystem prefixes 2021-11-08 19:13:41 -05:00
Carlo Cabrera
aa95c17c8e
keg_relocate: enable Java relocation for bottles
This is a continuation of #12334.
2021-10-30 01:34:00 +08:00
Carlo Cabrera
92c9d61e4f
Skip bottle relocation for now.
We need to have the pour relocation in a `brew` release tag before we
can enable this.

Also, add the empty line that the GitHub UI ate when I committed a
suggestion.
2021-10-27 20:11:47 +08:00
Carlo Cabrera
12f5e196f8
Fix trailing white space 2021-10-27 20:11:47 +08:00
Carlo Cabrera
457de40117
Apply suggestions from code review
These are just a few style improvements.

Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2021-10-27 20:11:47 +08:00
Carlo Cabrera
96f0441178
Fix tests
`runtime_dependencies` is sometimes `nil`.
2021-10-27 20:11:46 +08:00
Carlo Cabrera
91e425f7dd
keg_relocate: handle JAVA_HOME
Java-dependent formulae produce different bottles on macOS and Linux
because they have different values for `JAVA_HOME` (`opt_libexec` vs
`opt_libexec/"openjdk.jdk/Contents/Home"`).

Let's handle this difference by using the placeholder
`@@HOMEBREW_JAVA@@` in a bottle, like so:

    #!/bin/bash
    JAVA_HOME="${JAVA_HOME:-@@HOMEBREW_JAVA@@}" exec "@@HOMEBREW_CELLAR@@/clojure/1.10.3.998/libexec/bin/clojure"  "$@"
2021-10-27 20:11:46 +08:00
Rylan Polster
4457dc904b
Cleanup using suggestions from code review 2021-05-13 11:02:39 -04:00
Rylan Polster
309e9e1c52
Remove Keg::Relocation#start_with_old_value? method 2021-05-11 15:45:43 -04:00
Rylan Polster
7d49dba7e9
Fix Keg::Relocation::start_with_old_value? 2021-05-11 14:28:47 -04:00
Rylan Polster
875282bc06
Add more keg relocation tests 2021-05-11 14:28:47 -04:00
Rylan Polster
f13f7b9326
Only use path regex when requested 2021-05-11 14:28:47 -04:00
Rylan Polster
5f781770b4
Extract Keg::text_matches_in_file from bottle command 2021-05-11 14:26:14 -04:00
Rylan Polster
fe7f80f647
Refactor out and correctly create path regex 2021-05-11 14:26:14 -04:00