302 Commits

Author SHA1 Message Date
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
Seeker
b8aa67be5b bottle: add bottle stanza by traversing AST 2020-12-10 13:38:57 -08:00
Michka Popoff
d768b6649a bottle: add tests for json merging
- Extract the json reading from the json merging: it makes the code hard to understand.
This helps for the separation of concerns: the jsons are read in one method;
and merged in a second one
- Added a first test to check the merge function

No change in behaviour was done, this change is just there to increase code coverage
and to prepare for #9315
2020-12-07 19:58:49 +01:00
Markus Reiter
6750448d95 Fix some auto-correctable type errors. 2020-11-29 21:23:54 +01: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
Markus Reiter
1b732ec7b2 Fix RuboCop offenses. 2020-11-16 02:05:29 +01:00
Rylan Polster
20ee7e8881 add Lint/DuplicateBranch cop exceptions 2020-11-16 02:02:52 +01:00
Markus Reiter
da9289eff0 Add more type signatures. 2020-11-13 12:26:36 +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
Seeker
50ce5ef3a4 bottle: fix adding bottle block to formulae with special licenses 2020-11-08 07:23:33 -08:00
Mike McQuaid
4f3c590873
Unify and use Git username/email/GPG handling.
We're using essentially the same logic to setup Git for committing in
multiple places but the way we're doing so is inconsistent. Moved to
using two shared utility methods and use them consistently.
2020-11-02 12:21:18 +00:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Dustin Rodrigues
f41dd1834f bottle: new formula license may be a list, not just a string 2020-09-23 21:08:44 -04:00
Mike McQuaid
fb4d08a49a Fix brew style 2020-09-11 10:29:22 +01:00
Dustin Rodrigues
8ab5ea5249 bottle: use File.lutime instead of system call 2020-09-06 19:43:30 -04:00
Mike McQuaid
8b97c27c21 brew style manual fixes 2020-09-01 14:26:45 +01:00
Mike McQuaid
dbe427073d
Merge pull request #8399 from MLH-Fellowship/migrate-to-args-named
args: Migrate usage of args loading methods to args.named
2020-08-25 10:07:27 +01:00
William Ma
fa7bd3bff6 args: Migrate usage of args loading methods to args.named 2020-08-23 09:02:20 -04:00
Markus Reiter
3118fedab9 Refactor and document Git. 2020-08-23 06:40:07 +02:00
Mike McQuaid
3a91c37e66
Fix RuboCop checks. 2020-08-19 17:12:32 +01:00
Rylan Polster
0ff2f88f39 bottle: fix args 2020-08-01 14:56:11 -04:00
Markus Reiter
9c65a73893 Pass args correctly in brew bottle. 2020-07-31 18:58:07 +02:00
Markus Reiter
d4c2ffd705 Refactor CLI::Parser. 2020-07-31 15:07:17 +02:00
Dawid Dziurla
a8e524d334
bottle: fix inreplace string 2020-07-27 17:23:08 +02:00
vidusheeamoli
fd382d2ecd srb: set utils/inreplace.rb to true and refactor
- Sorbet gives preference to class methods over methods defined in
  included modules, hence Sorbet was unavailable to resolve the
definition of the gsub! method.
- The gsub! method in StringInreplaceExtension conflicts with the definition in String.
- This PR refactors the call to the gsub! method so that a custom object
  is exposed instead of a string.
2020-07-26 12:43:31 +05:30
Shaun Jackman
e2db288340 bottle --merge: Fix bug with cellar :any
When merging cellar, :any ought to have higher priority than
:any_skip_relocation.
The variables first and second are strings, not tags.
2020-07-10 09:46:05 -07:00
Bo Anderson
0e3f22e1df dev-cmd/bottle: fix positioning of bottle block in some cases 2020-07-01 23:51:23 +01:00
Mike McQuaid
aa81982aba
brew style --fix 2020-06-02 09:49:23 +01:00
Mike McQuaid
29fd98960c
Revert "bottle: author bottle commit as BrewTestBot" 2020-04-01 16:20:35 +01:00
Dawid Dziurla
96cd210f8f
bottle: author bottle commit as BrewTestBot 2020-03-31 16:26:10 +02:00
Mike McQuaid
1e265247ca
rubocop: apply autofixes. 2020-03-13 21:16:18 +00:00
Mike McQuaid
e3ac94fc5d
dev-cmd: use more and cleanup new args APIs. 2020-03-05 09:40:15 +00:00
Mike McQuaid
f31e01c3ad
test: set Git name and email.
Extract the code from `bottle.rb` into `utils/git.rb` and ensure it's
run before we run tests.

Should resolve issues like in
https://github.com/Homebrew/homebrew-core/pull/50328
2020-02-17 19:40:44 +00:00
Dawid Dziurla
c80107c8a2
bottle: prioritize HOMEBREW_CELLAR over :any over :any_skip_relocation 2020-02-10 21:39:36 +01:00
Shaun Jackman
7f4c7e0afc bottle: Elide root_url only if it is the default
Elide root_url only if it is precisely equal to the default root_url.
Eliding root_url when a prefix matches the default also elides
a custom root_url such as https://linuxbrew.bintray.com/bottles-bio.
2020-01-26 22:04:41 -08:00
Mike McQuaid
ea1a3ea6e0
dev-cmd/bottle: run sudo --purge non-interactively.
This should avoid hanging if permissions are not granted.
2020-01-15 10:48:13 +00:00
Mike McQuaid
36dac3d41f
dev-cmd/bottle: add HOMEBREW_BOTTLE_SUDO_PURGE.
Add environment variable to optionally run `sudo purge` a few times to
potentially work around #6539.
2020-01-14 15:09:13 +00:00
Gautham Goli
959b88266d
ARGV: Replace usages of ARGV.resolved_formulae with Homebrew.args 2020-01-02 13:56:19 +00:00
Gautham Goli
685a6b4da6 ARGV: Replace usages of ARGV.named with Homebrew.args.named 2019-12-18 20:38:21 +05:30
EricFromCanada
90e830c19e cmd: add raises for invalid input 2019-12-15 00:04:45 -05:00
EricFromCanada
2f7c3afeb8 cmd: improve wording of messages, spacing 2019-12-15 00:04:45 -05:00
Mike McQuaid
6decac5875
Merge pull request #6803 from MikeMcQuaid/latest_version_installed
Rename Formula#installed? to Formula#latest_version_installed?
2019-12-03 12:09:01 +00:00
Mike McQuaid
5dd8ead51a
Rename Formula#installed? to Formula#latest_version_installed?
This naming has always been a bit weird and confusing so let's change
it and provide a `compat` fallback for later deprecation.
2019-12-03 11:42:42 +00:00
EricFromCanada
b817796562 Grammar fixes for status messages 2019-12-02 11:38:06 -05:00
Mike McQuaid
176297d361
Handle 2.2.0 deprecations/disableds
- Make all `odeprecated` from 2.1.0 `odisabled` instead
- Remove dead code that won't be run now
- Remove (unused) `or_later` handling for bottles
2019-11-06 15:25:40 +00:00
Mike McQuaid
ddcbdbe0c0
formula: cache runtime_dependencies related stuff. 2019-11-06 10:04:13 +00:00
Mike McQuaid
eeb9ac36a2
keg: cache runtime_dependencies. 2019-11-06 10:04:13 +00:00
Jonathan Chang
81db0e9551 dev-cmd: enable frozen string literals
Now that we use Ruby 2.6 we can fix these last two files.
2019-11-04 21:00:20 +11:00
Mike McQuaid
333642927b
Merge pull request #6607 from dawidd6/keep-old-but-not-cellar
bottle: don't keep old cellar
2019-10-21 13:37:17 +01:00
Dawid Dziurla
aa9950282f
bottle: set bottle.cellar to old_spec.cellar if deleting mismatch
Co-Authored-By: Mike McQuaid <mike@mikemcquaid.com>
2019-10-21 14:11:08 +02:00