【问题标题】:Installing previous versions of a formula with brew extract使用 brew extract 安装以前版本的公式
【发布时间】:2020-10-28 07:16:27
【问题描述】:

由于 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)

【问题讨论】:

  • Homebrew #7948中描述,版本应该是1.13.0而不是1.13.0_5

标签: homebrew


【解决方案1】:

我尝试了brew install &lt;url&gt; 方法,似乎对我很有效?

安装日志:

$ 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

【讨论】:

  • 它确实有效。你收到了和我一样的警告:Warning: Calling Installation of subversion from a GitHub commit URL is deprecated! Use 'brew extract subversion' to stable tap on GitHub instead.
  • 我确实有另一种在这里提到的 hacky 方式,stackoverflow.com/a/62765875/791609,无论哪种方式都会做同样的事情。
  • 在我看来,brew extract 是创建版本化公式的新的正确方法,避免了我们过去使用的技巧,但我没有找到任何分步文档关于创建公式。
  • 这是一个很好的反馈,我可以在这个周末玩它。不过,我之前没有使用过brew extract &lt;xx&gt;,TBH。
  • 我为遇到的问题创建了一个问题,brew 中可能存在缺陷:github.com/Homebrew/brew/issues/7948
【解决方案2】:

仍然不确定这是创建新水龙头的最佳方式。我在我的 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

【讨论】:

  • 很棒的步骤和文档。谢谢!
【解决方案3】:

无需实际的 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

【讨论】:

  • 非常感谢,它完美运行,没有任何问题?
  • 可能有助于澄清 &lt;org&gt;/&lt;repo&gt; 是您编造的,而不是 homebrew/core 等。
  • 安装 antlr 4.7.2 时出现Unsupported special dependency :java 错误
  • 很高兴尝试这个,但对我不起作用:
  • 它似乎只适用于最新版本?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-09-03
  • 1970-01-01
  • 1970-01-01
  • 2020-01-13
  • 1970-01-01
  • 2017-08-30
  • 2011-06-30
相关资源
最近更新 更多