mirror of
https://github.com/rbenv/ruby-build.git
synced 2026-05-14 16:36:53 -04:00
37 lines
988 B
Ruby
Executable file
37 lines
988 B
Ruby
Executable file
#!/usr/bin/env ruby
|
|
|
|
require 'open-uri'
|
|
require 'digest/sha2'
|
|
require 'tempfile'
|
|
|
|
raise "Usage: #{$0} NEW_VERSION" unless ARGV.size == 1
|
|
new_version = ARGV[0]
|
|
|
|
major_minor = new_version.split('.')[0..1].join('.')
|
|
|
|
url = "https://github.com/openssl/openssl/releases/download/openssl-#{new_version}/openssl-#{new_version}.tar.gz"
|
|
sha = nil
|
|
|
|
Tempfile.create(['openssl', '.tar.gz']) do |tmpfile|
|
|
URI.open(url) do |remote_file|
|
|
IO.copy_stream(remote_file, tmpfile)
|
|
end
|
|
tmpfile.rewind
|
|
|
|
sha = Digest::SHA256.file(tmpfile.path).hexdigest
|
|
end
|
|
|
|
Dir.glob('share/ruby-build/*') do |file|
|
|
contents = File.read(file)
|
|
|
|
openssl_package = "\"openssl-#{major_minor}"
|
|
|
|
next unless contents.include? openssl_package
|
|
|
|
lines = contents.lines
|
|
line = lines.find { |line| line.include? openssl_package }
|
|
old_version = line[/"openssl-([\d.]+[a-z]?)"/, 1] or raise
|
|
line.gsub!(old_version, new_version)
|
|
line.sub!(/\.tar\.gz#(\h+)"/, ".tar.gz##{sha}\"")
|
|
File.write(file, lines.join)
|
|
end
|