#!/usr/bin/env ruby require 'open-uri' require 'pathname' require 'openssl' file = "http://rubinius-releases-rubinius-com.s3-us-west-2.amazonaws.com/index.txt" dir = Pathname(File.expand_path("share/ruby-build")) URI.open(file).each do |package| next if package.match(/sha512/) version = package.match(/rubinius-([345].[\d\.]+).tar.bz2/) next unless version version = version[1] defname = "rbx-#{version}" next if File.exist?(dir.join(defname)) package_url = "https://rubinius-releases-rubinius-com.s3.amazonaws.com/rubinius-#{version}.tar.bz2" sha256 = OpenSSL::Digest::SHA256.hexdigest(File.read(URI.open(package_url))) definition = <<-TEMPLATE require_llvm 3.7 install_package "openssl-1.0.2u" "https://www.openssl.org/source/openssl-1.0.2u.tar.gz#ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16" openssl --if needs_openssl_096_102 install_package "rubinius-#{version}" "#{package_url}##{sha256}" rbx TEMPLATE File.open(dir.join(defname), "w"){|f| f.write definition} end