summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-03 18:08:57 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-03 18:08:57 +0000
commite9ddb1a1f965d830ec26c808be9fcacacedf6844 (patch)
treeb8f26eba382fd409a84e01ab9aa7f84ea9f3a665
parent92f39045346c665b84761a031de4965f3fe9d270 (diff)
* tool/rbinstall.rb: use rubygems to load gemspecs, copy actual
gemspecs on install rather than generate fake ones for all gems. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rwxr-xr-xtool/rbinstall.rb72
2 files changed, 61 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 87292e6241..54a533ccbd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Aug 4 03:02:54 2011 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * tool/rbinstall.rb: use rubygems to load gemspecs, copy actual
+ gemspecs on install rather than generate fake ones for all gems.
+
Thu Aug 4 02:45:10 2011 Kenta Murata <mrkn@mrkn.jp>
* configure.in: set CXX variable to the C++ compiler that matches the
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
index 4c5904b349..3b5d6044bc 100755
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -532,6 +532,53 @@ install?(:local, :comm, :man) do
end
end
+# :stopdoc:
+module RbInstall
+ module Specs
+ class Reader < Struct.new(:name, :src, :execs)
+ def gemspec
+ @gemspec ||= begin
+ Gem::Specification.load(src) || raise("invalid spec in #{src}")
+ end
+ end
+
+ def spec_source
+ File.read src
+ end
+ end
+
+ class Generator < Struct.new(:name, :src, :execs)
+ def gemspec
+ @gemspec ||= eval spec_source
+ end
+
+ def spec_source
+ <<-GEMSPEC
+Gem::Specification.new do |s|
+ s.name = #{name.dump}
+ s.version = #{version.dump}
+ s.summary = "This #{name} is bundled with Ruby"
+ s.executables = #{execs.inspect}
+end
+ GEMSPEC
+ end
+
+ private
+ def version
+ version = open(src) { |f|
+ f.find { |s| /^\s*\w*VERSION\s*=(?!=)/ =~ s }
+ } or return
+ version.split(%r"=\s*", 2)[1].strip[/\A([\'\"])(.*?)\1/, 2]
+ end
+ end
+
+ def self.generator_for(file)
+ File.extname(file) == '.gemspec' ? Reader : Generator
+ end
+ end
+end
+# :startdoc:
+
install?(:ext, :comm, :gem) do
$:.unshift(File.join(srcdir, "lib"))
require("rubygems.rb")
@@ -550,29 +597,22 @@ install?(:ext, :comm, :gem) do
end
name, src, execs = *words
next unless name and src
- execs ||= []
- src = File.join(srcdir, src)
- version = open(src) {|f| f.find {|s| /^\s*\w*VERSION\s*=(?!=)/ =~ s}} or next
- version = version.split(%r"=\s*", 2)[1].strip[/\A([\'\"])(.*?)\1/, 2]
- full_name = "#{name}-#{version}"
- puts "#{" "*30}#{name} #{version}"
+ src = File.join(srcdir, src)
+ specgen = RbInstall::Specs.generator_for(src).new(name, src, execs || [])
+ gemspec = specgen.gemspec
+ full_name = "#{gemspec.name}-#{gemspec.version}"
+
+ puts "#{" "*30}#{gemspec.name} #{gemspec.version}"
open_for_install(File.join(spec_dir, "#{full_name}.gemspec"), $data_mode) do
- <<-GEMSPEC
-Gem::Specification.new do |s|
- s.name = #{name.dump}
- s.version = #{version.dump}
- s.summary = "This #{name} is bundled with Ruby"
- s.executables = #{execs.inspect}
-end
- GEMSPEC
+ specgen.spec_source
end
- unless execs.empty? then
+ unless gemspec.executables.empty? then
bin_dir = File.join(gem_dir, 'gems', full_name, 'bin')
makedirs(bin_dir)
- execs = execs.map {|exec| File.join(srcdir, 'bin', exec)}
+ execs = gemspec.executables.map {|exec| File.join(srcdir, 'bin', exec)}
install(execs, bin_dir, :mode => $prog_mode)
end
end