Extract something like Resource
from Formula
.
#20212
Comments
Seems sensible. Would be good if e.g. brew fetch and friends are all aware of resources too. |
Seems SoftwareSpec can be reused or extended for this. |
Trying to add a base class to Formula gives me |
Oh FFS how many times we we reopen the Formula class? |
Why does Formula need a superclass :( |
I like the resource idea very much. Because right now it is a PITA to write a subformula and copy stuff around. I find it hard if the main formula needs a resource to be in a subdir. There should be a resource('fonts').unpack which extracts it directly in the current working dir of the main formula. And if a separate tempdir is wanted, I'd throw the following syntax suggestion into the round: resource('executables') do
libexec.install 'aapt', 'apktool'
end |
It doesn't need a superclass, I can do it as a mixin. Possibly once I get through all this it can just be a component object, but I can't see that far through the code yet. |
Work in progress: https://github.com/adamv/homebrew/compare/sub TODO: (A) fix the naming of downloaded resources (B) swap over formulae over (C) make other commands (fetch, etc.) resource aware Accepting feedback now of course. |
TODO (D) Erlang switches between stable and head of 2 different doc packages; don't want |
cfitsio has a conditional resource; thinking about this now due to the discussion about spec-based deps |
To find files with subformulae:
|
I'm unsure what naming convention to use for fetched resources to ensure proper uniqueness, but so far I have:
thoughts? |
I wouldn't print the |
(The |
It's slightly tough to get the |
or |
This code is at the point where resources are fetched and cached. I haven't converted all subformulae over to resources because some of them still seem to make sense as formulae, at least so far. Accepting comments on what to tackle next here. |
I wonder if it makes sense to implement SoftwareSpec in terms of Resource instead of the other way around, keeping (or moving) all the download strategy/checksum verification/caching in Resource. I say this because after this lands I'm going to work on pushing dependencies into SoftwareSpec. |
That probably makes sense; trying to do the minimal amount here to get this working. Between SoftwareSpec Resource and Formula some methods definitely need to move around. |
Wondering if DownloadStrategy needs a property for the "downloaded name prefix" so that I can grab that for use in creating resource names. |
Another thought, we probably want to be able to fetch resources in parallel with a formula install that we'll need later:
But of course I know nothing about concurrency in Ruby. |
TODO - we can now audit resource URLs, so add that to |
Rebased on master; looking for some advice on what to do next with this. |
Closing this in favor of the pull request. |
Closes Homebrew#20212.
See: Homebrew/legacy-homebrew#20212 for details
I want to do something about how subformulae are currently handled.
Apktool defines a subformula:
and installs it thus:
The formula machinery is used here to download, checksum, and unpack what is essentially a "resource" full of files, not a formula in itself.
Subformulae basically don't have their own
def install
methods, since they don't install to their own place in the Cellar.Suggest that we extract some sort of "Resource" class from Formula for supporting subformulae.
We then enhance the formula DSL to be able to define resources, something like:
We can then clean subformulae from the cache since they are declared in the formula.
The text was updated successfully, but these errors were encountered: