Brew Concepts

From NovaOrdis Knowledge Base
Revision as of 17:21, 29 April 2018 by Ovidiu (talk | contribs) (→‎Cask)
Jump to navigation Jump to search

Internal

Overview

Homebrew is a package management system for Mac. All applications installed with Homebrew are linked from /usr/local/bin which usually takes precedence over /usr/bin:/bin:/usr/sbin:/sbin, where system utilities are installed. For example, if bash is installed with Homebrew, it'll be usually the newest one and take precedence over the one that comes with the system in /bin/bash.

Formula

A formula is a package definition written in Ruby. Homebrew comes with a good amount of existing formulae, and they are stored as Ruby files in the default tap named "homebrew/core": /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/<package-name>.rb. The directory where a specific formula is located can be displayed with:

brew formula <formula-name>

The formulae that have already been applied to the system can be listed with:

brew list

An application that has never been installed on the system can be installed with:

brew install <formula-name>

and it can be updated with:

brew update <formula-name>

Common Formulate

bash

/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/bash.rb

Custom Formulae

New formulae can be can be created. Instructions are available here: https://docs.brew.sh/Formula-Cookbook. The sequence is:

brew create <URL> 

where <URL> is a zip or tar file, installed with

brew install <formula>

and debugged with:

brew install --debug --verbose <formula>

Formula API: http://www.rubydoc.info/github/Homebrew/brew/master/Formula

Tap

A tap is a Git repository of formulae and other commands.

The list of all taps available on the system is provided by:

brew tap

A new repository can be added.

Keg

A keg is the installation prefix of a formula. The corresponding directories are stored in cellar.

Example:

/usr/local/Cellar/foo/0.1

Cellar

The directory where all kegs are stored:

/usr/local/Cellar

Bottle

Homebrew-Cask

Cask

https://caskroom.github.io
https://github.com/caskroom/homebrew-cask/blob/master/USAGE.md

A cask is application distributed in binary form. Examples: google-chrome, docker. brew-cask provides a CLI workflow for the administration of macOS graphical applications distributed as binaries. The difference between "brew" and "brew cask" comes from the difference between application downloaded as source code that will be compiled, or as an already compiled package.

To install Homebrew Cask itself:

brew tap caskroom/cask

An example of installing Google Chrome with cask:

brew cask install google-chrome
==> Satisfying dependencies
==> Downloading https://dl.google.com/chrome/mac/stable/GGRO/googlechrome.dmg
######################################################################## 100.0%
==> Verifying checksum for Cask google-chrome
==> Installing Cask google-chrome
==> Moving App 'Google Chrome.app' to '/Applications/Google Chrome.app'.
🍺  google-chrome was successfully installed!


Caskroom

User Space vs. System Space