How to use path of downloaded resource?


I’m currently trying to update an existing formula in order remove its current limitations. To do so, I need to download a dependency required in the build process alone.

Here is how I specify the resource:

stable do
  resource "zlib-w32" do
    url ""
    sha256 "a03fd15af45e91964fb980a30422073bc3f3f58683e9fdafadad3f7db10762b1"

I’m not entirely sure how to proceed from there. Do I have to extract the resource manually? How can use of the path of the extracted files? I need the path so I can pass it on to scons:

def install
  scons "ZLIB_W32=#{PATH_TO_ZLIB_W32}"

(Mike McQuaid) #2

You need something like:

resource("zlib-w32").stage do

This will extract the resource and change to the relevant directory. You can grep for .stage in other formulae to see their usage.


Thanks Mike. I actually came across .stage before, but the following code felt a bit odd, so I wondered if there was another way.

resource("zlib-win32").stage do
    @zlib_path = Dir.pwd

scons "ZLIB_W32=#{@zlib_path}"

The formula itself works fine, let’s see what the maintainers think of it.

(Peter Gusev) #4

Thanks for the post! I have a similar problem and your solution seems to help partially, though.
The problem is that the resource folder gets deleted after staging and non-existent at the time when I try to compile my formula.
I found there’s staging.retain! call, but unfortunately I don’t know how to use it, since I’m not familiar with Ruby too much. Tried this and it didn’t work:

resource("openfec").stage do |resource, staging| { 
          @openfecPath = Dir.pwd 
          |resource,staging| staging.retain!

I’m sure this is something simple that can be resolved quickly.
Looking for help here, thanks!

(Peter Gusev) #5

I figured this out. This code works and allows me to retain the resource folder for later use during compilation:

  resource("openfec").stage do |stage|  
      @openfecPath = Dir.pwd