Skip to content

Commit

Permalink
Rewrite open-uri and digest from curl
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt committed Oct 31, 2024
1 parent 2658e63 commit 93b08e8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions install_ruby.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ function get_released_ruby() {
cat << RUBY | ruby - $1
require "net/http"
require "uri"
require "open-uri"
require "digest"
ver2 = ARGV[0].split('.')[0,2].join('.')
if Net::HTTP.get_response(URI.parse("https://cache.ruby-lang.org/pub/ruby/#{ver2}/ruby-#{ARGV[0]}.tar.gz")).code == "200"
url = "https://cache.ruby-lang.org/pub/ruby/#{ver2}/ruby-#{ARGV[0]}.tar.gz"
sha256 = `curl -sSL #{url} | sha256sum`.split(' ')[0]
puts "#{url} #{sha256}"
URI.open(url) do |f|
sha256 = Digest::SHA256.hexdigest(f.read)
puts "#{url} #{sha256}"
end
else
exit 1
RUBY
Expand Down

0 comments on commit 93b08e8

Please sign in to comment.