Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Commit

Permalink
Merge pull request #110 from boxen/high-sierra
Browse files Browse the repository at this point in the history
Don't manage `/usr/local`
  • Loading branch information
jacobbednarz committed Mar 25, 2018
2 parents ea3f0ca + f49554f commit 9850c7d
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 58 deletions.
4 changes: 0 additions & 4 deletions files/brew-boxen-install.rb

This file was deleted.

7 changes: 0 additions & 7 deletions files/brew-boxen-latest.rb

This file was deleted.

4 changes: 2 additions & 2 deletions lib/puppet/provider/package/homebrew.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
15 changes: 8 additions & 7 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
43 changes: 19 additions & 24 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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';
}

->
Expand Down
6 changes: 3 additions & 3 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <| |>
}
Expand Down
15 changes: 5 additions & 10 deletions spec/classes/homebrew_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -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
2 changes: 1 addition & 1 deletion spec/defines/homebrew__formula_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9850c7d

Please sign in to comment.