Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rhenium/4b08f402a00d316aa588f2a23f9c4916 to your computer and use it in GitHub Desktop.
Save rhenium/4b08f402a00d316aa588f2a23f9c4916 to your computer and use it in GitHub Desktop.
From e7c0f184530fa3f056ac2939793797fff9d5448e Mon Sep 17 00:00:00 2001
From: Kazuki Yamaguchi <k@rhe.jp>
Date: Wed, 26 Oct 2016 18:29:09 +0900
Subject: [PATCH] Add a rake task to install testing dependencies
Extracted from tool/ruby-openssl-docker/init.sh. Parse the dependency
gems from openssl.gemspec and install them.
---
Rakefile | 22 ++++++++++++++++++----
tool/ruby-openssl-docker/init.sh | 11 +----------
2 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/Rakefile b/Rakefile
index f3e7e3fae6a3..2f50c4700530 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,11 +1,14 @@
-gem 'rake-compiler'
-
require 'rake'
-require 'rake/extensiontask'
require 'rake/testtask'
require 'rdoc/task'
-Rake::ExtensionTask.new('openssl')
+begin
+ require 'rake/extensiontask'
+ Rake::ExtensionTask.new('openssl')
+rescue LoadError
+ warn "rake-compiler not installed. Run 'rake install_dependencies' to " \
+ "install testing dependency gems."
+end
Rake::TestTask.new do |t|
t.libs << 'test'
@@ -22,6 +25,17 @@ task :debug do
ruby "-I./lib -ropenssl -ve'puts OpenSSL::OPENSSL_VERSION, OpenSSL::OPENSSL_LIBRARY_VERSION'"
end
+task :install_dependencies do
+ if ENV["USE_HTTP_RUBYGEMS_ORG"] == "1"
+ Gem.sources.replace([Gem::Source.new("http://rubygems.org")])
+ end
+
+ gemspec = eval(File.read("openssl.gemspec"))
+ gemspec.development_dependencies.each do |dep|
+ Gem.install(dep.name, dep.requirement, force: true)
+ end
+end
+
namespace :sync do
task :from_ruby do
sh "./tool/sync-with-trunk"
diff --git a/tool/ruby-openssl-docker/init.sh b/tool/ruby-openssl-docker/init.sh
index 3fa271c48356..c4301482de48 100755
--- a/tool/ruby-openssl-docker/init.sh
+++ b/tool/ruby-openssl-docker/init.sh
@@ -15,15 +15,6 @@ export PATH="/opt/ruby/${RUBY_VERSION}/bin:$PATH"
export LD_LIBRARY_PATH="/opt/openssl/${OPENSSL_VERSION}/lib"
export PKG_CONFIG_PATH="/opt/openssl/${OPENSSL_VERSION}/lib/pkgconfig"
-ruby -e '
- newsource = Gem::Source.new("http://rubygems.org")
- Gem.sources.replace([newsource])
- Gem.configuration.write
-
- spec = eval(File.read("openssl.gemspec"))
- spec.development_dependencies.each do |dep|
- Gem.install(dep.name, dep.requirement, force: true)
- end
-'
+rake install_dependencies USE_HTTP_RUBYGEMS_ORG=1
exec $*
--
2.10.1.706.g8aa3d76.dirty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment