Mac OS下用Homebrew安装自己写的开源工具

栏目: 软件资讯 · 发布时间: 7年前

内容简介:本文主要介绍了适用于Mac OS系统的一款软件包管理工具Homebrew,并详细说明了新建Formula的步骤。上篇文章回顾:本文首发于公众号“小米运维”,点击查看原文

本文主要介绍了适用于Mac OS系统的一款软件包管理工具Homebrew,并详细说明了新建Formula的步骤。

上篇文章回顾: Nginx动态发现方案与实践

1、 Homebrew 介绍

Homebrew[1]是一款 Mac OS 平台下的软件包管理工具,拥有安装、卸载、更新、查看、搜索等很多实用的功能。简单的一条指令,就可以实现包管理,而不用你关心各种依赖和文件路径的情况,十分方便快捷。Homebrew 可以说已经成为使用 Mac 电脑 程序员 的标配。做为开源软件的贡献者,本文将向大家介绍一下如何能够让自己的开源项目通过 Homebrew 进行软件包管理。

brew install foo复制代码

2、 Formula VS. Cask

Homebrew 支持多种形式的软件包管理,常见的有 Formula 和 Cask 两种。Formula 一般用来源码编译安装开源的命令行工具,Cask 一般用来安装支持UI的应用程序。官方 Formula 对应的 Github 项目为 homebrew-core[2], Cask 对应的 Github 项目为homebrew-cask[3]。建议先 Fork 相应的 Git 项目到自己的账号下再添加新的工具。文章篇幅所限,本文只会介绍 Formula 的创建使用方法,Cask 的创建方法类似。

Mac OS下用Homebrew安装自己写的开源工具

3、 新建 Formula 步骤

1、本地 Git 仓库准备

cd `brew --repo`/Library/Taps/homebrew/homebrew-core
git remote add ${your_github_id} https://github.com/${your_github_id}/homebrew-core.git
git fetch ${your_github_id}
git checkout -b ${your_github_id} ${your_github_id}/master复制代码

2、新建 Formula 脚本文件

# 执行该命令后将自动在 Formula 目录下创建一个名为foo.rb的文件,文本编辑器也会自动打开该文件。
brew create foo复制代码

Mac OS下用Homebrew安装自己写的开源工具

3、编辑 Formula 文件

Mac OS下用Homebrew安装自己写的开源工具

4、测试安装

# 安装
brew install foo
# 下载源码安装而不是下载编译好的 bottle 版本,下面链接是对 bottle 的介绍
# https://docs.brew.sh/Bottle
brew reinstall --build-from-source foo
# 检查 Formula 脚本格式,超好用的 linter 工具
brew audit --strict foo复制代码

5、提交代码等待 PR 合并

Homebrew 的社区相当活跃,一般 PR 提交24小时内就能得到项目维护人的回复。为了让自已写的 工具 尽快被收录,建议提交 PR 前认真阅读 Issue Template,并按照建议修改。下面是官方提供的 PR 建议。

- [ ] Have you followed the [guidelines for contributing](https://github.com/Homebrew/homebrew-core/blob/master/CONTRIBUTING.md)?
- [ ] Have you checked that there aren't other open [pull requests](https://github.com/Homebrew/homebrew-core/pulls) for the same formula update/change?
- [ ] Have you built your formula locally with `brew install --build-from-source <formula>`, where `<formula>` is the name of the formula you're submitting?
- [ ] Does your build pass `brew audit --strict <formula>` (after doing `brew install <formula>`)?复制代码

参考链接

[1] https://brew.sh/

[2] https://github.com/Homebrew/homebrew-core

[3] https://github.com/Homebrew/homebrew-cask

[4] https://docs.brew.sh/Formula-Cookbook#homebrew-terminology

[5] https://docs.brew.sh/Formula-Cookbook

[6] https://github.com/Homebrew

本文首发于公众号“小米运维”,点击查看原文


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Web 2.0 Architectures

Web 2.0 Architectures

Duane Nickull、Dion Hinchcliffe、James Governor / O'Reilly / 2009 / USD 34.99

The "Web 2.0" phenomena has become more pervasive than ever before. It is impacting the very fabric of our society and presents opportunities for those with knowledge. The individuals who understand t......一起来看看 《Web 2.0 Architectures》 这本书的介绍吧!

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具