[rubygems/rubygems] Extend the script to allow reverting the patch when tried locally

https://github.com/rubygems/rubygems/commit/00ebf8c9f7
This commit is contained in:
David Rodríguez 2020-07-12 12:35:57 +02:00 committed by Hiroshi SHIBATA
parent 69881a41f2
commit 1b2bda72fc
Notes: git 2020-07-31 21:08:12 +09:00

View File

@ -3,19 +3,53 @@
require "rbconfig" require "rbconfig"
require "fileutils" require "fileutils"
class OpensslSimulator
attr_reader :openssl_rb, :openssl_gemspec, :openssl_ext
def initialize
archdir = RbConfig::CONFIG["archdir"] archdir = RbConfig::CONFIG["archdir"]
rubylibdir = RbConfig::CONFIG["rubylibdir"] rubylibdir = RbConfig::CONFIG["rubylibdir"]
default_specifications_dir = Gem.default_specifications_dir default_specifications_dir = Gem.default_specifications_dir
openssl_rb = File.join(rubylibdir, "openssl.rb") @openssl_rb = File.join(rubylibdir, "openssl.rb")
openssl_gemspec = Dir.glob("#{default_specifications_dir}/openssl-*.gemspec").first @openssl_gemspec = Dir.glob("#{default_specifications_dir}/openssl-*.gemspec").first
openssl_ext = if RUBY_PLATFORM == "java" @openssl_ext = if RUBY_PLATFORM == "java"
File.join(rubylibdir, "jopenssl.jar") File.join(rubylibdir, "jopenssl.jar")
else else
File.join(archdir, "openssl.so") File.join(archdir, "openssl.so")
end end
end
FileUtils.mv openssl_rb, openssl_rb + "_" def hide_openssl
FileUtils.mv openssl_ext, openssl_ext + "_" hide_file openssl_rb
FileUtils.mv openssl_gemspec, openssl_gemspec + "_" if openssl_gemspec hide_file openssl_ext
hide_file openssl_gemspec if openssl_gemspec
end
def unhide_openssl
unhide_file openssl_gemspec if openssl_gemspec
unhide_file openssl_ext
unhide_file openssl_rb
end
private
def hide_file(file)
FileUtils.mv file, file + "_"
end
def unhide_file(file)
FileUtils.mv file + "_", file
end
end
if $0 == __FILE__
openssl_simulate = OpensslSimulator.new
if ARGV[0] == "--revert"
openssl_simulate.unhide_openssl
else
openssl_simulate.hide_openssl
end
end