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

Commit 78a298f

Browse files
committed
Fix downgrading packages.
Boxen is quite insistent about what versions it wants to be installed. If the version installed does not exactly match the version it wants it's going to try to `upgrade` to it. Unfortunately Homebrew doesn't allow `brew upgrade` to downgrade software so the two contradict. Instead of relying on `brew upgrade` instead just `brew unlink` first which lets you install (and link) whatever version you want. It also let's us kill even more Boxen-specific code.
1 parent d5f0247 commit 78a298f

File tree

4 files changed

+10
-17
lines changed

4 files changed

+10
-17
lines changed

files/brew-boxen-upgrade.rb

Lines changed: 0 additions & 5 deletions
This file was deleted.

lib/puppet/provider/package/homebrew.rb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,22 @@ def install
6565
# If the desired version is already installed, just link or
6666
# switch. Somebody might've activated another version for
6767
# testing or something like that.
68-
6968
execute [ "brew", "switch", @resource[:name], version ], command_opts
70-
71-
elsif self.class.current @resource[:name]
72-
# Okay, so there's a version already active, it's not the right
73-
# one, and the right one isn't installed. That's an upgrade.
74-
75-
execute [ "brew", "boxen-upgrade", @resource[:name] ], command_opts
7669
else
77-
# Nothing here? Nothing from before? Yay! It's a normal install.
70+
if self.class.current @resource[:name]
71+
# Okay, so there's a version already active, it's not the right
72+
# one, and the right one isn't installed. That's an upgrade/downgrade.
73+
# However, if we use `brew upgrade` then it won't let us downgrade so
74+
# instead let's `brew unlink` and then we're allowed to `brew install`
75+
# whatever version we want.
76+
execute [ "brew", "unlink", @resource[:name] ], command_opts
77+
end
7878

7979
if install_options.any?
8080
execute [ "brew", "install", @resource[:name], *install_options ].flatten, command_opts
8181
else
8282
execute [ "brew", "boxen-install", @resource[:name] ], command_opts
8383
end
84-
8584
end
8685
end
8786

manifests/init.pp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@
103103
source => 'puppet:///modules/homebrew/brew-boxen-latest.rb' ;
104104
"${brewsdir}/cmd/brew-boxen-install.rb":
105105
source => 'puppet:///modules/homebrew/brew-boxen-install.rb' ;
106-
"${brewsdir}/cmd/brew-boxen-upgrade.rb":
107-
source => 'puppet:///modules/homebrew/brew-boxen-upgrade.rb' ;
108106
}
109107

110108
->
@@ -114,6 +112,7 @@
114112
"${boxen::config::envdir}/30_homebrew.sh",
115113
"${boxen::config::envdir}/cflags.sh",
116114
"${boxen::config::envdir}/ldflags.sh",
115+
"${brewsdir}/cmd/brew-boxen-upgrade.rb",
117116
]:
118117
ensure => absent,
119118
}

spec/classes/homebrew_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
should contain_file("#{cmddir}/boxen-bottle-hooks.rb").
2424
with_source("puppet:///modules/homebrew/boxen-bottle-hooks.rb")
2525

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

0 commit comments

Comments
 (0)