4

我需要用文件上传包编译 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

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

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

2 回答 2

5

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

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

然后在installNginx 公式的方法中,你会做类似的事情

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

相应地调整路径。

核心 Homebrew 存储库中有很多这样的例子;grepping“new.brew”应该给你不少。

于 2012-05-20T22:12:47.003 回答
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" }
于 2014-11-04T21:01:32.553 回答