Replace subformula example with a resource example
This commit is contained in:
parent
4bacc8bb13
commit
75dd75bd24
@ -202,6 +202,16 @@ class ExampleFormula < Formula
|
|||||||
cause 'multiple configure and compile errors'
|
cause 'multiple configure and compile errors'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
## Resources
|
||||||
|
|
||||||
|
# Additional downloads can be defined as resources and accessed in the
|
||||||
|
# install method. Resources can also be defined inside a stable, devel, or
|
||||||
|
# head block. This mechanism replaces ad-hoc "subformula" classes.
|
||||||
|
resource "additional_files" do
|
||||||
|
url 'https://example.com/additional-stuff.tar.gz'
|
||||||
|
sha1 'deadbeef7890123456789012345678901234567890'
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
## Patches
|
## Patches
|
||||||
|
|
||||||
@ -348,12 +358,10 @@ class ExampleFormula < Formula
|
|||||||
# Copy `./example_code/simple/ones` to share/demos/examples
|
# Copy `./example_code/simple/ones` to share/demos/examples
|
||||||
(share/'demos').install "example_code/simple/ones" => 'examples'
|
(share/'demos').install "example_code/simple/ones" => 'examples'
|
||||||
|
|
||||||
# Additional stuff can be defined in a sub-formula (see below) and
|
# Additional downloads can be defined as resources (see above).
|
||||||
# with a block like this, it will be extracted into its own temporary
|
# The stage method will create a temporary directory and yield
|
||||||
# dir. We can install into the Cellar of the main formula easily,
|
# to a block.
|
||||||
# because `prefix`, `bin` and all the other pre-defined variables are
|
resource("additional_files").stage { bin.install 'my/extra/tool' }
|
||||||
# from the main formula.
|
|
||||||
AdditionalStuff.new.brew { bin.install 'my/extra/tool' }
|
|
||||||
|
|
||||||
# `name` and `version` are accessible too, if you need them.
|
# `name` and `version` are accessible too, if you need them.
|
||||||
end
|
end
|
||||||
@ -412,13 +420,6 @@ class ExampleFormula < Formula
|
|||||||
def plist; nil; end
|
def plist; nil; end
|
||||||
end
|
end
|
||||||
|
|
||||||
class AdditionalStuff < Formula
|
|
||||||
# Often, a second formula is used to download some resource
|
|
||||||
# NOTE: This is going to change when https://github.com/Homebrew/homebrew/pull/21714 happens.
|
|
||||||
url 'https://example.com/additional-stuff.tar.gz'
|
|
||||||
sha1 'deadbeef7890123456789012345678901234567890'
|
|
||||||
end
|
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
# Room for a patch after the `__END__`
|
# Room for a patch after the `__END__`
|
||||||
# Read in the wiki about how to get a patch in here:
|
# Read in the wiki about how to get a patch in here:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user