2022-41 homebrew formula example for go
2022-10-6 20:35:49 Author: cloudsjhan.github.io(查看原文) 阅读量:3 收藏

发表于 | 分类于 | 阅读次数: |

| 字数统计: 371 | 阅读时长 ≈ 2

homebrew formula example for go

最近准备将 bendsql 发布到 homebrew 的 repo,这样就可以使用 brew install bendsql 方便地安装 bendsql 了。发布的方式就是为 bendsql 写一个 formula 并提 pr 到 homebrew-core,在此记录一下如何生成 homebrew formula。

说干就干, fork 了 homebrew-core 的 repo 然后 checkout 分支准备提 PR。

执行 brew create $download_URL 执行后会生成 install 模板,根据模板填写需要的信息。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Bendsql < Formula
desc "Work seamlessly with Databend Cloud from the command line."
homepage "https://github.com/databendcloud/bendsql"
url "https://github.com/databendcloud/bendsql/releases/download/v0.0.2/bendsql-darwin-amd64.tar.gz"
sha256 "25c1a2a4e1922261535325634a939fe42a0ffcc12ae6c262ed7021dab611f622"
license "MIT"
head "https://github.com/databendcloud/bendsql.git", branch: "main"

depends_on "go" => :build

def install
system "go", "build", *std_go_args(ldflags: "-s -w")
end

test do
system "make test"
end
end

根据 homebrew-core 的文档,在提 PR 之前要完成几个前置操作:

当执行到 brew test bendsql 的时候,发现向 homebrew 官方仓库提交应用是需要满足一定条件的:

bendsql 刚开源一周还没满足以上条件,所以没法直接使用 brew install bendsql,只能另辟蹊径了。

想起来之前写其他工具的时候,只要在自己的账户中创建一个 homebrew-tap 的 repo, 比如 https://github.com/hantmac/homebrew-tap, 就能实现类似的下载效果。

所以只要在 databendcloud 的账户下,新建一个这样的 repo,将上面配好的 formula 提交进去就可以 brew tap databendcloud/homebrew-tap && brew install bendsql 很方便地下载了。


-------------The End-------------

cloud sjhan wechat

subscribe to my blog by scanning my public wechat account

0%


文章来源: https://cloudsjhan.github.io/2022/10/06/homebrew-formula-example-for-go/
如有侵权请联系:admin#unsafe.sh