summaryrefslogtreecommitdiff
path: root/tool/rbinstall.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-16 04:48:56 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-16 04:48:56 +0000
commitd0cf23b57eae01a21e10658b8272b498117d3913 (patch)
tree74b34d7da985db971f7e2223aedbe67e0f228ffb /tool/rbinstall.rb
parent51e7d0efb2ee98b1d963a32961904aee98437017 (diff)
rbinstall.rb: install unpacked gems
* tool/rbinstall.rb (gem): install gems from unpacked directories for platforms where zlib is not available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/rbinstall.rb')
-rwxr-xr-xtool/rbinstall.rb44
1 files changed, 43 insertions, 1 deletions
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
index 159144c..c60e4ad 100755
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -275,6 +275,12 @@ def with_destdir(dir)
$destdir + dir
end
+def without_destdir(dir)
+ return dir if !$destdir or $destdir.empty? or !dir.start_with?($destdir)
+ dir = dir.sub(/\A\w:/, '') if File::PATH_SEPARATOR == ';'
+ dir[$destdir.size..-1]
+end
+
def prepare(mesg, basedir, subdirs=nil)
return unless basedir
case
@@ -649,6 +655,27 @@ end
end
end
end
+
+ class UnpackedInstaller < Gem::Installer
+ module DirPackage
+ def extract_files(destination_dir, pattern = "*")
+ path = File.dirname(@gem.path)
+ return if path == destination_dir
+ install_recursive(path, without_destdir(destination_dir),
+ :glob => pattern,
+ :no_install => "*.gemspec",
+ :mode => $data_mode)
+ end
+ end
+
+ def initialize(spec, *options)
+ super(spec.loaded_from, *options)
+ @package.extend(DirPackage).spec = spec
+ end
+
+ def write_cache_file
+ end
+ end
end
# :startdoc:
@@ -711,10 +738,25 @@ install?(:ext, :comm, :gem) do
directories = Gem.ensure_gem_subdirectories(gem_dir, :mode => $dir_mode)
prepare "bundle gems", gem_dir, directories
install_dir = with_destdir(gem_dir)
+ installed_gems = {}
begin
require "zlib"
rescue LoadError
+ $" << "zlib.rb"
+ end
+ Gem::Specification.each_spec([srcdir+'/gems/*']) do |spec|
+ ins = RbInstall::UnpackedInstaller.new(spec,
+ :install_dir => install_dir,
+ :ignore_dependencies => true)
+ puts "#{" "*30}#{spec.name} #{spec.version}"
+ ins.install
+ installed_gems[spec.full_name] = true
+ end
+ installed_gems, gems = Dir.glob(srcdir+'/gems/*.gem').partition {|gem| installed_gems.key?(File.basename(gem, '.gem'))}
+ unless installed_gems.empty?
+ install installed_gems, gem_dir+"/cache"
end
+ next if gems.empty?
if defined?(Zlib)
options = {
:install_dir => install_dir,
@@ -724,7 +766,7 @@ install?(:ext, :comm, :gem) do
:data_mode => $data_mode,
:prog_mode => $prog_mode,
}
- Dir.glob(srcdir+'/gems/*.gem').each do |gem|
+ gems.each do |gem|
Gem.install(gem, Gem::Requirement.default, options)
gemname = File.basename(gem)
puts "#{" "*30}#{gemname}"