diff --git a/rubygems/ChangeLog b/rubygems/ChangeLog index bed83bc9..a9294349 100644 --- a/rubygems/ChangeLog +++ b/rubygems/ChangeLog @@ -1,3 +1,8 @@ +2004-06-08 Gavin Sinclair + * lib/rubygems/installer.rb: don't warn about not being able to + install a library stub if a library stub is already installed. + Still warn if it's not a library stub that's there already. + 2004-06-08 Gavin Sinclair * bin/gem: renamed --upgrade-dist to --upgrade--all and fixed bug. * lib/rubygems/installer.rb: fixed bug with Ruby version assertion. diff --git a/rubygems/lib/rubygems/installer.rb b/rubygems/lib/rubygems/installer.rb index 16eae373..a9507666 100644 --- a/rubygems/lib/rubygems/installer.rb +++ b/rubygems/lib/rubygems/installer.rb @@ -159,10 +159,12 @@ def generate_library_stubs(spec) sitelibdir = Config::CONFIG['sitelibdir'] if FileTest.writable?(sitelibdir) target_file = File.join(sitelibdir, "#{spec.autorequire}.rb") - if FileTest.exist?(target_file) - STDERR.puts "(WARN) Library file '#{target_file}'" - STDERR.puts " already exists; not overwriting. If you want to force a" - STDERR.puts " library stub, delete the file and reinstall." + if FileTest.exist?(target_file) + unless library_stub?(target_file) + STDERR.puts "(WARN) Library file '#{target_file}'" + STDERR.puts " already exists; not overwriting. If you want to force a" + STDERR.puts " library stub, delete the file and reinstall." + end else # Create #{autorequire}.rb in #{target_dir}. unless File.exist? File.dirname(target_file) @@ -199,6 +201,17 @@ def library_stub_text(name, file_name) TEXT text end + + ## + # Returns true iff the given filename contains a library stub. (Best guess!) + # + def library_stub?(filename) + lines = File.read(filename) + lines.grep(/^# This file was generated by RubyGems/) and + lines.grep(/is installed as part of a gem, and/) and + lines.grep(/^#/).size == 7 and + lines.size == 11 + end def build_extensions(directory, spec) return unless spec.extensions.size > 0