Skip to content
This repository has been archived by the owner on Jan 16, 2025. It is now read-only.

New external command: brew-tap #6086

Closed
wants to merge 30 commits into from
Closed

Conversation

Sharpie
Copy link
Contributor

@Sharpie Sharpie commented Jun 19, 2011

brew-tap is an external command that brings multi-repo support to Homebrew by making it easy to add alternate repositories, update them, and install the formulae they contain. Currently, the tool is set up to use repositories in the fork network of Adam's homebrew-alt:

https://github.com/adamv/homebrew-alt/network

See the manpage for full usage details:

https://raw.github.com/Sharpie/homebrew/brew-tap/Library/Contributions/manpages/brew-tap.1.md

When creating brew-tap I tried very hard to integrate with existing Homebrew code and style. However, one small change was required to the core file formula.rb in order to enable dependency resolution among formulae in alternate repositories by adding an :alt type to depends_on. This dependency type is ignored by brew, but used by brew-tap. See the HDF-EOS2 formula for an example of :alt usage:

https://github.com/Sharpie/homebrew-science/blob/for-science/scientific/hdf-eos2.rb#L24

I have been using this subcommand for a couple of months and I think it would be a great addition to Homebrew!

@mxcl
Copy link
Contributor

mxcl commented Jul 7, 2011

This is cool. I'll review. Adam let me know if you have concerns, etc.

@Sharpie
Copy link
Contributor Author

Sharpie commented Jul 7, 2011

Thanks for taking the time to look at my code Max!

@Sharpie
Copy link
Contributor Author

Sharpie commented Jul 9, 2011

One thing that just crossed my mind is that I should include some method of flagging kegs as being installed by brew tap install such that brew doctor can pick up on it. That way if someone uses brew-tap to install things we don't provide in the main repo and then those things interfear with later installs, we can see the presence of non-standard software in bug reports.

@adamv, @MikeMcQuaid thoughts?

@adamv
Copy link
Contributor

adamv commented Jul 10, 2011

This can be worked into the mechanism Homebrew will use to save options from normal installs, the metadata file. I'm working on it in a branch, but need to rebase it against master; the install-name fixes are causing me a slight conflict due to a change in indent level.

@mxcl
Copy link
Contributor

mxcl commented Jul 10, 2011

In the spirit of homebrew this kind of metadata should be a new folder and symlinks. I mean the tappedbrews not the options. The options would have to be in some metadata store.

@MikeMcQuaid
Copy link
Member

I agree with @mxcl. I'm wary of making brew-tap too good an external command as it might limit the likelihood of us making a "proper" integrated solution (or it could be start to be the base for one).

@Sharpie
Copy link
Contributor Author

Sharpie commented Jul 10, 2011

@mxcl:

I agree that that folders and symlinks would be the best system. However, currently brew tap install just expands formula names into paths and recalls brew install. Getting things to install into separate folders would require re-implementing some of the installation routines with custom versions. These custom versions would have to be re-worked every time the functionality of brew install changes in order to keep things consistent. Perhaps this sort of system would be more appropriate if brewing from alternate repositories moves into the Homebrew core?

Currently I was thinking of something quick and dirty, like touching an INSTALLED-BY-BREW-TAP file inside the keg after brew install finishes execution. Then brew doctor could easily get a list of kegs installed through brew-tap via something like:

Dir["#{HOMEBREW_PREFIX}/**/INSTALLED-BY-BREW-TAP"]

@MikeMcQuaid:

From the beginning of this project I have been hoping that brew-tap could eventually form the basis of multirepo support in the Homebrew core---or at least a good case study for figuring out what works and what doesn't in this situation.

@mxcl
Copy link
Contributor

mxcl commented Jul 30, 2011

Still integrating this, haven't forgotten, I promise. Max x

@Sharpie
Copy link
Contributor Author

Sharpie commented Aug 4, 2011

@mxcl

Sounds good, let me know if you have any questions or concerns.

@Sharpie
Copy link
Contributor Author

Sharpie commented Sep 17, 2011

I'm taking a shot at integrating brew-tap into the core code instead of having it as an external command. Pull request #7643 is tracking the changes.

@samueljohn
Copy link
Contributor

Notes from my attempt to install brew tap:

sudo gem install httparty is needed.

   brew tap add samueljohn/homebrew-alt
   Error: No repository named samueljohn/homebrew-alt on the menu!

But I have forked homebrew-alt: https://github.com/samueljohn/homebrew-alt

There I am stuck right now.

@Sharpie
Copy link
Contributor Author

Sharpie commented Sep 22, 2011

@samueljohn

We hit up the GitHub API to retrieve the Homebrew-alt fork network---this in turn is used to determine the list of available repositories. The weird thing is that you show up if the V2 API is used to retrieve the forks, but not if the V3 API is used---so there must be some GitHub synching issue going on.

I'll send them a support request.

@samueljohn
Copy link
Contributor

@Sharpie
Thanks. So I'll just wait. Right now it's still not found.

@ashgti
Copy link
Contributor

ashgti commented Oct 7, 2011

Is it possible to have a repository that is outside of the Homebrew-alt fork network as a taproom?

@Sharpie
Copy link
Contributor Author

Sharpie commented Oct 7, 2011

@ashgti

There is no explicit support for it, but you should be able to add one manually:

cd /usr/local/Library/Taproom
git clone <repository> <name>

Then you should be able to install formulae:

brew tap install <name>/<formula>

I would like to make this easier in the future but it is beyond the scope of my current efforts.

@docwhat
Copy link
Contributor

docwhat commented Jan 17, 2012

Is there anything I can do to help with this effort? I'd like to have homebrew-alt be a first class citizen... :-)

@samueljohn
Copy link
Contributor

I am trying brew tap. Works good!

One issue, perhaps:

brew tap search scipy
No formula found for "/usr/local/Library/Taproom/samueljohn-homebrew-alt/other/scipy.rb". Searching open pull requests...

When in fact there is my scipy formula and brew tap install scipy works. And brew tap which also works:

brew tap which scipy
/usr/local/Library/Taproom/samueljohn-homebrew-alt/other/scipy.rb

I added my homebrew-alt for via brew tap add samueljohn. That works like charm.

@Sharpie
Copy link
Contributor Author

Sharpie commented Jan 26, 2012

@docwhat

Is there anything I can do to help with this effort? I'd like to have homebrew-alt be a first class citizen... :-)

This pull request is essentially complete (but bug reports are welcomed and needed!) and is inteded as a way for people to add multi-repo support to an existing Homebrew installation without much fuss. First-class support is being developed in #7643.

@samueljohn

At this point, there is no implementation for searching. brew tap search just re-calls brew search which has no clue what to do with external formulae.

@samueljohn
Copy link
Contributor

@Sharpie, I have another strange issue.
To reproduce/verify: brew tap add samueljohn

Then brew tap install wxpython works but brew tap install numpy does not :-(
The output is: This command requires a formula argument
Both can be found with brew tap which numpy or brew tap which wxpython. Note, they are in the same directory.

What am I doing wrong?

@samueljohn
Copy link
Contributor

More:

  brew -v tap install numpy
  Homebrew 0.8.1
  brew install -v
  This command requires a formula argument
  Kernel.exit

@wjwwood
Copy link
Contributor

wjwwood commented Feb 24, 2012

@samueljohn I get the same thing (This command requires a formula argument) if I try to install a formula that is already installed. You can reproduce on mine with:

brew tap add ros-deps
brew tap install ros/fuerte/swig-wx
....Installation stuff...
brew tap install ros/fuerte/swig-wx
This command requires a formula argument

@wjwwood
Copy link
Contributor

wjwwood commented Feb 24, 2012

Also, is there a way to depend on formula in tap?

For example, say formula catkin and swig-wx are in a tap called ros-deps. How can I make catkin depend on swig-wx from ros-deps?

Because:

depends_on 'swig-wx'

Gives me:

Error: No available formula for swig-wx

Is there a different syntax for depending on tap formulae? Something like:

depends_on 'ros-deps/swig-wx'
OR
depends_on 'ros-deps-swig-wx'
OR
depends_on 'swig-wx' => :tap

UPDATE:

I figure this out myself:

depends_on 'ros-deps/swig-wx' => :alt

Works. Sorry for the noise.

@wjwwood
Copy link
Contributor

wjwwood commented Feb 29, 2012

This pull request doesn't seem to apply cleanly on a fresh vm.

To reproduce:

  • I setup a fresh vm
  • apple updates
  • install clt-4.3 (not xcode)
  • Install homebrew: /usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
  • brew update
  • brew pull 6086

I get this: https://gist.github.com/1936861

Relavent parts:

error: patch failed: Library/Homebrew/formula.rb:644
error: Library/Homebrew/formula.rb: patch does not apply
Patch failed at 0020 Add new external dependency type `:alt`
When you have resolved this problem run "git am --resolved".
If you would prefer to skip this patch, instead run "git am --skip".
To restore the original branch and stop patching run "git am --abort".
Error: Failure while executing: git am --signoff --whitespace=fix /Users/william/Library/Caches/Homebrew/6086.patch

I think this commit keeps formula.rb from merging automagically: c4027c4#Library/Homebrew/formula.rb

@Sharpie
Copy link
Contributor Author

Sharpie commented Feb 29, 2012

@wjwwood

Thanks for the report and tracing the problem down---it looks like a simple matter of updating the cross-repo deps code to be compatible with a recent change that added more external deps.

I've been traveling all weekend and am coming down with the flu tonight, but I will try to clear this up tomorrow.

`brew tap` is planned to be a subcommand for "tapping" (checking out)
repositories from other "breweries" (GitHub users other than mxcl) and then
managing syncs and installs.

Initial commit contains an implementation of the Brewery class which is a
simple abstraction of a GitHub repository. Brewery instances can query GitHub
for information such as branch lists and fork networks through memoized API
calls.
New class named Taproom. Instances of taproom represent folders where
repositories ("Breweries") are checked out. The list of available repositories
is generated from the fork network of a "founding brewery". Adamv's
homebrew-alt repository is being used as the prototype founder.

The "founding brewery" concept will probably need to be refactored away someday
in the name of generalization, but right now it serves as a useful boundary by
restricting the list of possible repositories to a well-known quantity.

Also added support for what will eventually be the dispatch method of
`brew-tap` subcommands. Currently implemented:

  - list: Prints out a "menu" that lists the available "breweries"

  - update: Refreshes the menu.
Taproom objects can now report on the breweries they have available and which
are on tap (checked out). A Taproom can also place a brewery on tap by cloning
it into the Taproom path.

Library/Taproom was chosen as the default taproom path which required adding an
entry to the master .gitignore file. This could probably be avoided by using
HOMEBREW_PREFIX/Taproom but Library/Taproom seems more logical as it is next to
the master Formula directory.
Two alternate repositories may provide different formulae for the same
software. `brew-tap` will now accepts forumla names of the following form:

    repo/[subdirectories]/formula

Case-sensitive partial matching is also used. For example, the following
formula specification:

    adam/gcc

Would cause the formula search to use the following glob:

    TAPROOM_PATH/adam*/**/gcc.rb

Specifying subdirectories also works:

    adam/dupe/gcc => TAPROOM_PATH/adam*/dup*/**/gcc.rb

Both of these globs resolve to the following path:

    TAPROOM_PATH/adamv-homebrew-alt/duplicates/gcc.rb
Partial matching of brewery names is now case sensitive. This was done for
consistancy as the partial matching used for formula names is case sensitive
and there is no easy way to make it insensitive.
brew-tap can now loop over each tapped repository and perform an operation
similar to brew update. A modified version of the RefreshBrew class is used, so
the update operation is summarized in a similar way.
The menu is now separated into tapped and untapped repositories.
Various stylistic and organizational tweaks. Trimmed some unused material.
Made usage more concise and clarified examples in manpage.
The GitHub API now returns `master_branch` in repository summaries. This
allows the use of a better, simpler method for discovering the name of this
branch.
Small tweak to Homebrew core to allow for a new `:alt` external dependency
type. Dependencies flagged as `:alt` will be ignored by Homebrew core commands
and so will not raise errors.
`brew-tap` now scans alternate formulae for dependencies of the form:

    depends_on 'repo/formula' => :alt

If `repo` has not been added to the taproom, it is cloned. The original
formula along with it's dependencies are then formed into a correctly sorted
list for `brew install`
Now that the newest GitHub API offers repository access, brew-tap should use it
instead of the V2 API.
The method by which `RefreshBrew` detects changes was improved by:

  Homebrew/legacy-homebrew@cae8f9e

This patch upgrades the version of `RefreshBrew` used by `brew-tap` to be
compatible.
Normally `brew-tap` expands all formula arguments into paths to formula files
and then recalls `brew`. This is inappropriate for `brew uninstall` so we pass
formula names unchanged.
The mechanics of how `brew update` obtains a diff changed which requires a
small update to `brew-tap update`.
Unlike version 2, v3 of the GitHub API splits long lists of responses into
pages. So, we may need multiple requests in order to retrieve the whole fork
network. The code used to locate the "last page" is a bit hacky---but I can't
think of anything better at the moment.
Just had my University firewall hose `git:` connections.
@Sharpie
Copy link
Contributor Author

Sharpie commented Feb 29, 2012

Allright, this should apply cleanly on master again. I did a rebase followed by a force-push, which is something that I have been trying to avoid in this pull request---but there was no other obvious way to straighten this out.

@pboling
Copy link

pboling commented Mar 8, 2012

+1

@adamv
Copy link
Contributor

adamv commented Mar 16, 2012

@mxcl pushed his brew-tap, so closing this

@adamv adamv closed this Mar 16, 2012
@Homebrew Homebrew locked and limited conversation to collaborators Feb 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants