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 #137 from boxen/binary-tweaks
Browse files Browse the repository at this point in the history
Binary tweaks
  • Loading branch information
MikeMcQuaid committed Mar 12, 2015
2 parents a0b1e55 + 8fb455f commit 56428d1
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/puppet/provider/ruby/rubybuild.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,12 @@ def query
def create
destroy if File.directory?(prefix)

default_boxen_homebrew = !Facter.value(:homebrew_root)
default_boxen_homebrew ||= Facter.value(:homebrew_root) == "/opt/boxen/homebrew"

if Facter.value(:offline) == "true"
if File.exist?("#{cache_path}/ruby-#{version}.tar.gz")
build_ruby
else
raise Puppet::Error, "Can't install ruby because we're offline and the tarball isn't cached"
end
elsif !default_boxen_homebrew
Puppet.debug("Can't use ruby binary due to custom Homebrew location")
build_ruby
else
try_to_download_precompiled_ruby || build_ruby
end
Expand Down Expand Up @@ -76,17 +70,29 @@ def tmp
"/tmp/ruby-#{version}.tar.bz2"
end

# Keep in sync with same-named function in:
# https://github.com/boxen/our-boxen/blob/master/script/sync
def s3_cellar
homebrew_cellar = "#{Facter.value(:homebrew_root)}/Cellar"
case homebrew_cellar
when "/Cellar", "/opt/boxen/homebrew/Cellar" then ""
when "/usr/local/Cellar" then "default/"
else "#{Base64.strict_encode64(homebrew_cellar)}/"
end
end

def precompiled_url
base = Facter.value(:boxen_download_url_base) ||
"http://#{Facter.value(:boxen_s3_host)}/#{Facter.value(:boxen_s3_bucket)}"
"https://#{Facter.value(:boxen_s3_host)}/#{Facter.value(:boxen_s3_bucket)}"

%W(
#{base}
/
rubies
/
#{Facter.value(:operatingsystem)}
/
#{s3_cellar}
#{os_release}
/
#{CGI.escape(version)}.tar.bz2
Expand Down

0 comments on commit 56428d1

Please sign in to comment.