Skip to content

Commit

Permalink
Also check and uninstall old platform name when uninstalling.
Browse files Browse the repository at this point in the history
Remove existing rdoc and ri directory so regenerating docs succeeds even if
previously interrupted.



git-svn-id: http://rubygems.rubyforge.org/svn/trunk@1434 3d4018f9-ac1a-0410-99e9-8a154d859a19
  • Loading branch information
drbrain committed Oct 5, 2007
1 parent 2a5a5ed commit b590b90
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 10 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
@@ -1,3 +1,10 @@
2007-10-04 Eric Hodel <drbrain@segment7.net>

* lib/rubygems/uninstaller.rb: Also check and uninstall old platform
name to ensure legacy platform gems are uninstalled.
* lib/rubygems/doc_manager.rb: Remove existing rdoc and ri directory
so regenerating docs succeeds even if previously interrupted.

2007-10-02 Eric Hodel <drbrain@segment7.net>

* lib/rubygems/source_index.rb: Make #outdated search only for gems
Expand Down
29 changes: 25 additions & 4 deletions lib/rubygems/doc_manager.rb
Expand Up @@ -73,13 +73,21 @@ def load_rdoc
end

def install_rdoc
rdoc_dir = File.join @doc_dir, 'rdoc'

FileUtils.rm_rf rdoc_dir

say "Installing RDoc documentation for #{@spec.full_name}..."
run_rdoc '--op', File.join(@doc_dir, 'rdoc')
run_rdoc '--op', rdoc_dir
end

def install_ri
ri_dir = File.join @doc_dir, 'ri'

FileUtils.rm_rf ri_dir

say "Installing ri documentation for #{@spec.full_name}..."
run_rdoc '--ri', '--op', File.join(@doc_dir, 'ri')
run_rdoc '--ri', '--op', ri_dir
end

def run_rdoc(*args)
Expand Down Expand Up @@ -115,9 +123,22 @@ def uninstall_doc
raise Gem::FilePermissionError.new(@spec.installation_path) unless
File.writable? @spec.installation_path

doc_dir = File.join(@spec.installation_path, "doc", @spec.full_name)
original_name = [
@spec.name, @spec.version, @spec.original_platform].join '-'

doc_dir = File.join @spec.installation_path, 'doc', @spec.full_name
unless File.directory? doc_dir then
doc_dir = File.join @spec.installation_path, 'doc', original_name
end

FileUtils.rm_rf doc_dir
ri_dir = File.join(@spec.installation_path, "ri", @spec.full_name)

ri_dir = File.join @spec.installation_path, 'ri', @spec.full_name

unless File.directory? ri_dir then
ri_dir = File.join @spec.installation_path, 'ri', original_name
end

FileUtils.rm_rf ri_dir
end

Expand Down
10 changes: 9 additions & 1 deletion lib/rubygems/specification.rb
Expand Up @@ -34,6 +34,9 @@ module Gem
#
class Specification

# Allows deinstallation of gems with legacy platforms.
attr_accessor :original_platform # :nodoc:

# ------------------------- Specification version contstants.

# The the version number of a specification that does not specify one
Expand Down Expand Up @@ -349,6 +352,8 @@ def test_suite_file=(val)
end

overwrite_accessor :platform= do |platform|
@original_platform = platform

case platform
when Platform::CURRENT then
@platform = Gem::Platform.local
Expand Down Expand Up @@ -620,7 +625,10 @@ def full_name
# return:: [String] the full gem path
#
def full_gem_path
File.join(installation_path, "gems", full_name)
path = File.join installation_path, 'gems', full_name
return path if File.directory? path
File.join installation_path, 'gems',
"#{name}-#{version}-#{@original_platform}"
end

# The default (generated) file name of the gem.
Expand Down
27 changes: 22 additions & 5 deletions lib/rubygems/uninstaller.rb
Expand Up @@ -36,6 +36,7 @@ def initialize(gem, options)
#
def uninstall
list = Gem.source_index.search(/^#{@gem}$/, @version)

if list.empty? then
raise Gem::InstallError, "Unknown gem #{@gem}-#{@version}"
elsif list.size > 1 && @force_all
Expand Down Expand Up @@ -127,15 +128,31 @@ def remove(spec, list)
File.writable?(spec.installation_path)

FileUtils.rm_rf spec.full_gem_path
FileUtils.rm_rf File.join(spec.installation_path, 'specifications',
"#{spec.full_name}.gemspec")

FileUtils.rm_rf File.join(spec.installation_path, 'cache',
"#{spec.full_name}.gem")
original_platform_name = [
spec.name, spec.version, spec.original_platform].join '-'

spec_dir = File.join spec.installation_path, 'specifications'
gemspec = File.join spec_dir, "#{spec.full_name}.gemspec"

unless File.exist? gemspec then
gemspec = File.join spec_dir, "#{original_platform_name}.gemspec"
end

FileUtils.rm_rf gemspec

cache_dir = File.join spec.installation_path, 'cache'
gem = File.join cache_dir, "#{spec.full_name}.gem"

unless File.exist? gemspec then
gem = File.join cache_dir, "#{original_platform_name}.gem"
end

FileUtils.rm_rf gem

Gem::DocManager.new(spec).uninstall_doc

say "Successfully uninstalled #{spec.name} version #{spec.version}"
say "Successfully uninstalled #{spec.full_name}"

list.delete spec
end
Expand Down

0 comments on commit b590b90

Please sign in to comment.