25

Due to a problem with the Subversion 1.13 Brew formula I was installing an older revision of the formula:

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

That gives a warning:

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

The suggestion is the same as this tip.

Now, I'd like to do this properly using brew extract subversion rather than using the deprecated commit URL. I'd like to install Subversion 1.13_5 on some computers, but Subversion 1.14 is the latest formula.

I need to do something like this: brew extract --version 1.13.0_5 subversion <tap>.

The way I understand this I should:

  1. Create an empty repository for my versioned formulas
  2. Add the repository as a tap and initialize it
  3. Extract the versioned formula
  4. Commit and push the formula?

I created an empty repository, then:

$ 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>

I think I'm doing several things wrong, but mainly I'm unsure why brew extract doesn't work. Also, is there a better way to create a new repository and populate it with the template files for a new tap?

$ 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)
RjOllos
  • 2,900
  • 1
  • 19
  • 29
  • Described in [Homebrew #7948](https://github.com/Homebrew/brew/issues/7948), version should be `1.13.0` rather than `1.13.0_5`. – RjOllos Jul 09 '20 at 19:51

3 Answers3

66

Taps can be created locally without actual github repository. Here is general example:

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
Patrice Chalin
  • 15,440
  • 7
  • 33
  • 44
fav
  • 826
  • 8
  • 10
10

Still not sure this is the best way to create a new tap. I created homebrew-repo on my GitHub, then added the tap, then initialized the tap using 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)

Extract the versioned formula:

$ 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

Add the formula:

$ 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
RjOllos
  • 2,900
  • 1
  • 19
  • 29
-2

I tried brew install <url> approach, seems working well for me?

installation log:

$ 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)

version check

$ 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
chenrui
  • 8,910
  • 3
  • 33
  • 43
  • 4
    It does work. And you received the same warning that I did: `Warning: Calling Installation of subversion from a GitHub commit URL is deprecated! Use 'brew extract subversion' to stable tap on GitHub instead.` – RjOllos Jul 08 '20 at 02:52
  • I do have another hacky way which mentioned in here, https://stackoverflow.com/a/62765875/791609, either way would do the same thing. – chenrui Jul 08 '20 at 02:55
  • 2
    It sounds to me like `brew extract` is the new and proper way to create a versioned formula, avoiding the tricks we used in the past, but I haven't found any step-by-step documentation on creating a formula. – RjOllos Jul 08 '20 at 18:44
  • That is a good feedback, I can play around it this weekend. I have not used `brew extract `before though , TBH. – chenrui Jul 08 '20 at 21:23
  • I created an issue for the problem I encountered, possible defect in `brew`: https://github.com/Homebrew/brew/issues/7948. – RjOllos Jul 09 '20 at 00:51
  • Described in [Homebrew #7948](https://github.com/Homebrew/brew/issues/7948), version should be `1.13.0` rather than `1.13.0_5`. I've posted an updated answer. – RjOllos Jul 09 '20 at 20:01