homebrew的基本结构和扩展使用

本文介绍了Homebrew,一个MacOS的包管理器,如何使用`brewconfig`、`brewls`和`breweditgit`等命令管理软件包。Homebrew将包安装在Cellar目录,然后通过symlink链接到/usr/local。创建新Formula的步骤包括使用`brewcreate`生成模板,编辑Formula文件,然后使用`brewupdate`和`git`进行提交。
摘要由CSDN通过智能技术生成

开发手册

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

homebrew cheat sheet

概念

摘要:

  • 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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值