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


当前回答

解决方案

brew extract --version=8.4p1  openssh homebrew/cask
brew install openssh@8.4p1

最新的openssl@8.5p1在我运行brew升级后出现错误,因此我通过上述方式成功地备份到了以前的版本。

其他回答

这里的其他答案很好,但如果您需要安装较旧版本的软件包并确保修改了软件包名称,则需要另一种方法。当使用脚本(在我的例子中是PHP构建脚本)时,这一点非常重要,这些脚本使用brew前缀package_name来确定要用于编译的目录。

如果您正在使用brew提取,则会在包名称的末尾添加一个版本,这将中断brew前缀查找。

以下是如何在保持原始软件包名称的同时安装较旧的软件包版本:

# uninstall the newer version of the package that you accidentally installed
brew uninstall --ignore-dependencies icu4c

# `extract` the version you'd like to install into a custom tap
brew tap-new $USER/local-tap
brew extract --version=68.2 icu4c $USER/local-tap

# jump into the new tap you created
cd $(brew --repository $USER/local-tap)/Formula

# rename the formula
mv icu4c@68.2.rb icu4c.rb

# change the name of the formula by removing "AT682" from the `class` definition
# the exact text you'll need to remove will be different
# depending on the version you extracted
nano icu4c.rb

# then, install this specific formula directly
brew install $(brew --repository $USER/local-tap)/Formula/icu4c.rb

我在这里写了更多。

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

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

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

:)

在最新版本的自制程序(截至本文撰写时为0.9.5)上,将有一个你想要安装的自制桶版本的具体配方。例子:

$ brew search mongodb
mongodb    mongodb24  mongodb26

然后,像正常一样进行brew安装mongodb26。

如果您已经安装了最新版本,请确保取消链接最新版本并链接所需版本:brew unlink mongodb&&brew link mongob26。

编辑: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

如果无法使用brew search<formula>找到您的版本,您也可以尝试查看公式的提交日志,以找到所需的版本:

下面是通过brew安装旧版本nginx的示例:

ngxnx公式提交日志参见nginx:更新1.6.3瓶装eba75b9a1a474b9fc4df30bd0a32637fa31ec049

从那里,我们可以使用sha和原始git url安装1.6.3:

brew安装https://raw.githubusercontent.com/Homebrew/homebrew/eba75b9a1a474b9fc4df30bd0a32637fa31ec049/Library/Formula/nginx.rb