Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HomeBrew Formula : Download two URL packages

Tags:

homebrew

I need to get nginx compiled with the file upload package. The module doesn't come as part of the default nginx brew formula. It appears brew formulas are based off one download pkg, see below

class Nginx < Formula
  homepage 'http://nginx.org/'
  url 'http://nginx.org/download/nginx-1.2.0.tar.gz'
  md5 'a02ef93d65a7031a1ea3256ad5eba626'

  devel do
    url 'http://nginx.org/download/nginx-1.3.0.tar.gz'
    md5 'b02e171c4a088aa9a5ab387943ce08eb'
  end

How can I download the bellow in a subfolder, say nginx/contrib ?

url 'http://www.grid.net.ru/nginx/download/nginx_upload_module-2.2.0.tar.gz'
md5 '2681a6167551830a23336fa41bc539a1'
like image 256
Olivier Refalo Avatar asked Feb 20 '23 10:02

Olivier Refalo


2 Answers

You can use a "subformula". You would stick this class definition in the Nginx formula file:

class NginxUploadModule < Formula
  url 'http://www.grid.net.ru/nginx/download/nginx_upload_module-2.2.0.tar.gz'
  md5 '2681a6167551830a23336fa41bc539a1'
end

and then in the install method of the Nginx formula, you would do something like

NginxUploadModule.new.brew do
  (buildpath/'where/you/want/the/files').install Dir['*']
end

adjusting the path accordingly.

There are a number of examples of this in the core Homebrew repository; grepping for "new.brew" should give you quite a few.

like image 124
jacknagel Avatar answered Mar 11 '23 12:03

jacknagel


From https://github.com/Homebrew/homebrew/blob/master/Library/Contributions/example-formula.rb

# 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

# Additional downloads can be defined as resources (see above).
# The stage method will create a temporary directory and yield
# to a block.
resource("additional_files").stage { bin.install "my/extra/tool" }
like image 28
bridiver Avatar answered Mar 11 '23 12:03

bridiver