开发手册
https://docs.brew.sh/Formula-Cookbook#homebrew-terminology
概念
摘要:
- brew config 列出当前homebrew的配置
- brew ls 查看已经symkink的包
- brew edit git 编辑git的安装规则
homebrew所有的包(称为Keg)安装到Cellar目录中,Cellar目录如:/home/cat/homebrew/Cellar.
配置展示:
$ brew config
HOMEBREW_VERSION: 3.2.17-123-g96815c8
ORIGIN: https://mirrors.aliyun.com/homebrew/brew.git
HEAD: 96815c8e60a1bfe398cae7c2385be5c369ff03a8
Last commit: 5 weeks ago
Core tap ORIGIN: https://mirrors.aliyun.com/homebrew/homebrew-core.git
Core tap HEAD: 44973e887e63473dec54c256996e8c65ab8c6eb4
Core tap last commit: 5 weeks ago
Core tap branch: master
HOMEBREW_PREFIX: /Users/xhd2015/homebrew
HOMEBREW_REPOSITORY: /Users/xhd2015/homebrew
HOMEBREW_CELLAR: /Users/xhd2015/homebrew/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://mirrors.aliyun.com/homebrew/homebrew-bottles
HOMEBREW_CASK_OPTS: []
HOMEBREW_CORE_GIT_REMOTE: https://github.com/Homebrew/homebrew-core
HOMEBREW_MAKE_JOBS: 4
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: quad-core 64-bit kabylake
Clang: 13.0.0 build 1300
Git: 2.30.1 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.6-x86_64
CLT: 13.0.0.0.1.1630607135
Xcode: N/A
homebrew将包安装到Cellar目录下,并且会将其中一些symlink到/usr/local
下,通过brew ls
可以列出symlink的包。
$ brew ls
==> Formulae
aom gdbm libidn mpfr pcre telnet
bash gettext libidn2 mutagen pcre2 texi2html
blueutil gmp libmpc nasm pkg-config thrift
boost gnu-getopt libpcap nginx python wget
coreutils groovy libpng ninja python@3.8 xz
freetype icu4c libtool node readline
fzf isl libunistring oniguruma ripgrep
gawk jq meson openssl sqlite
gcc libffi minicom openssl@1.1 tcpdump
==> Casks
emacs-mac macfuse
通过brew edit git
或者HOMEBREW_EDITOR=code brew edit git
可以打开vscode编辑git的Formula:
创建Formula
如果你的有一个tarball包含了所有的内容,需要打包:
brew create https://example.com/foo-0.1.tar.gz
会创建一个formula:
class Foo < Formula
desc ""
homepage ""
url "https://example.com/foo-0.1.tar.gz"
sha256 "85cc828a96735bdafcf29eb6291ca91bac846579bcef7308536e0c875d6c81d7"
license ""
# depends_on "cmake" => :build
def install
# ENV.deparallelize
system "./configure", "--disable-debug",
"--disable-dependency-tracking",
"--disable-silent-rules",
"--prefix=#{prefix}"
# system "cmake", ".", *std_cmake_args
system "make", "install"
end
test do
system "false"
end
end
提交
brew update
可用于将本地安装的homebrew转换成git仓库,并且更新。
brew update # required in more ways than you think (initialises the brew git repository if you don't already have it)
cd "$(brew --repository homebrew/core)"
# Create a new git branch for your formula so your pull request is easy to
# modify if any changes come up during review.
git checkout -b <some-descriptive-name> origin/master
git add Formula/foo.rb
git commit
push:将你的更改提交到自己的仓库
git push https://github.com/myname/homebrew-core/ <what-you-called-your-branch>