269 Commits

Author SHA1 Message Date
Douglas Eichelberger
403f08db8b Remove delegation 2023-04-16 09:30:21 -07:00
Douglas Eichelberger
b90897e280 Create git_repo attr 2023-04-15 19:35:13 -07:00
Douglas Eichelberger
429f23dcc6 Create GitRepoPath 2023-04-15 19:35:12 -07:00
apainintheneck
801ee5e474 Address feedback
- style nits
- better comments for tests that are not idempotent
- moved appdir placeholder constant to global.rb
2023-03-22 19:43:49 -07:00
apainintheneck
38146893c3 api_hashable: Make API path subs generic
This turns the ability to replace common paths with placeholders
into a mixin that can be used with both Casks and Formulae.

The idea here is to make formula hash generation more consistent.
2023-03-21 23:20:42 -07:00
Douglas Eichelberger
cc5b013cb9 Remove compatibility layer 2023-03-14 14:49:34 -07:00
Douglas Eichelberger
1943132cf6 Move i18n out of global 2023-03-11 17:27:53 -08:00
Mike McQuaid
5631310653
Auto-update from the API less often
Instead of doing so literally whenever we query for a formula, Instead
do so only when we're in an auto-updateable command.

This better fits the existing behaviour while still updating when it's
most important to do so.
2023-03-10 17:53:15 +00:00
Douglas Eichelberger
7aab1c2a38 Remove ActiveSupport String inflections 2023-03-07 10:16:52 -08:00
Douglas Eichelberger
e68b02c4a6 Move tests and requires 2023-03-03 12:44:23 -08:00
Douglas Eichelberger
91ad24b876 Remove Array#to_sentence monkey-patch 2023-03-03 12:44:22 -08:00
Bo Anderson
e86a8c2477
Move HOMEBREW_NO_INSTALL_FROM_API defaults to shell 2023-02-24 21:53:08 +00:00
Mike McQuaid
2884b1649b
api: don't download files as root when Homebrew's not owned by root.
This was mentioned in a random comment. While we're here, make some
helper functions to query this a bit more nicely elsewhere when we do
it.
2023-02-23 10:04:50 +00:00
Mike McQuaid
c5252817c2
analytics: refactor InfluxDB/Google handling. 2023-02-15 16:34:50 +00:00
Mike McQuaid
237eec8ef8
Overhaul Formula/Cask JSON generation
- Use constants for placeholders
- Monkeypatch to set `HOMEBREW_PREFIX` consistently to placeholder
- Use environment variable to set `Dir.home` consistently to placeholder
- Use `appdir` short-circuit to set `Cask#appdir` consistently to placeholder
- Use `Cask.generating_hash!` to enable "generating mode" with these patches
- Fix `Formula#caveats` from JSON

Fixes #14505
Fixes #14595
2023-02-14 14:19:40 +00:00
Mike McQuaid
179974ce26
Merge pull request #14502 from dduugg/active-support-reduce
Remove active_support Time extensions
2023-02-05 11:51:48 +01:00
Douglas Eichelberger
24e7c2c5bd Remove active_support Time extensions 2023-02-04 13:51:35 -08:00
Xuehai Pan
ba3bccf9ed api: download from HOMEBREW_API_DOMAIN 2023-02-04 13:05:20 +00:00
Douglas Eichelberger
e98e668a34 remove redundant string extension 2023-01-28 08:26:11 -08:00
Mike McQuaid
77c0d38c35
brew style --fix 2022-12-13 11:37:06 +00:00
Troy McCabe
ac9a96874e Adds brew docs to close #13834 2022-09-11 22:10:37 -05:00
Rylan Polster
ac067eedb2
Create MacOSVersions module 2022-06-29 11:34:49 -04:00
Bo Anderson
02164a35db
Use ORIGINAL_PATHS over envs; reject nil PATH 2022-06-17 19:47:57 +01:00
Bo Anderson
cd73e6bac5
Introduce more Ruby constants for values set by brew.sh 2022-06-17 19:47:57 +01:00
Mike McQuaid
04938efc24
Unify GitHub Packages authorization logic in brew.sh. 2022-01-27 15:44:34 +00:00
Mike McQuaid
0cda6a0657
Only use patchelf.rb
Remove support for using the `patchelf` formula for writing as it's been
off by default for a long time now.
2021-10-19 15:15:56 +01:00
Bo Anderson
861dea9ada
Bump various type strictnesses 2021-09-11 01:00:23 +01:00
Bo Anderson
a06d136d2c
Move Sorbet gems into an optional group 2021-06-11 08:10:30 +01:00
Markus Reiter
59f4a711cd
Deprecate _fetch without timeout option. 2021-04-03 20:10:33 +02:00
Markus Reiter
b6ed8915e5
Add compatibility layer for AbstractDownloadStrategy#fetch. 2021-04-03 20:10:33 +02:00
Mike McQuaid
d8a2cf9efc
Write tabs to bottle JSON, optionally not bottle
- Write a subset of the tab required for bottles as an annotation.
- Add option on new bottle creation to skip writing tab into bottle
  and instead add it (and other useful metadata) to bottle JSON.
- Read formula information and tab from bottle JSON.
- Write prettier JSON to disk.
- Don't write `HEAD` to tab; this duplicates `HOMEBREW_VERSION`.
- Allow `brew bottle` to use `--json` to generate JSON files from a
  local bottle file.
2021-03-31 09:43:37 +01:00
Mike McQuaid
3f00d08544
dev-cmd/pr-upload: some refactoring
- make the description more generic/correct
- use "internet archive" over "archive"
- move some logic to a new `GitHubReleases` class (for consistency)
- remove some obvious comments
- extract out and move some constants
2021-03-11 14:49:56 +00:00
Bo Anderson
1fba9b9b53
Prevent loading all non-Bundler gems 2021-02-26 18:23:48 +00:00
Mike McQuaid
e65e310fd0
Fix brew style 2021-01-29 20:56:59 +00:00
Mike McQuaid
683ae7ff53
Add HOMEBREW_BOOTSNAP to optionally use Bootsnap
> Bootsnap is a library that plugs into Ruby, with optional support
> for ActiveSupport and YAML, to optimize and cache expensive
> computations.
https://github.com/Shopify/bootsnap

For our case that translates to "repeated calls to `brew` have
reductions in the time spend `require`ing speeding up the process
boot time".

For example:

```
$ hyperfine --warmup=2 "unset HOMEBREW_BOOTSNAP; brew info wget" "export HOMEBREW_BOOTSNAP=1; brew info wget"
Benchmark #1: unset HOMEBREW_BOOTSNAP; brew info wget
  Time (mean ± σ):      2.417 s ±  0.032 s    [User: 659.0 ms, System: 855.5 ms]
  Range (min … max):    2.382 s …  2.464 s    10 runs

Benchmark #2: export HOMEBREW_BOOTSNAP=1; brew info wget
  Time (mean ± σ):      1.862 s ±  0.064 s    [User: 425.3 ms, System: 566.8 ms]
  Range (min … max):    1.736 s …  1.952 s    10 runs

Summary
  'export HOMEBREW_BOOTSNAP=1; brew info wget' ran
    1.30 ± 0.05 times faster than 'unset HOMEBREW_BOOTSNAP; brew info wget'
```
2021-01-21 12:34:04 +00:00
Seeker
cdb07d89ae integration_test: fix indentation for test formulae 2020-12-21 16:17:39 -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
7439a9b8a2
global: add more active_support includes. 2020-11-30 16:27:47 +00:00
Markus Reiter
7348185347 Reorder global. 2020-11-30 00:00:02 +01:00
Jonathan Chang
f98736119b global: fix default prefix 2020-11-27 15:36:04 +11:00
Michka Popoff
95bf529ad2 bottle merge: add support for linux cellar
The first attempt to build and pull a formula (hello) for linux in homebrew-core
resulted in a wrong cellar line being added to the formula's bottle block.

How to test/debug this, using the 4 bottles that where built for hello:
brew bottle --merge --debug hello--2.10_1.mojave.bottle.json hello--2.10_1.x86_64_linux.bottle.json hello--2.10_1.big_sur.bottle.json hello--2.10_1.catalina.bottle.json

This command would add create the following bottle block:

  bottle do
    cellar "/home/linuxbrew/.linuxbrew/Cellar"
    sha256 "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f" => :big_sur
    sha256 "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac" => :catalina
    sha256 "22948764d8f8d7be4870ff92dae64d986eb63a9150b219c20fff87d1a6aa93d6" => :mojave
    sha256 "702dc7f78444d2f4f1c19324be654bcbb8b99dd0e9ce26c3e2fbc3b6464a189f" => :x86_64_linux
  end

After the change in this PR, the result is the following:

  bottle do
    sha256 "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f" => :big_sur
    sha256 "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac" => :catalina
    sha256 "22948764d8f8d7be4870ff92dae64d986eb63a9150b219c20fff87d1a6aa93d6" => :mojave
    sha256 "702dc7f78444d2f4f1c19324be654bcbb8b99dd0e9ce26c3e2fbc3b6464a189f" => :x86_64_linux
  end

The brew bottle --merge code will pick the most common cellar line between the 4 bottles, by order of priority:
- non-relocatable (fixed cellar path)
- cellar :any
- cellar :any_skip_relocation

In the case of the hello bottle, the 3 mac bottles are "cellar :any_skip_relocation", and the linux bottle
is non-relocatable. So the linux bottle wins and the code correctly determines that the 4 bottles should
be non-relocatable.

In that case, the /home/linuxbrew/.linuxbrew/Cellar path is defined as cellar, and by convention
we do not write that out to the formula file, hence the cellar path check that needs to be modified
in this PR.

This PR also fixes the same situation for mac ARM cellar paths
2020-11-26 15:11:55 +01:00
Mike McQuaid
5afff3f3aa
Handle macOS Homebrew on ARM
- Output `brew doctor` and `brew install` messages noting this configuration is (currently) unsupported and encourage use of Rosetta instead
- Output Rosetta 2 usage in `brew config` on ARM (whether in Rosetta 2 or not)
- Check the architecture of (newly installed) dependencies and ensure they are using the correct architecture.
- Don't allow installing macOS Intel Homebrew in macOS ARM Homebrew default prefix (and vice versa
- Actually write out the architecture of dependencies to the tab rather than generating and throwing them away
- Set and document the expected default prefix for macOS Intel Homebrew, macOS ARM Homebrew (`/opt/homebrew`) and Homebrew on Linux

While we're here:
- Don't say Big Sur is a prerelease version but still make it clear we
  don't support it (yet).
- Don't reference non-existent IRC channel
2020-11-12 17:06:47 +00:00
Markus Reiter
5bc626bbe1 Completely deprecate Homebrew.args. 2020-11-11 08:52:55 +01:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
d36df37099 Replace custom stubs with sorbet-runtime-stub. 2020-10-09 16:45:13 +02:00
Dawid Dziurla
f6601cee10
Support bottle uploads to GitHub Releases
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2020-09-12 13:03:39 +02:00
Maxim Belkin
a6d29894d9 cleanup: fix and reuse portable ruby logic.
Align the logic in `cleanup_portable_ruby` with that in `ruby.sh`.

Co-authored-by: Maxim Belkin <maxim.belkin@gmail.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2020-09-03 09:43:41 +01:00
Mike McQuaid
8b97c27c21 brew style manual fixes 2020-09-01 14:26:45 +01:00
Bo Anderson
e6b30e4065 cask/dsl/depends_on: fix missing require 2020-08-21 18:40:04 +01:00
Bo Anderson
e3372e2a14 Lazily require some heavy files 2020-08-20 02:05:17 +01:00