HomeBrew Formula:下载两个URL包

时间:2012-05-19 12:14:15

标签: homebrew

我需要使用文件上传包编译nginx。该模块不是默认nginx brew公式的一部分。看来brew公式是基于一个下载pkg,见下文

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

如何在子文件夹中下载bellow,比如nginx / contrib?

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

2 个答案:

答案 0 :(得分:5)

您可以使用“子公式”。您可以将此类定义粘贴在Nginx公式文件中:

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

然后在Nginx公式的install方法中,你会做类似

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

相应地调整路径。

核心Homebrew存储库中有很多这样的例子;为“new.brew”打招呼应该会给你很多。

答案 1 :(得分:3)

来自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" }