311 Commits

Author SHA1 Message Date
Rylan Polster
fb50cfa13d
Simplify tap assignment 2023-11-13 14:12:35 -05:00
Rylan Polster
74996ab32c
Remove new tap parameter to FormulaAPILoader 2023-11-13 14:07:34 -05:00
Rylan Polster
aa316109d9
Pass new tap to TapLoader
Co-authored-by: Alexander Mancevice <alexander.mancevice@hey.com>
2023-11-13 14:02:50 -05:00
Rylan Polster
237a42974b
Pass original tap to formula when loaded from the API via TapLoader 2023-11-13 13:40:44 -05:00
Rylan Polster
97b411906d
Refactor TapLoader to fix tap migrations with API 2023-11-11 16:48:05 -05:00
Mike McQuaid
41dc533add
Merge pull request #16108 from Bo98/api-rename-fix
formulary: load from API for formula renames
2023-10-12 17:49:58 +01:00
Bo Anderson
408e15f485
formulary: load from API for formula renames 2023-10-12 17:04:54 +01:00
Eric Knibbe
03e743a75e
api: add using: attribute to head & stable URLs 2023-10-11 14:14:18 -04:00
Mike McQuaid
b7114651ac
utils/curl: include or use explicitly.
Include or use `Utils::Curl` explicitly everywhere it is used.
2023-09-04 22:17:57 -04:00
Mike McQuaid
b3c33d34ab
Various sharding fixes
- Load paths with no API when needed (e.g. for `brew edit`)
- Use no API mode for `brew log` as it's needed there
- Define sharding format for homebrew-cask and homebrew-core inside
  `Tap` methods
- Create new formulae/casks in location defined by these `Tap` methods
- Fix a bug in Formulary that made sharded formulae lookup less
  efficient (and possibly broke it for core and some API usage)
- Fix various other hardcoded Formula/Cask directory assumptions

Co-authored-by: Bo Anderson <mail@boanderson.me>
2023-08-04 16:43:13 +01:00
Ruoyu Zhong
26f8f27b3c
formulary: fix type of alias_path
`Formulary.from_rack` only allows `alias_path` to be a `Pathname`. Make
it happy with `String`s too.

Fixes:

    $ brew test openssl
    Error: Parameter 'alias_path': Expected type Pathname, got type String with value "/usr/local/Homebrew/Librar...homebrew-core/Aliases/openssl"
    Caller: /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/sorbet-runtime-0.5.10461/lib/types/private/methods/call_validation.rb:113
    Definition: /usr/local/Homebrew/Library/Homebrew/formulary.rb:787

Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
2023-08-02 22:49:39 +08:00
Eric Knibbe
b3ecd91f97
dev-cmd/edit: suggest tapping core repositories 2023-08-01 13:39:28 -04:00
Douglas Eichelberger
08e46c18cd Add type to Formula attrs 2023-07-24 14:12:36 -07:00
Douglas Eichelberger
a46430a390 Fix type error when running 'brew doctor' 2023-07-24 07:00:26 -07:00
Mike McQuaid
c940e15a5c
Use HOMEBREW_CELLAR_PLACEHOLDER
Similarly to HOMEBREW_PREFIX_PLACEHOLDER, this allows the substitution
of HOMEBREW_CELLAR in JSON output when using the API.

Fixes #15668.
2023-07-18 10:59:27 +01:00
Bo Anderson
beaa6c32a0
Fix cases of core taps being unnecessarily installed 2023-07-13 20:33:31 +01:00
Bo Anderson
c4077aa076
Support head deps & uses_from_macos bounds in API; strip implicit deps 2023-07-04 13:40:58 +01:00
Bo Anderson
8dc2e80a98
Significantly improve install speeds with smarter postinstall detection 2023-06-22 03:06:45 +01:00
Markus Reiter
e9bfcb9296
Merge pull request #15225 from reitermarkus/audit-os-arch
Add `--os=all` and `--arch=all` options for `brew audit`.
2023-05-19 15:03:32 +02:00
Mike McQuaid
77f94ba5bf
formulary: use a lot more .presence.
Addresses regression in https://github.com/Homebrew/brew/pull/15396.

Fixes https://github.com/Homebrew/homebrew-core/issues/131284
Fixes https://github.com/Homebrew/homebrew-core/issues/131287
Fixes https://github.com/Homebrew/homebrew-bundle/issues/1205
2023-05-18 13:14:52 +01:00
Kevin
946478aed4
Merge pull request #15396 from apainintheneck/custom-service-name
Custom service name
2023-05-17 22:09:31 -07:00
apainintheneck
f2adbf6613 service: change custom name DSL
After some discussion, we decided to change the DSL to get rid of
the `plist_name` and `service_name` methods which aren't meaningful
for most users.

The new DSL looks like this:

```rb
service do
  name macos: "name", linux: "name"
end
```

I also updated some specs here to reflect these changes.

There was some talk about maybe deprecating `plist_name` and `service_name`
but I think that's outside of the scope of this PR so I'm leaving
them as is for now. One benefit of this is that everything here is backwards
compatible.
2023-05-17 21:54:32 -07:00
Markus Reiter
486c3765ce
Add --os=all and --arch=all options. 2023-05-17 15:26:46 +02:00
Markus Reiter
f60612e6b2
Add Formula#loaded_from_api?. 2023-05-15 13:58:33 +02:00
apainintheneck
1111706378 service: add custom service name DSL
The main thing is that this DSL allows us to provide an
interface that can be serialized to the JSON API.

Changes:
- Homebrew::Service
  - Adds `#service_name` and `#plist_name` methods
    - Each is now included in the `#serialize` method as well
  - Eval block on instantiation
    - Before we lazy evaluated this but the cost is not significant
      and it complicated the code a bunch. This only gets called
      during install, when evaluating caveats and in the `brew service`
      command. It skips this evaluation if the service block isn't there.
  - Add `#command?` helper to avoid `#command.blank?` and `#command.present?`
- Formula
  - `#service` now returns a service whenever it's called. This call is
    hidden behind a call to `#service?` most of the time anyway so this
    should be fine.
  - `#plist_name` and `#service_name` now call the methods of the same name
    on the service class. This should have already been in the service object
    to begin with and keeping these methods here helps preserve backwards
    compatibility with people who were overwriting these methods before.
- Caveats
  - Prefer `service#command?`
  - Add helpers for checking on service commands
    - This duplicates some of the work in `brew services`. Maybe we should
      merge that repo in at some point.
  - Check for installed service at `#plist_name` or `#service_name`. I think
    this should be used instead of `Keg#plist_installed?` which checked for any plist file.
    We should think about deprecating `#plist_installed?` in the future.
  - Stop using `ps aux | grep #{formula.plist_name}` to check for service files
    because it was inaccurate (it always returns true on my machine) because the grep
    process is started before the ps process.
  - Note: The behavior is the same as it was before. This means that caveats
    only show up for custom service files on install or if they're already installed.
    Otherwise it won't show up in `brew info`. This is because it has to check
    first if the service file has been installed.
- Utils::Service
  - Add utils for evaluating if a service is installed and running. This duplicates
    some of the work already found in `brew services`. We should seriously consider
    merging `brew services` with the main brew repo in the future since it's already
    tightly coupled to the code in the main repo.
- Formulary.load_formula_from_api
  - Be more explicit about which types can be deserialized into run params since
    it is now possible for run params to be nil.
- Update and add tests
2023-05-13 14:53:01 -07:00
Markus Reiter
a3231a03fa
Implement cask renames. 2023-05-12 21:17:30 +02:00
Markus Reiter
8274920217
Rename OS::Mac::Version to MacOSVersion. 2023-05-09 05:08:38 +02:00
Bo Anderson
44f058edb5
Refactor formula, cask and Ruby source downloads to use shared code 2023-04-27 23:23:07 +01: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
apainintheneck
d57f291a1e formulary: sub home placeholder in caveats
We set a placeholder for the home directory when generating
API JSON so we should substitute the actual home directory
back in when printing caveats locally. This allows people
to use `Dir.home` in caveats and have it display correctly
no matter the platform or operating system.
2023-04-22 10:17:16 -07:00
Markus Reiter
844db75361
Add source paths to API. 2023-04-07 15:20:01 +02:00
Douglas Eichelberger
ccfc1be6fe Rename lvar 2023-03-27 09:39:18 -07:00
Douglas Eichelberger
1c411f6086 Code review changes 2023-03-26 08:57:39 -07:00
Douglas Eichelberger
7720485f40 Enable types in Formula files 2023-03-25 08:50:06 -07:00
Mike McQuaid
a0eb5ebec7
formulary: require service.
This is used in this file.
2023-03-24 09:23:09 +00:00
apainintheneck
bc85857e13 service: make serialization non-recursive
This helps with type annotations and makes it easier to
reason about the code as well.
2023-03-21 23:20:49 -07:00
apainintheneck
db8d488db4 service: add info to API json and load from api
As a part of serializing the hash, certain path
placeholders are used for the HOMEBREW_PREFIX and $HOME
directories. Beyond that certain elements need to be
turned back into strings like cron and sockets and symbols
need to be preserved as well.

The run command accepts either an arg or kwargs so it
has to be treated specially here.
2023-03-19 00:09:10 -07:00
Douglas Eichelberger
0eccc0e987 git grep -l Utils::Inflection | xargs gsed -i 's|Utils::Inflection|Utils|g' 2023-02-27 20:18:27 -08:00
Douglas Eichelberger
2c73d4d9b7 Replace deconstantize inflection with util 2023-02-27 20:17:33 -08:00
Douglas Eichelberger
d62211d3af Replace demodulize inflection with util 2023-02-27 20:17:33 -08:00
Bo Anderson
e86a8c2477
Move HOMEBREW_NO_INSTALL_FROM_API defaults to shell 2023-02-24 21:53:08 +00:00
Mike McQuaid
f280ce069b
Support loading formulae/casks from subdirectories
Previously, we required all formulae and casks to be in a specific
formula or cask directory but did not check any subdirectories.

This commit allows using subdirectories for official taps, the only
ones likely to be big enough to warrant sharding in this way and to
avoid potentially breaking backwards compatibility for existing taps.

This was inspired by the most recent issues with homebrew-cask.
2023-02-24 10:57:41 +00:00
Bo Anderson
e663f532a6
Checksum Ruby source file downloads 2023-02-22 22:50:24 +00:00
Bo Anderson
cacd7194f6
Support link_overwrite and conflicts_with in API 2023-02-20 16:28:07 +00:00
Mike McQuaid
14a11f5c72
formulary: use default bottle root_url.
We never change this value in `formula.json` so ignore it for security.
2023-02-20 10:03:23 +00:00
Bo Anderson
efc5088f85
formulary: fix git clone handling for API formulae 2023-02-15 05:31:23 +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
e0ba9a1249
Merge pull request #14617 from Bo98/api-reqs-oldname
formulary: support requirements, aliases etc from API
2023-02-14 11:54:55 +00:00
Bo Anderson
7c1b642035
formulary: fix uses_from_macos handling on macOS 2023-02-14 04:07:51 +00:00