如何在自制程序中安装特定版本的公式?例如,postgresql-8.4.4而不是最新的9.0。


当前回答

编辑:2021,由于github安装被弃用,这个答案不再起作用。(感谢蒂姆·史密斯的更新)。

安装旧的酿造包版本(Flyway 4.2.0示例)

查找本地自制程序gitdir或本地克隆homebrew/homebrew内核

cd/usr/local/Homebrew/Library/Taps/Homebrew/Homebrew内核/

OR

git克隆git@github.com:Homebrew/Homebrew-core.git

列出所有可用版本

git log master--Formula/flyway.rb

复制所需版本的提交ID并直接安装

brew安装https://raw.githubusercontent.com/Homebrew/homebrew-core/793abfa325531415184e1549836c982b39e89299/Formula/flyway.rb

其他回答

以下是我如何降级KOPS(不支持版本控制)

# brew has a git repo on your localhost
cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core

git remote -v
origin  https://github.com/Homebrew/homebrew-core (fetch)
origin  https://github.com/Homebrew/homebrew-core (push)

# find the version of kops.rb you need
git log Formula/kops.rb

# checkout old commit
# kops: update 1.18.1 bottle.
git checkout 2f0ede7f27dfc074d5b5493894f3468f27cc73f0 -- Formula/kops.rb

brew unlink kops
brew install kops

# now we have old version installed
ls -1 /usr/local/Cellar/kops/
1.18.1
1.18.2

which kops
/usr/local/bin/kops
ls -l /usr/local/bin/kops
/usr/local/bin/kops -> ../Cellar/kops/1.18.1/bin/kops
kops version
Version 1.18.1

# revert to the newest version
brew uninstall kops
git checkout -f
brew link kops
kops version
Version 1.18.2

按照@halfcube的建议,这非常有效:

查找您要查找的库https://github.com/Homebrew/homebrew-core/tree/master/Formula单击它:https://github.com/Homebrew/homebrew-core/blob/master/Formula/postgresql.rb单击“历史记录”按钮查看旧提交:https://github.com/Homebrew/homebrew-core/commits/master/Formula/postgresql.rb单击所需的选项:“postgresql:update version to 8.4.4”,https://github.com/Homebrew/homebrew-core/blob/8cf29889111b44fd797c01db3cf406b0b14e858c/Formula/postgresql.rb单击“原始”链接:https://raw.githubusercontent.com/Homebrew/homebrew-core/8cf29889111b44fd797c01db3cf406b0b14e858c/Formula/postgresql.rbbrew安装https://raw.githubusercontent.com/Homebrew/homebrew-core/8cf29889111b44fd797c01db3cf406b0b14e858c/Formula/postgresql.rb

我决定,违背我更好的判断,为Maven 3.1.1创建一个公式,而自制程序/版本没有。要执行此操作:

我在github上分叉了自制程序/版本。我从$(brew-prefix)/Library/Taps符号链接到我的fork的本地工作副本。我将其称为我的自制程序/版本。我通过将公式指定为我的自制程序/版本/<公式>进行测试。我向自制程序/版本发送了新公式的拉取请求。

Yay.

基于@tschundee和@Debilski的更新1所描述的工作流,我自动化了该过程,并在此脚本中添加了清理。

下载它,将其放到您的路径中,然后brewv<formula_name><wanted_version>。对于特定OP,它将是:

cd path/to/downloaded/script/
./brewv postgresql 8.4.4

:)

更新日期:2015年1月15日

查找所需软件和版本的提交历史记录。例如,我需要从docker版本1.4.1切换到1.3.3:https://github.com/Homebrew/homebrew-core/commits/master/Formula/docker.rb使用此按钮查看文件:单击“原始”按钮:从地址栏复制URL(本例中为docker.rb URL)brew install<url>(可能必须首先brew unlink,例如brew unlinkdocker)酿造开关装卸工1.3.3切换回码头1.4.1酿造切换码头1.4.1

根据这一要点

brew update
brew versions FORMULA
cd `brew --prefix`
git checkout HASH Library/Formula/FORMULA.rb  # use output of "brew versions"
brew install FORMULA
brew switch FORMULA VERSION
git checkout -- Library/Formula/FORMULA.rb    # reset formula

## Example: Using Subversion 1.6.17
#
# $ brew versions subversion
# 1.7.3    git checkout f8bf2f3 /usr/local/Library/Formula/subversion.rb
# 1.7.2    git checkout d89bf83 /usr/local/Library/Formula/subversion.rb
# 1.6.17   git checkout 6e2d550 /usr/local/Library/Formula/subversion.rb
# 1.6.16   git checkout 83ed494 /usr/local/Library/Formula/subversion.rb
# 1.6.15   git checkout 809a18a /usr/local/Library/Formula/subversion.rb
# 1.6.13   git checkout 7871a99 /usr/local/Library/Formula/subversion.rb
# 1.6.12   git checkout c99b3ac /usr/local/Library/Formula/subversion.rb
# 1.6.6    git checkout 8774131 /usr/local/Library/Formula/subversion.rb
# 1.6.5    git checkout a82e823 /usr/local/Library/Formula/subversion.rb
# 1.6.3    git checkout 6b6d369 /usr/local/Library/Formula/subversion.rb
# $ cd `brew --prefix`
# $ git checkout 6e2d550 /usr/local/Library/Formula/subversion.rb
# $ brew install subversion
# $ brew switch subversion 1.6.17
# $ git checkout -- Library/Formula/subversion.rb