4

2022-41 homebrew formula example for go

 1 year ago
source link: https://cloudsjhan.github.io/2022/10/06/homebrew-formula-example-for-go/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

2022-41 homebrew formula example for go

2022-10-06

| weekly-report

|

|

| 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 模板,根据模板填写需要的信息。

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 之前要完成几个前置操作:

005UfcOkly8h6z5wwxx48j31bm0e241t.jpg

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

005UfcOkly8h6z5domkzbj31c007swfx.jpg

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
坚持原创技术分享,您的支持将鼓励我继续创作!
(>给这篇博客打个分吧<)

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK