bernd / fpm-cookery

A tool for building software packages with fpm.
Other
460 stars 88 forks source link

Allow delayed execution for Recipe metadata #134

Closed brodock closed 8 years ago

brodock commented 8 years ago

I was trying to implement a method to retrieve version from a VERSION file:

File.open(File.join(workdir, 'VERSION'), &:read).chomp

While this works, I can't use it with version recipe definition, as I don't have workdir defined at that moment.

This is just an example, but could illustrate other places that could be dynamically defined (like URL, Maintainer, Revision, etc).

One way to make this works, is with lambdas:

instead of

version File.open(File.join(workdir, 'VERSION'), &:read).chomp`
version -> { File.open(File.join(workdir, 'VERSION'), &:read).chomp }

But for this to work, there must need to make sure it will have access to the same "context", and the lambda must receive a .call at the right moment.

Do you think this is valuable?

bernd commented 8 years ago

I think the hiera PR would solve your use case, right?

See: https://github.com/bernd/fpm-cookery/pull/150

bernd commented 8 years ago

This might be solved by using the hiera backend implemented in #150.

Please re-open if this doesn't help in your case. Thank you!