使用 brew extract 安装以前版本的公式

Installing previous versions of a formula with brew extract

由于 problem 使用 Subversion 1.13 Brew 公式,我正在安装公式的旧版本:

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/0c3d786402ad7d9dd5eb6907e3ed3f2525a0472d/Formula/subversion.rb

给出警告:

Warning: Calling Installation of subversion from a GitHub commit URL is deprecated! Use 'brew extract subversion' to stable tap on GitHub instead.

建议同this tip

现在,我想使用 brew extract subversion 而不是使用已弃用的提交 URL 来正确执行此操作。我想在某些计算机上安装 Subversion 1.13_5,但 Subversion 1.14 是最新的公式。

我需要做这样的事情:brew extract --version 1.13.0_5 subversion <tap>

我的理解方式应该是:

  1. 为我的版本化公式创建一个空存储库
  2. 将存储库添加为 tap 并对其进行初始化
  3. 提取版本化公式
  4. 提交并推送公式?

我创建了一个empty repository,然后:

$ brew tap rjollos/homebrew-versioned
Cloning into '/usr/local/Homebrew/Library/Taps/rjollos/homebrew-versioned'...
warning: You appear to have cloned an empty repository.
Tapped (16 files, 22.2KB).
$ brew tap-new rjollos/homebrew-versioned
==> Created rjollos/versioned
/usr/local/Homebrew/Library/Taps/rjollos/homebrew-versioned
$ brew extract --version '1.13.0_5' subversion rjollos/homebrew-versioned
==> Searching repository history
Warning: Calling 'devel' blocks in formulae is deprecated! Use 'head' blocks or @-versioned formulae instead.
Please report this issue to the homebrew/core tap (not Homebrew/brew or Homebrew/core), or even better, submit a PR to fix it:
  /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/subversion.rb:16

Warning: Calling 'devel' blocks ... (repeats about a dozen times)

Error: subversion: undefined method `sha1' for #<SoftwareSpec:0x00007fceaf144490>

我想我做错了几件事,但主要是我不确定为什么 brew extract 不起作用。另外,有没有更好的方法来创建一个新的存储库并使用新的水龙头的模板文件填充它?

$ brew --version
Homebrew 2.4.4-19-ge09802b
Homebrew/homebrew-core (git revision 5ee797; last commit 2020-07-07)
Homebrew/homebrew-cask (git revision 837ac; last commit 2020-07-08)

我试过 brew install <url> 方法,对我来说似乎很有效?

安装日志:

$ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/0c3d786402ad7d9dd5eb6907e3ed3f2525a0472d/Formula/subversion.rb
Warning: Calling Installation of subversion from a GitHub commit URL is deprecated! Use 'brew extract subversion' to stable tap on GitHub instead.
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/subversion-1.13.0_5.mojave.bottle.tar.gz
Already downloaded: /Users/rchen/Library/Caches/Homebrew/downloads/6c15ae92fb6a09985f1679367588188829b69a4dbc53bb324597fb9fdf588d9e--subversion-1.13.0_5.mojave.bottle.tar.gz
Warning: subversion 1.14.0_2 is available and more recent than version 1.13.0_5.
==> Pouring subversion-1.13.0_5.mojave.bottle.tar.gz
==> Caveats
svntools have been installed to:
  /usr/local/opt/subversion/libexec

The perl bindings are located in various subdirectories of:
  /usr/local/opt/subversion/lib/perl5

You may need to link the Java bindings into the Java Extensions folder:
  sudo mkdir -p /Library/Java/Extensions
  sudo ln -s /usr/local/lib/libsvnjavahl-1.dylib /Library/Java/Extensions/libsvnjavahl-1.dylib

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
  /usr/local/Cellar/subversion/1.13.0_5: 234 files, 30.3MB
Removing: /Users/rchen/Library/Caches/Homebrew/subversion--1.13.0_5.mojave.bottle.tar.gz... (8.6MB)

版本检查

$ svn --version
svn, version 1.13.0 (r1867053)
   compiled Apr 17 2020, 12:01:27 on x86_64-apple-darwin18.7.0

Copyright (C) 2019 The Apache Software Foundation.
This software consists of contributions made by many people;
see the NOTICE file for more information.
Subversion is open source software, see http://subversion.apache.org/

The following repository access (RA) modules are available:

* ra_svn : Module for accessing a repository using the svn network protocol.
  - with Cyrus SASL authentication
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.
  - using serf 1.3.9 (compiled with 1.3.9)
  - handles 'http' scheme
  - handles 'https' scheme

The following authentication credential caches are available:

* Mac OS X Keychain

仍然不确定这是创建新水龙头的最佳方式。我在 GitHub 上创建了 homebrew-repo,然后添加了水龙头,然后使用 tap-new.

初始化了水龙头
$ TAP=rjollos/homebrew-repo
$ TAP_PATH=$(brew --repository)/Library/Taps/$TAP

$ brew tap $TAP
==> Tapping rjollos/repo
Cloning into '/usr/local/Homebrew/Library/Taps/rjollos/homebrew-repo'...
warning: You appear to have cloned an empty repository.
Tapped (16 files, 22.2KB).

$ brew tap-new $TAP
==> Created rjollos/repo
/usr/local/Homebrew/Library/Taps/rjollos/homebrew-repo

$ cd $TAP_PATH

$ git add .

$ git commit -m "Initialized with template files"
[master (root-commit) c7c4bed] Initialized with template files
 2 files changed, 29 insertions(+)
 create mode 100644 .github/workflows/main.yml
 create mode 100644 README.md

$ git remote -v
origin  https://github.com/rjollos/homebrew-repo (fetch)
origin  https://github.com/rjollos/homebrew-repo (push)

提取版本化公式:

$ brew extract --version 1.13.0 subversion $TAP
==> Searching repository history
==> Writing formula for subversion from revision dab5452 to:
/usr/local/Homebrew/Library/Taps/rjollos/homebrew-repo/Formula/subversion@1.13.0.rb

添加公式:

$ cd $TAP_PATH
$ git add Formula
$ git commit -m "Add Subversion 1.13 formula"
 1 file changed, 203 insertions(+)
 create mode 100644 Formula/subversion@1.13.0.rb
$ git push
Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression using up to 8 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (10/10), 3.99 KiB | 2.00 MiB/s, done.
Total 10 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/rjollos/homebrew-repo
 * [new branch]      master -> master

无需实际 github 存储库即可在本地创建 Taps。这是一般示例:

TAP=...     # <org>/<repo>, for example "my-org/homebrew-old"
MODULE=...  # name of module you want to install, e.g. "hugo"
VERS=...    # version of $MODULE you want to install, e.g., "0.80.0"
brew tap-new $TAP
brew extract --version $VERS $MODULE $TAP
brew install $TAP/$MODULE@$VERS