diff --git a/files/brew-boxen-install.rb b/files/brew-boxen-install.rb deleted file mode 100755 index 41b33fd..0000000 --- a/files/brew-boxen-install.rb +++ /dev/null @@ -1,4 +0,0 @@ -require "cmd/install" - -# A custom Homebrew command that loads our bottle hooks. -Homebrew.install diff --git a/files/brew-boxen-latest.rb b/files/brew-boxen-latest.rb deleted file mode 100755 index 133d0b0..0000000 --- a/files/brew-boxen-latest.rb +++ /dev/null @@ -1,7 +0,0 @@ -# A custom Homebrew command that gives us the latest available version -# for a given formula. This allows us to avoid the terrifying prospect -# of loading Homebrew Ruby code in the Puppet process. -# -# $ brew boxen-latest -raise FormulaUnspecifiedError if ARGV.named.empty? -puts ARGV.formulae.first.pkg_version diff --git a/lib/puppet/provider/package/homebrew.rb b/lib/puppet/provider/package/homebrew.rb index 0e4774e..50e91b1 100644 --- a/lib/puppet/provider/package/homebrew.rb +++ b/lib/puppet/provider/package/homebrew.rb @@ -80,7 +80,7 @@ def install if install_options.any? execute [ "brew", "install", @resource[:name], *install_options ].flatten, command_opts else - execute [ "brew", "boxen-install", @resource[:name] ], command_opts + execute [ "brew", "install", @resource[:name] ].flatten, command_opts end end end @@ -106,7 +106,7 @@ def install_options end def latest - execute([ "brew", "boxen-latest", @resource[:name] ], command_opts).strip + execute([ "brew", "ls", "--versions", @resource[:name] ], command_opts.merge({ :failonfail => false })).split.last end def query diff --git a/manifests/config.pp b/manifests/config.pp index 7897adb..3323d53 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -7,14 +7,15 @@ class homebrew::config { include boxen::config - $cachedir = "${boxen::config::cachedir}/homebrew" - $installdir = $::homebrew_root - $libdir = "${installdir}/lib" + $cachedir = "${boxen::config::cachedir}/homebrew" + $installdir = $::homebrew_root + $repositorydir = "${installdir}/Homebrew" + $libdir = "${installdir}/lib" - $cmddir = "${installdir}/Library/Homebrew/cmd" - $tapsdir = "${installdir}/Library/Taps" + $cmddir = "${repositorydir}/Library/Homebrew/cmd" + $tapsdir = "${repositorydir}/Library/Taps" - $brewsdir = "${tapsdir}/boxen/homebrew-brews" + $brewsdir = "${tapsdir}/boxen/homebrew-brews" - $min_revision = 'd5b6ecfc5078041ddf5f61b259c57f81d5c50fcc' + $min_revision = 'd5b6ecfc5078041ddf5f61b259c57f81d5c50fcc' } diff --git a/manifests/init.pp b/manifests/init.pp index f702096..5d43cd9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -5,22 +5,22 @@ # include homebrew class homebrew( - $cachedir = $homebrew::config::cachedir, - $installdir = $homebrew::config::installdir, - $libdir = $homebrew::config::libdir, - $cmddir = $homebrew::config::cmddir, - $tapsdir = $homebrew::config::tapsdir, - $brewsdir = $homebrew::config::brewsdir, - $min_revision = $homebrew::config::min_revision, - $repo = 'Homebrew/brew', - $set_cflags = true, - $set_ldflags = true, + $cachedir = $homebrew::config::cachedir, + $installdir = $homebrew::config::installdir, + $repositorydir = $homebrew::config::repositorydir, + $libdir = $homebrew::config::libdir, + $cmddir = $homebrew::config::cmddir, + $tapsdir = $homebrew::config::tapsdir, + $brewsdir = $homebrew::config::brewsdir, + $min_revision = $homebrew::config::min_revision, + $repo = 'Homebrew/brew', + $set_cflags = true, + $set_ldflags = true, ) inherits homebrew::config { include boxen::config include homebrew::repo - file { [$installdir, - "${installdir}/bin", + file { ["${installdir}/bin", "${installdir}/etc", "${installdir}/include", "${installdir}/lib", @@ -43,29 +43,29 @@ "${installdir}/share/aclocal", "${installdir}/var", "${installdir}/var/log", + $repositorydir, ]: ensure => 'directory', owner => $::boxen_user, group => 'staff', mode => '0755', require => undef, - before => Exec["install homebrew to ${installdir}"], + before => Exec["install homebrew to ${repositorydir}"], } - exec { "install homebrew to ${installdir}": + exec { "install homebrew to ${repositorydir}": command => "git init -q && git config remote.origin.url https://github.com/${repo} && git config remote.origin.fetch master:refs/remotes/origin/master && git fetch origin master:refs/remotes/origin/master -n && git reset --hard origin/master", - cwd => $installdir, + cwd => $repositorydir, user => $::boxen_user, - creates => "${installdir}/.git", - require => File[$installdir], + creates => "${repositorydir}/.git", } File { - require => Exec["install homebrew to ${installdir}"], + require => Exec["install homebrew to ${repositorydir}"], } # Remove the old monkey patches, from pre #39 @@ -94,12 +94,7 @@ $brewsdir, "${brewsdir}/cmd" ]: - ensure => 'directory' ; - - "${brewsdir}/cmd/brew-boxen-latest.rb": - source => 'puppet:///modules/homebrew/brew-boxen-latest.rb' ; - "${brewsdir}/cmd/brew-boxen-install.rb": - source => 'puppet:///modules/homebrew/brew-boxen-install.rb' ; + ensure => 'directory'; } -> diff --git a/manifests/repo.pp b/manifests/repo.pp index da65860..1a95eee 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -4,13 +4,13 @@ # # include homebrew::repo class homebrew::repo ( - $installdir = $homebrew::config::installdir, - $min_revision = $homebrew::config::min_revision, + $repositorydir = $homebrew::config::repositorydir, + $min_revision = $homebrew::config::min_revision, ) { require homebrew if $::osfamily == 'Darwin' { - homebrew_repo { $installdir: + homebrew_repo { $repositorydir: min_revision => $min_revision, } -> Package <| |> } diff --git a/spec/classes/homebrew_spec.rb b/spec/classes/homebrew_spec.rb index d6b3176..1a03030 100644 --- a/spec/classes/homebrew_spec.rb +++ b/spec/classes/homebrew_spec.rb @@ -4,13 +4,13 @@ let(:facts) { default_test_facts } let(:dir) { facts[:homebrew_root] } - let(:cmddir) { "#{dir}/Library/Taps/boxen/homebrew-brews/cmd" } + let(:cmddir) { "#{dir}/Homebrew/Library/Taps/boxen/homebrew-brews/cmd" } it do - should contain_exec("install homebrew to #{dir}").with({ - :cwd => dir, + should contain_exec("install homebrew to #{dir}/Homebrew").with({ + :cwd => "#{dir}/Homebrew", :user => 'testuser', - :creates => "#{dir}/.git" + :creates => "#{dir}/Homebrew/.git" }) ["ldflags.sh", "cflags.sh", "homebrew.sh"].each do |f| @@ -20,14 +20,9 @@ should contain_boxen__env_script("homebrew") - ["latest", "install"].each do |cmd| - should contain_file("#{cmddir}/brew-boxen-#{cmd}.rb"). - with_source("puppet:///modules/homebrew/brew-boxen-#{cmd}.rb") - end - should contain_file("#{dir}/lib").with_ensure("directory") should contain_file(cmddir).with_ensure("directory") - should contain_file("#{dir}/Library/Taps").with_ensure("directory") + should contain_file("#{dir}/Homebrew/Library/Taps").with_ensure("directory") should contain_file("/test/boxen/cache/homebrew").with_ensure("directory") end end diff --git a/spec/defines/homebrew__formula_spec.rb b/spec/defines/homebrew__formula_spec.rb index a2d188a..7986b57 100644 --- a/spec/defines/homebrew__formula_spec.rb +++ b/spec/defines/homebrew__formula_spec.rb @@ -4,7 +4,7 @@ let(:facts) { default_test_facts } let(:title) { "clojure" } - let(:tapdir) { "#{facts[:homebrew_root]}/Library/Taps/boxen/homebrew-brews" } + let(:tapdir) { "#{facts[:homebrew_root]}/Homebrew/Library/Taps/boxen/homebrew-brews" } context "with source provided" do let(:params) do