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 #85 from boxen/fix-downgrades
Browse files Browse the repository at this point in the history
Fix downgrading packages.
  • Loading branch information
MikeMcQuaid committed Jun 5, 2015
2 parents d5f0247 + 78a298f commit 3537c38
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
5 changes: 0 additions & 5 deletions files/brew-boxen-upgrade.rb

This file was deleted.

17 changes: 8 additions & 9 deletions lib/puppet/provider/package/homebrew.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,22 @@ def install
# If the desired version is already installed, just link or
# switch. Somebody might've activated another version for
# testing or something like that.

execute [ "brew", "switch", @resource[:name], version ], command_opts

elsif self.class.current @resource[:name]
# Okay, so there's a version already active, it's not the right
# one, and the right one isn't installed. That's an upgrade.

execute [ "brew", "boxen-upgrade", @resource[:name] ], command_opts
else
# Nothing here? Nothing from before? Yay! It's a normal install.
if self.class.current @resource[:name]
# Okay, so there's a version already active, it's not the right
# one, and the right one isn't installed. That's an upgrade/downgrade.
# However, if we use `brew upgrade` then it won't let us downgrade so
# instead let's `brew unlink` and then we're allowed to `brew install`
# whatever version we want.
execute [ "brew", "unlink", @resource[:name] ], command_opts
end

if install_options.any?
execute [ "brew", "install", @resource[:name], *install_options ].flatten, command_opts
else
execute [ "brew", "boxen-install", @resource[:name] ], command_opts
end

end
end

Expand Down
3 changes: 1 addition & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@
source => 'puppet:///modules/homebrew/brew-boxen-latest.rb' ;
"${brewsdir}/cmd/brew-boxen-install.rb":
source => 'puppet:///modules/homebrew/brew-boxen-install.rb' ;
"${brewsdir}/cmd/brew-boxen-upgrade.rb":
source => 'puppet:///modules/homebrew/brew-boxen-upgrade.rb' ;
}

->
Expand All @@ -114,6 +112,7 @@
"${boxen::config::envdir}/30_homebrew.sh",
"${boxen::config::envdir}/cflags.sh",
"${boxen::config::envdir}/ldflags.sh",
"${brewsdir}/cmd/brew-boxen-upgrade.rb",
]:
ensure => absent,
}
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/homebrew_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
should contain_file("#{cmddir}/boxen-bottle-hooks.rb").
with_source("puppet:///modules/homebrew/boxen-bottle-hooks.rb")

["latest", "install", "upgrade"].each do |cmd|
["latest", "install"].each do |cmd|
should contain_file("#{cmddir}/brew-boxen-#{cmd}.rb").
with_source("puppet:///modules/homebrew/brew-boxen-#{cmd}.rb")
end
Expand Down

0 comments on commit 3537c38

Please sign in to comment.