120 Commits

Author SHA1 Message Date
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
Rylan Polster
db8f54cea1
keg_relocate: only replace matches at the start of a path 2021-05-11 14:26:13 -04:00
Bo Anderson
5f41016267
Support handling of rewriting shebangs with flags
Fixes #11108.
2021-05-10 06:13:58 +01:00
Bo Anderson
ae49b06600
keg_relocate: replace Perl shebangs 2021-05-10 06:13:54 +01:00
hyuraku
e6eeb2cbed delete HOMEBREW_REPOSITORY & some variables 2021-01-27 00:29:43 +09:00
Seeker
b9854bd4cf rubocops: add unless_multiple_conditions 2021-01-08 10:33:54 -08:00
Mike McQuaid
e2d032a6b6
keg_relocate: ensure @@HOMEBREW_REPOSITORY@@ is always relocated.
This will be needed to pour older bottles after 2.7.0.
2020-12-18 13:50:10 +00:00
Mike McQuaid
0bbf965807
More bottling HOMEBREW_LIBRARY changes
- Refuse to create bottles which have non-relocatable references to
  `HOMEBREW_LIBRARY`. This allows us to make all bottles ignore where
  `HOMEBREW_REPOSITORY` is (even those that aren't `cellar :any`).
  I cannot see any circumstances in which any bottle should link to
  anything within `HOMEBREW_REPOSITORY`.
- Remove audit that becomes unnecessary given the above change.
- Relocate references to `@HOMEBREW_LIBRARY@` but don't actually write
  any references yet. This will allow us to move to using
  `@HOMEBREW_LIBRARY` and remove all relocation of `HOMEBREW_REPOSITORY`
  in a future release (2.7.1, most likely).
2020-12-18 13:50:10 +00:00
Shaun Jackman
c56681a227 Comment needed changes if HOMEBREW_LIBRARY changes 2020-12-16 14:03:10 -08:00
Shaun Jackman
65b9e1231d Relocate HOMEBREW_LIBRARY conditionally
Relocate HOMEBREW_LIBRARY conditionally when
HOMEBREW_PREFIX = HOMEBREW_REPOSITORY.
2020-12-15 12:47:08 -08:00
Shaun Jackman
4edf28409d Relocate @@HOMEBREW_REPOSITORY@@/Library
Ensure that $HOMEBREW_REPOSITORY/Library is relocated to
@@HOMEBREW_REPOSITORY@@/Library even when
HOMEBREW_PREFIX = HOMEBREW_REPOSITORY.
2020-12-15 12:47:08 -08:00
Mike McQuaid
0f9bad0052
Fix bottle prefix and repository handling
We were previously only looking at the `cellar` value when pouring
bottles and ignoring the `prefix` and (implicit) `repository`.

Actually look at these values and set the defaults for each platform.

Also, when we're relocating to create or pour bottles when `prefix`
and `repository` are equal then skip relocating the `repository` and
always use references to the `prefix` instead.

Fixes #9453
2020-12-09 13:53:10 +00:00
Mike McQuaid
9216d8abe6
rubocop-rails: make fixes. 2020-12-02 10:43:04 +00:00