42 Commits

Author SHA1 Message Date
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
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
Douglas Eichelberger
9075cbae62 brew style --fix 2023-04-21 09:58:50 -07:00
Douglas Eichelberger
ac1e6ded9a git grep -l '# typed: false' | xargs gsed -i 's|# typed: false||g' 2023-04-21 09:57:47 -07:00
Issy Long
3a83b5492c
rubocop: Clean up Style/BlockDelimiters excludes and autofix offenses
- The defaults of using "do ... end" for multi-line blocks everywhere is
  good, better than switching everything to braces everywhere.
2023-03-08 23:54:22 +00:00
Mike McQuaid
6b4363092d
Revert "Merge pull request #14548 from Homebrew/revert-14382-deprecate-disable-remove"
This reverts commit 932d2cf3b77c9439a57b6a43577fc8d3b6399a62, reversing
changes made to f4e60482791d2ff628efadfdbf0d14d9237d2d29.
2023-02-07 19:25:51 +01:00
Mike McQuaid
6882ac17e7
Revert "Add deprecations and disables" 2023-02-07 15:13:19 +01:00
Sean Molenaar
f67d4c4ed6
chore: deprecate plist_options in formula 2023-02-01 17:44:36 +01:00
Dawid Dziurla
0d0c98de29
Allow defining service run command per platform 2023-01-19 11:36:37 +01:00
Mike McQuaid
1bb44979ee
Disable and delete code for 3.5.0
The next planned release will be 3.5.0 so let's fix things up for there.
2022-05-30 14:59:14 +01:00
Sean Molenaar
4cb8afeeef
service: add timer support for systemd 2021-11-30 11:05:11 +01:00
Sean Molenaar
869b0ea519
Formula: use opt_prefix for service helpers 2021-07-26 11:11:34 +02:00
Sean Molenaar
157fed329c
service: install linux service file 2021-05-04 16:22:28 +02:00
Sean Molenaar
4427fa283f
formula: allow plists to be generated 2021-04-08 10:16:57 +02:00
Mike McQuaid
9d70b48e93
Merge pull request #10851 from kthchew/audit-empty-files
audit: check for installed empty files
2021-03-29 11:55:56 +01:00
Kenneth Chew
9d6bfa5965
pathname: do not install empty metafiles 2021-03-27 13:34:50 -04:00
Bo Anderson
fa8b80747a
test/formula_installer_spec: add tests for cyclic deps 2021-03-15 17:51:09 +00:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
8a1f8ab858 Pass args to FormulaInstaller instead of using global args. 2020-07-25 04:21:21 +02:00
Mike McQuaid
ef95b59ed4
Remove HomebrewArgvExtension
Fixes #5730
2020-05-23 19:39:11 +01:00
Mike McQuaid
e5d15c8b19
Merge branch 'master' into argv-cleanup-26 2020-05-23 13:44:42 +01:00
Michelle Nguyen
2264c08cee
Fetch formula resources before unlinking during upgrade.
Fixes #6374.
2020-05-11 09:37:56 +01:00
Gautham G
b40e33aeb8 ARGV: Deprecate ARGV.cc and replace with Homebrew.args.cc 2020-05-04 11:14:55 +05:30
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
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Markus Reiter
e5aaf36f7d Add spec for FormulaInstaller#audit_installed. 2018-09-19 20:07:15 +02:00
William Woodruff
367629d289
utils: Use JSON to marshal child errors
Replaces our serialization of child process
errors via Marshal with JSON, preventing
unintentional or malicious code execution outside
of the build sandbox.

Additionally, adds tests for the new behavior.
2018-09-04 11:03:32 -04:00
Markus Reiter
7762ce32aa Use more descriptive heredoc names. 2018-07-11 18:15:30 +02:00
Mike McQuaid
5e1806e796 test: rubocop-rspec style auto-corrects.
There’s too many warnings to start enabling `rubocop-rspec` by default
but let’s at least apply the cleanups it does automatically.
2018-03-25 13:30:37 +01:00
Mike McQuaid
e5c82dd3d9 Deprecate requirements harder
Remove more Requirement logic to enable future removal of default
formula logic. Also, output deprecations, convert symbol requirement
usage to deps and simplify the compatibility code for the direct
Requirement usage.
2018-01-18 08:31:20 +00:00
Mike McQuaid
d54e670a64 requirements: move more to compat. 2017-12-30 20:56:55 +00:00
Mike McQuaid
b9cf7b2bbc formula_installer: avoid irrelevant build deps.
If dependents are already installed ensure their build dependencies (and
requirements) don't end up in the dependency/requirement tree.

Fixes #3033.
2017-12-07 14:56:12 +00:00
Markus Reiter
9bee9ca575 Use “squiggly” heredocs. 2017-10-18 14:39:09 +02:00
Markus Reiter
175ca909ee Clean up code style and remove .rubocop_todo.yml. 2017-10-08 16:10:37 +02:00
Markus Reiter
f5af3fe0cd Delete :focus. 2017-08-05 18:09:09 +02:00
Mike McQuaid
e755505c70 Merge pull request #2969 from MikeMcQuaid/default-formula-bottles
formula_installer: use default_formula for bottles
2017-07-30 18:41:10 +01:00
Mike McQuaid
a83baba8b5 formula_installer: use default_formula for bottles
This was the original, intended functionality before this was broken
in fe117bf79b244c42b7e4049d353c3c003eae4880.

Fixes https://github.com/Homebrew/homebrew-core/issues/13680.
2017-07-30 16:56:24 +01:00
Markus Reiter
2ad3a87045 Silence all specs by default. 2017-07-29 20:25:37 +02:00
Markus Reiter
3cdf8f938a Use scoped RSpec matchers. 2017-05-15 17:23:40 +02:00
Mike McQuaid
51ca9025a5 formula_installer_spec: add default formula test.
Test the situation where a requirement is satisfied by a non-formula
but the `default_formula` is also installed.
2017-03-29 09:34:52 +01:00
Mike McQuaid
0cc9d93885 formula_installer: tweak req formula additions.
Rather than just checking if a requirement's dependency is installed or
not check if the requirement was actually satisfied by a particular
formula rather than e.g. just having a `default_formula` defined.
2017-03-25 10:59:54 +00:00
Markus Reiter
8b60412c99 Convert FormulaInstaller test to spec. 2017-02-27 13:45:06 +01:00