summaryrefslogtreecommitdiff
path: root/lib/rubygems
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2022-08-02 10:27:42 +0200
committergit <svn-admin@ruby-lang.org>2022-08-04 13:36:45 +0900
commit542040fb8375ffd74096ae0615a33bbc90524cb3 (patch)
tree2cea6b5f9c8275e766f95f9a2137fe78e4ee09cc /lib/rubygems
parent0591780a74f9893038d5d794a958621189953e8a (diff)
[rubygems/rubygems] Warn dangling symlinks
https://github.com/rubygems/rubygems/commit/425b78637f
Diffstat (limited to 'lib/rubygems')
-rw-r--r--lib/rubygems/installer.rb10
-rw-r--r--lib/rubygems/package.rb14
2 files changed, 13 insertions, 11 deletions
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 8ec75d1ff7..b764f21a4f 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -490,15 +490,7 @@ class Gem::Installer
spec.executables.each do |filename|
filename.tap(&Gem::UNTAINT)
bin_path = File.join gem_dir, spec.bindir, filename
-
- unless File.exist? bin_path
- if File.symlink? bin_path
- alert_warning "`#{bin_path}` is dangling symlink pointing to `#{File.readlink bin_path}`"
- else
- alert_warning "`#{bin_path}` does not exist, maybe `gem pristine #{spec.name}` will fix it?"
- end
- next
- end
+ next unless File.exist? bin_path
mode = File.stat(bin_path).mode
dir_mode = options[:prog_mode] || (mode | 0111)
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index 8d7aa01f6e..77f9f282d8 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -409,6 +409,8 @@ EOM
def extract_tar_gz(io, destination_dir, pattern = "*") # :nodoc:
directories = []
+ symlinks = []
+
open_tar_gz io do |tar|
tar.each do |entry|
full_name = entry.full_name
@@ -422,6 +424,8 @@ EOM
raise Gem::Package::SymlinkError.new(full_name, real_destination, destination_dir) unless
normalize_path(real_destination).start_with? normalize_path(destination_dir + "/")
+
+ symlinks << [full_name, link_target, destination, real_destination]
end
FileUtils.rm_rf destination
@@ -445,12 +449,18 @@ EOM
FileUtils.chmod file_mode(entry.header.mode), destination
end if entry.file?
- File.symlink(entry.header.linkname, destination) if entry.symlink?
-
verbose destination
end
end
+ symlinks.each do |name, target, destination, real_destination|
+ if File.exist?(real_destination)
+ File.symlink(target, destination)
+ else
+ alert_warning "#{@spec.full_name} ships with a dangling symlink named #{name} pointing to missing #{target} file. Ignoring"
+ end
+ end
+
if dir_mode
File.chmod(dir_mode, *directories)
end