Skip to content

Commit

Permalink
Merge pull request #2305 from rolandwalker/depends_on_brew
Browse files Browse the repository at this point in the history
add dependencies for Homebrew formulae
  • Loading branch information
phinze committed Jan 26, 2014
2 parents b1d5875 + 9d43951 commit a9aabf4
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Additional fields you might need for special use-cases:
| `binary` | relative path to a binary that should be linked into the `~/usr/local/bin` folder on installation
| `input_method` | relative path to a input method that should be linked into the `~/Library/Input Methods` folder on installation
| `nested_container` | relative path to an inner container that must be extracted before moving on with the installation; this allows us to support dmg inside tar, zip inside dmg, etc.
| `depends_on_formula` | a list of Homebrew Formulae upon which this Cask depends
| `caveats` | a string or Ruby block providing the user with Cask-specific information at install time (see __Caveats Details__ for more information)
| `after_install` | a Ruby block containing postflight install operations
| `after_uninstall` | a Ruby block containing postflight uninstall operations
Expand Down
3 changes: 2 additions & 1 deletion FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ Casks currently have five required fields:
* __font__ : (required for fonts) indicates which file(s) should be linked into the Fonts folder on installation
* __input_method__: (required for input method) indicates which file(s) should be linked into the Input Methods folder on installation

and five optional fields:
and six optional fields:

* __binary__: relative path to a binary to be installed
* __uninstall__: (optional for `.pkg`) indicates how to uninstall a package
* __nested_container__: relative path to a nested inner container
* __depends_on_formula__: a list of Homebrew Formulae upon which this Cask depends
* __caveats__: a string or Ruby block providing the user with Cask-specific information at install time
* __after_install__: a Ruby block containing postflight install operations
* __after_uninstall__: a Ruby block containing postflight uninstall operations
Expand Down
6 changes: 6 additions & 0 deletions lib/cask/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def url; self.class.url; end

def version; self.class.version; end

def depends_on_formula; self.class.depends_on_formula; end

def sums; self.class.sums || []; end

def artifacts; self.class.artifacts; end
Expand All @@ -33,6 +35,10 @@ def version(version=nil)
@version ||= version
end

def depends_on_formula(*args)
@depends_on_formula ||= args
end

def artifacts
@artifacts ||= Hash.new { |hash, key| hash[key] = Set.new }
end
Expand Down
26 changes: 26 additions & 0 deletions lib/cask/installer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require 'digest'
require 'dependency_collector'
require 'formula_installer'

class Cask::Installer
def initialize(cask, command=Cask::SystemCommand)
Expand Down Expand Up @@ -27,6 +29,7 @@ def install(force=false)
print_caveats

begin
formula_dependencies
download
extract_primary_container
install_artifacts
Expand Down Expand Up @@ -60,6 +63,29 @@ def install_artifacts
end
end

def formula_dependencies
unless @cask.depends_on_formula.empty?
ohai 'Installing Formula dependencies from Homebrew'
@cask.depends_on_formula.each do |dep_name|
dependency_collector = DependencyCollector.new
dep = dependency_collector.add(dep_name)
unless dep.installed?
dep_tab = Tab.for_formula(dep.to_formula)
dep_options = dep.options
dep = dep.to_formula
fi = FormulaInstaller.new(dep)
fi.tab = dep_tab
fi.options = dep_options
fi.ignore_deps = false
fi.show_header = true
fi.install
fi.caveats
fi.finish
end
end
end
end

def print_caveats
self.class.print_caveats(@cask)
end
Expand Down

0 comments on commit a9aabf4

Please sign in to comment.