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


当前回答

更新Library/Formal/postgresql.rb第8行至

http://ftp2.uk.postgresql.org/sites/ftp.postgresql.org/source/v8.4.6/postgresql-8.4.6.tar.bz2

第9行的MD5

fcc3daaf2292fa6bf1185ec45e512db6

保存并退出。

brew install postgres
initdb /usr/local/var/postgres

现在在这个阶段,您可能会遇到postgresql无法创建共享内存段错误,要解决这个问题,请像这样更新/etc/sysctl.conf:

kern.sysv.shmall=65536
kern.sysv.shmmax=16777216

再次尝试initdb/usr/local/var/postgres,它应该运行平稳。

在启动时运行postgresql

launchctl load -w /usr/local/Cellar/postgresql/8.4.6/org.postgresql.postgres.plist

希望有助于:)

其他回答

目前,安装特定公式版本的旧方法已被弃用。因此,我们似乎必须使用brew edit[公式]。例如,假设我们要安装icu4c的62.1版本(例如postgresql10.5需要)

> brew edit icu4c
# drops you to editor

在这里,您必须将url、version和sha256(可能也是镜像)更改为相应的62.1字符串。

url "https://ssl.icu-project.org/files/icu4c/62.1/icu4c-62_1-src.tgz"
mirror "https://github.com/unicode-org/icu/releases/download/release-62-1/icu4c-62_1-src.tgz"
version "62.1"
sha256 "3dd9868d666350dda66a6e305eecde9d479fb70b30d5b55d78a1deffb97d5aa3"

然后运行brew重新安装icu4c,最终下载62.1版本。

如果无法使用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

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

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

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

:)

这些都不适用于我的案例(Python),所以我将添加我的2美分:

cd `brew --prefix`
git log Library/Formula/python.rb

输出如下所示:

提交文件作者:Dominik Tiller<dominyktiller@gmail.com>日期:2016年6月30日星期四17:42:18+0100python:澄清pour-bottle原因提交cb3b29b824a264895434214e191d0d7ef4d51c85作者:BrewTestBot<brew-test-bot@googlegroups.com>日期:2016年6月29日星期三14:18:40+0100python:更新2.7.12瓶。提交45bb1e20234184bbb7d6fd3f6df20987dc14f0作者:Rakesh<rakkesh@users.noreply.github.com>日期:2016年6月29日星期三10:02:26+0530python 2.7.12关闭#2452。签字人:Tim D.Smith<git@tim-smith.us>提交cf5da0547cd261f79d69e7ff62fdfbd2c2d646e9作者:BrewTestBot<brew-test-bot@googlegroups.com>日期:2016年6月17日星期五20:14:36+0100python:更新2.7.11瓶子。...

我想要2.7.11版本,所以我的哈希是cf5da0547cd261f79d69e7ff62fdfbd2c2d646e9(简称cf5da05)。接下来,我检查该版本并安装公式python:

git checkout cf5da05
brew install python

最后,清理:

git checkout master

UPDATE:此方法已弃用,不再有效。

此方法导致错误:不支持从GitHub提交URL安装mysql!brew将mysql提取到GitHub上的稳定水龙头。(用法错误)

$ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/c77882756a832ac1d87e7396c114158e5619016c/Formula/mysql.rb
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).

...

Traceback (most recent call last):
    9: from /usr/local/Homebrew/Library/Homebrew/brew.rb:122:in `<main>'
    8: from /usr/local/Homebrew/Library/Homebrew/cmd/install.rb:132:in `install'
    7: from /usr/local/Homebrew/Library/Homebrew/cli/parser.rb:302:in `parse'
    6: from /usr/local/Homebrew/Library/Homebrew/cli/parser.rb:651:in `formulae'
    5: from /usr/local/Homebrew/Library/Homebrew/cli/parser.rb:651:in `map'
    4: from /usr/local/Homebrew/Library/Homebrew/cli/parser.rb:655:in `block in formulae'
    3: from /usr/local/Homebrew/Library/Homebrew/formulary.rb:351:in `factory'
    2: from /usr/local/Homebrew/Library/Homebrew/formulary.rb:138:in `get_formula'
    1: from /usr/local/Homebrew/Library/Homebrew/formulary.rb:142:in `klass'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:227:in `load_file': Invalid usage: Installation of mysql from a GitHub commit URL is unsupported! `brew extract mysql` to a stable tap on GitHub instead. (UsageError)
    12: from /usr/local/Homebrew/Library/Homebrew/brew.rb:155:in `<main>'
    11: from /usr/local/Homebrew/Library/Homebrew/brew.rb:157:in `rescue in <main>'
    10: from /usr/local/Homebrew/Library/Homebrew/help.rb:64:in `help'
     9: from /usr/local/Homebrew/Library/Homebrew/help.rb:83:in `command_help'
     8: from /usr/local/Homebrew/Library/Homebrew/help.rb:103:in `parser_help'
     7: from /usr/local/Homebrew/Library/Homebrew/cli/parser.rb:302:in `parse'
     6: from /usr/local/Homebrew/Library/Homebrew/cli/parser.rb:651:in `formulae'
     5: from /usr/local/Homebrew/Library/Homebrew/cli/parser.rb:651:in `map'
     4: from /usr/local/Homebrew/Library/Homebrew/cli/parser.rb:655:in `block in formulae'
     3: from /usr/local/Homebrew/Library/Homebrew/formulary.rb:351:in `factory'
     2: from /usr/local/Homebrew/Library/Homebrew/formulary.rb:138:in `get_formula'
     1: from /usr/local/Homebrew/Library/Homebrew/formulary.rb:142:in `klass'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:227:in `load_file': Invalid usage: Installation of mysql from a GitHub commit URL is unsupported! `brew extract mysql` to a stable tap on GitHub instead. (UsageError)

我尝试使用推荐的命令进行安装,但它在MySQL 5.7.10的这个特定实例中不起作用。你可能会有更好的运气与更新的公式。

$ brew extract --version=5.7.10 mysql homebrew/cask
==> Searching repository history
==> Writing formula for mysql from revision 0fa511b to:
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/Formula/mysql@5.7.10.rb

$ 

$ brew install /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/Formula/mysql@5.7.10.rb
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 1 formula.
Error: undefined method `core_tap?' for nil:NilClass

Error: Failed to load cask: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/Formula/mysql@5.7.10.rb
Cask 'mysql@5.7.10' is unreadable: wrong constant name #<Class:0x00007f9b9498cad8>
Warning: Treating /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/Formula/mysql@5.7.10.rb as a formula.
==> Installing mysql@5.7.10 from homebrew/cask
==> Downloading https://homebrew.bintray.com/bottles/cmake-3.19.4.big_sur.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/278f2ad1caf664019ff7b4a7fc5493999c06adf503637447af13a617d45cf484?response-content-disposition=attachment%3Bfilenam
######################################################################## 100.0%
==> Downloading https://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.bz2
==> Downloading from https://phoenixnap.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.bz2
######################################################################## 100.0%
==> Downloading https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.10.tar.gz

curl: (22) The requested URL returned error: 404 Not Found
Error: Failed to download resource "mysql@5.7.10"
Download failed: https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.10.tar.gz

您可以在上面的路径中修改公式(用ruby编写),以尝试实现所需的结果(例如,在最近的macOS版本上安装MySQL 5.7.10)。


您可以使用识别公式和公式历史记录中与您要安装的软件包版本匹配的特定提交的策略。

去https://github.com/Homebrew/homebrew-core按键盘上的t启动文件查找器。确定一个看起来最相关的公式,可能是:formula/mysql.rb,将您带到forumla文件位置:https://github.com/Homebrew/homebrew-core/blob/master/Formula/mysql.rb.单击历史记录按钮查看修订历史记录,该按钮位于https://github.com/Homebrew/homebrew-core/commits/master/Formula/mysql.rb.如果您对MySQL 5.7.10感兴趣,可以单击5.7.11之前的最新版本,该版本导航到GitHub提交:

https://github.com/Homebrew/homebrew-core/commit/c77882756a832ac1d87e7396c114158e5619016c#Formula/mysql.rb

注意:如果提交历史没有加载到浏览器中,您可能需要根据GitHub的建议在控制台中查看提交历史。如果您有兴趣在GitHub上看到提交,请在URL中替换上面的提交SHA。或者,跳到下面的步骤7。

应用提交后,单击“查看”按钮查看mysql.rb文件的源代码。然后单击“原始”按钮查看原始源。复制URL。或者,使用mysql.rb文件名自己构建URL,以标识您的公式和该公式的特定版本(由以下URL中的commmit SHA标识)。

https://raw.githubusercontent.com/Homebrew/homebrew-core/c77882756a832ac1d87e7396c114158e5619016c/Formula/mysql.rb

使用$brew Install[步骤7的URL]安装它$brew安装https://raw.githubusercontent.com/Homebrew/homebrew-core/c77882756a832ac1d87e7396c114158e5619016c/Formula/mysql.rb