phinze/homebrew-cask — pull request #114 by passcod (2012-12-10 12:27:01+00:00)
Title: Revamp install processes

Not sure whether this should/could be merged in or if it'd be better to cherry-pick/copy/steal selected changes out. Anyway, here goes:

- - - - -

This fork/branch is testing out a radically different way of installing Casks. It develops ideas exposed in the following issues:

- #105 — Features to help manage multiple .app folders
- #89 — Don't make `brew doctor` complain (about unlinked kegs)
- #72 — Features for metadata
- #38 — Moar configuration
- #30 — Config: install/link path
- #41 — Better version management
- #69 — Features for installing different types
- #82 — Checksums

Checksums
---------

`content_length` has been removed. In its stead, there are `md5`, `sha1`, and `sha256` which all take a hexdigest string, e.g:

```ruby
class Candybar < Cask
url 'http://panic.com/museum/candybar/CandyBar 3.3.4.zip'
homepage 'http://panic.com/museum/candybar/'
sha1 'f645e9da45a621415a07a7492c45923b1a1fd4d4'
end
```

`brew cask install` will warn if there is no checksum provided, and error if the sums do not match.

Audit
-----

`brew cask audit` has had a facelift, and is now based on `brew audit`. It checks whitespace, URLs, checksums, versions, and code style just like Homebrew's one, albeit modified to fit Casks (a lot of stuff related to compiling was removed).

Caskroom
--------

Casks are now installed in `$HOMEBREW_PREFIX/Caskroom/$name/$version/` instead of in the Cellar. This stops Homebrew from complaining about unlinked kegs, and from listing our casks on `brew list`.

Devel & Edge
------------

You can now specify alternate specs for *devel* (checksummed, versioned) and *edge* (un-checksummed, unversioned) using blocks, e.g.

```ruby
class Firefox < Cask
url 'http://download.cdn.mozilla.net/pub/mozilla.org/firefox/releases/17.0.1/mac/en-US/Firefox%2017.0.1.dmg'
homepage 'http://www.mozilla.org/en-US/firefox/'
version '17.0.1'
sha1 'a9888ce69440574fabff712549c8ff503fd1acb7'

# Beta
devel do
url 'http://download.cdn.mozilla.net/pub/mozilla.org/firefox/releases/18.0b3/mac/en-US/Firefox%2018.0b3.dmg'
version '18.0b3'
sha1 '31e383782b4fbbcbf3a1ef578d82cbf6861912cb'
end

# Nightly
edge do
url 'http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/firefox-20.0a1.en-US.mac.dmg'
end
end
```

If the top level `url` is unspecified, then the *edge* spec will be used, e.g.

```ruby
class FirefoxAurora < Cask
homepage 'http://www.mozilla.org/en-US/firefox/aurora/'

edge do
url 'https://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-mozilla-aurora/firefox-19.0a2.en-US.mac.dmg'
version '19.0a2'
end
end
```

### Version parsing

Additionally, we will attempt to parse the URL to get the version, so if the correct version is within the URL, there is no need to specify it explicitely using `version`. This also applies to *devel* specs.

Linking
-------

Moar breaking changes: `brew cask linkapps` is removed. Linking is done at install-time, and by default has the same behaviour (link every `.app` found recursively). However, that behaviour can be overridden in the formula:

```ruby
class Brackets < Cask
url 'https://github.com/downloads/adobe/brackets/brackets-sprint-16-MAC.dmg'
homepage 'http://brackets.io'
version 'sprint-16'
sha1 '94322762ecb00baab857e324a98e543d548bf961'

install :app => 'Brackets Sprint 16.app'
end
```

`install` is spec-specific (so you have a different one for *devel* and *edge*), and takes a hash with a single pair of the form:

:type => 'path/to/file.ext'

You can have as many `install ...` statements as necessary. Currently, the only types supported are `app` (`.app` files, linked into `~/Applications` or whatever `--appdir` is set to) and `pref` (`.prefPane` files, linked into `~/Library/PreferencePanes` or whatever `--prefdir` is set to).

Configuration
-------------

You can now configure some aspects of `brew cask`'s operation. You can set options on the command:

$ brew cask install adium --appdir=/Applications

or you can set them in the `HOMEBREW_CASK_OPTS` environment variable:

```bash
# ~/.bashrc, somewhere at the end of the file

export HOMEBREW_CASK_OPTS='--appdir=/Applications'
```

Command-line options override environment ones.

### Available options:

* `--appdir=PATH` — Where applications are linked / aliased. Defaults to ~/Applications.
* `--prefdir=PATH` — Where preference panes are linked / aliased. Defaults to ~/Library/PreferencePanes.
* `--edge` — Use the edge spec for that cask.
* `--devel` — Use the devel spec for that cask.
* `--stable` — Use the stable spec for that cask. Useful to override the ENV.
* `--[no-]ignore-edge-only` — Ignore “edge-only” problems when auditing casks. If you're
working with `brew cask audit` a lot, I recommend you put it in your `HOMEBREW_CASK_OPTS`.

Cask info
---------

`brew cask info ` now gives:

```plain
adium: 1.5.3
http://www.adium.im/
/usr/local/Caskroom/adium/1.5.3 (2947 files, 69M)
https://github.com/phinze/cask/commits/master/Casks/adium.rb
```

And you can use `brew cask open ` to open its homepage.