Skip to content

Commit

Permalink
Extend the script to allow reverting the patch when tried locally
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Jul 19, 2020
1 parent a40d9a3 commit 00ebf8c
Showing 1 changed file with 50 additions and 16 deletions.
66 changes: 50 additions & 16 deletions util/remove_openssl.rb
Expand Up @@ -3,19 +3,53 @@
require "rbconfig"
require "fileutils"

archdir = RbConfig::CONFIG["archdir"]
rubylibdir = RbConfig::CONFIG["rubylibdir"]
default_specifications_dir = Gem.default_specifications_dir

openssl_rb = File.join(rubylibdir, "openssl.rb")
openssl_gemspec = Dir.glob("#{default_specifications_dir}/openssl-*.gemspec").first

openssl_ext = if RUBY_PLATFORM == "java"
File.join(rubylibdir, "jopenssl.jar")
else
File.join(archdir, "openssl.so")
end

FileUtils.mv openssl_rb, openssl_rb + "_"
FileUtils.mv openssl_ext, openssl_ext + "_"
FileUtils.mv openssl_gemspec, openssl_gemspec + "_" if openssl_gemspec
class OpensslSimulator
attr_reader :openssl_rb, :openssl_gemspec, :openssl_ext

def initialize
archdir = RbConfig::CONFIG["archdir"]
rubylibdir = RbConfig::CONFIG["rubylibdir"]
default_specifications_dir = Gem.default_specifications_dir

@openssl_rb = File.join(rubylibdir, "openssl.rb")
@openssl_gemspec = Dir.glob("#{default_specifications_dir}/openssl-*.gemspec").first

@openssl_ext = if RUBY_PLATFORM == "java"
File.join(rubylibdir, "jopenssl.jar")
else
File.join(archdir, "openssl.so")
end
end

def hide_openssl
hide_file openssl_rb
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

0 comments on commit 00ebf8c

Please sign in to comment.