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 #156 from boxen/bump-base-ruby-build-min
Browse files Browse the repository at this point in the history
Use a more recent `ruby-build` version
  • Loading branch information
jacobbednarz authored Sep 26, 2017
2 parents 4c7b6e1 + bdc179a commit cab20f7
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 32 deletions.
2 changes: 1 addition & 1 deletion data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ruby::prefix: '/opt'
ruby::provider: 'rbenv'
ruby::user: "%{::id}"

ruby::build::ensure: 'v20161225'
ruby::build::ensure: 'v20170914'
ruby::build::prefix: "%{hiera('ruby::prefix')}/ruby-build"
ruby::build::user: "%{hiera('ruby::user')}"

Expand Down
30 changes: 2 additions & 28 deletions lib/puppet/provider/ruby/rubybuild.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,17 @@ def create
raise Puppet::Error, "Can't install ruby because we're offline and the tarball isn't cached"
end
else
try_to_download_precompiled_ruby || build_ruby
build_ruby
end
rescue => e
raise Puppet::Error, "install failed with a crazy error: #{e.message} #{e.backtrace}"
raise Puppet::Error, "install failed with an error: #{e.message} #{e.backtrace}"
end

def destroy
FileUtils.rm_rf prefix
end

private
def try_to_download_precompiled_ruby
Puppet.debug("Trying to download precompiled ruby for #{version}")
output = execute "curl --silent --fail #{precompiled_url} >#{tmp} && tar xjf #{tmp} -C /opt/rubies", command_options.merge(:failonfail => false)

output.exitstatus == 0
ensure
FileUtils.rm_f tmp
end

def build_ruby
execute "#{ruby_build} #{version} #{prefix}", command_options.merge(:failonfail => true)
Expand All @@ -81,24 +73,6 @@ def s3_cellar
end
end

def precompiled_url
base = Facter.value(:boxen_download_url_base) ||
"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
).join("")
end

def os_release
case Facter.value(:operatingsystem)
when "Darwin"
Expand Down
2 changes: 1 addition & 1 deletion manifests/build.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
repository { $prefix:
ensure => $ensure,
force => true,
source => 'sstephenson/ruby-build',
source => 'rbenv/ruby-build',
user => $user,
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/rbenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
repository { $prefix:
ensure => $ensure,
force => true,
source => 'sstephenson/rbenv',
source => 'rbenv/rbenv',
user => $user
}

Expand Down
2 changes: 1 addition & 1 deletion spec/classes/ruby_rbenv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
should contain_repository('/test/boxen/rbenv').with({
:ensure => 'v0.4.0',
:force => true,
:source => 'sstephenson/rbenv',
:source => 'rbenv/rbenv',
:user => 'testuser'
})

Expand Down

0 comments on commit cab20f7

Please sign in to comment.