[Rubygems-developers] RubyGems 0.9.0 introduces bug for installing source Gems

Tilman Sauerbeck tilman at code-monkey.de
Sun Jul 9 13:53:00 EDT 2006


Lyle Johnson [2006-07-09 08:47]:
> On 7/9/06, Tilman Sauerbeck <tilman at code-monkey.de> wrote:
> 
> > Blame me.
> 
> I wasn't looking to assign blame. ;)
> 
> I just wanted to get it out there so that the problem can be addressed
> in the next release of RubyGems. The stuff related to source gems
> doesn't seem to get exercised as much as the stuff for "pure Ruby"
> gems, and so problems like this one are easy to overlook.

Damn! I posted my final extension-stuff patch for Rubygems in
20050925081121.GA5808 at code-monkey.de, but it seems that Chad applied a
patch that I posted earlier.
I assumed he committed the right one, but didn't verify :(

Here's a patch that contains the bits that have been missed back then.
I also backed out the "clean" chunk for ExtConfBuilder.
I only tested it briefly, I haven't looked at this code in months and
I'm not sure it's 100% correct.

See the mail I referenced above for comments on these changes.

I'm sorry for the inconvience :(

Regards,
Tilman

-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
-------------- next part --------------
Only in rubygems-0.9.0/lib/rubygems: .installer.rb.swp
diff -aur rubygems-0.9.0.orig/lib/rubygems/installer.rb rubygems-0.9.0/lib/rubygems/installer.rb
--- rubygems-0.9.0.orig/lib/rubygems/installer.rb	2006-06-07 05:39:54.000000000 +0200
+++ rubygems-0.9.0/lib/rubygems/installer.rb	2006-07-09 19:48:23.000000000 +0200
@@ -292,9 +292,12 @@
       say "Building native extensions.  This could take a while..."
       start_dir = Dir.pwd
       dest_path = File.join(directory, spec.require_paths[0])
+      ran_rake = false # only run rake once
 
-      results = []
       spec.extensions.each do |extension|
+        break if ran_rake
+        results = []
+
         case extension
         when /extconf/ then
           builder = ExtExtConfBuilder
@@ -302,6 +305,7 @@
           builder = ExtConfigureBuilder
         when /rakefile/i then
           builder = ExtRakeBuilder
+          ran_rake = true
         else
           builder = nil
           results = ["No builder for extension '#{extension}'"]
@@ -310,7 +314,7 @@
         begin
           err = false
           Dir.chdir File.join(directory, File.dirname(extension))
-          results = builder.build(extension, directory, dest_path)
+          results = builder.build(extension, directory, dest_path, results)
         rescue => ex
           err = true
         end
@@ -551,29 +555,27 @@
   end  # class Uninstaller
 
   class ExtConfigureBuilder
-    def self.build(extension, directory, dest_path)
-      results = []
+    def self.build(extension, directory, dest_path, results)
       unless File.exist?('Makefile') then
         cmd = "sh ./configure --prefix=#{dest_path}"
         results << cmd
         results << `#{cmd}`
       end
 
-      results.push(*ExtExtConfBuilder.make(dest_path))
+      ExtExtConfBuilder.make(dest_path, results)
       results
     end
   end
 
   class ExtExtConfBuilder
-    def self.build(extension, directory, dest_path)
-      results = ["#{Gem.ruby} #{File.basename(extension)} #{ARGV.join(" ")}"]
+    def self.build(extension, directory, dest_path, results)
+      results << "#{Gem.ruby} #{File.basename(extension)} #{ARGV.join(" ")}"
       results << `#{Gem.ruby} #{File.basename(extension)} #{ARGV.join(" ")}`
-      results.push(*make(dest_path))
+      make(dest_path, results)
       results
     end
 
-    def self.make(dest_path)
-      results = []
+    def self.make(dest_path, results)
       raise unless File.exist?('Makefile')
       mf = File.read('Makefile')
       mf = mf.gsub(/^RUBYARCHDIR\s*=\s*\$[^$]*/, "RUBYARCHDIR = #{dest_path}")
@@ -585,27 +587,25 @@
         make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
       end
 
-      ['', 'install', 'clean'].each do |target|
+      ['', 'install'].each do |target|
         results << "#{make_program} #{target}".strip
         results << `#{make_program} #{target}`
-      end
 
-      results
+        raise unless $?.exitstatus.zero?
+      end
     end
 
   end
 
   class ExtRakeBuilder
-    def ExtRakeBuilder.build(ext, directory, dest_path)
+    def ExtRakeBuilder.build(ext, directory, dest_path, results)
       make_program = ENV['rake'] || 'rake'
       make_program += " RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}"
 
-      results = []
+      results << "#{make_program} extension".strip
+      results << `#{make_program} extension`
 
-      ['', 'install', 'clean'].each do |target|
-        results << "#{make_program} #{target}".strip
-        results << `#{make_program} #{target}`
-      end
+      raise unless $?.exitstatus.zero?
 
       results
     end
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/rubygems-developers/attachments/20060709/12559513/attachment.bin 


More information about the Rubygems-developers mailing list