diff options
-rw-r--r-- | lib/rubygems/installer.rb | 6 | ||||
-rw-r--r-- | lib/rubygems/package.rb | 24 | ||||
-rw-r--r-- | lib/rubygems/package/tar_header.rb | 38 |
3 files changed, 37 insertions, 31 deletions
@@ -224,11 +224,11 @@ class Gem::Installer File.open generated_bin, "rb" do |io| line = io.gets - shebang = /^#!.*ruby/ # TruffleRuby uses a bash prelude in default launchers if load_relative_enabled? || RUBY_ENGINE == "truffleruby" - until line.nil? || line =~ shebang do line = io.gets end end @@ -239,7 +239,7 @@ class Gem::Installer # TODO: detect a specially formatted comment instead of trying # to find a string inside Ruby code. - next unless io.gets.to_s.include?("This file was generated by RubyGems") ruby_executable = true existing = io.read.slice(/ @@ -357,18 +357,21 @@ EOM def digest(entry) # :nodoc: algorithms = if @checksums - @checksums.keys - else - [Gem::Security::DIGEST_NAME].compact end - algorithms.each do |algorithm| - digester = Gem::Security.create_digest(algorithm) - - digester << entry.readpartial(16_384) until entry.eof? - entry.rewind @digests[algorithm][entry.full_name] = digester end @@ -437,8 +440,6 @@ EOM FileUtils.rm_rf destination - mkdir_options = {} - mkdir_options[:mode] = dir_mode ? 0o755 : (entry.header.mode if entry.directory?) mkdir = if entry.directory? destination @@ -447,7 +448,7 @@ EOM end unless directories.include?(mkdir) - FileUtils.mkdir_p mkdir, **mkdir_options directories << mkdir end @@ -707,6 +708,7 @@ EOM def verify_gz(entry) # :nodoc: Zlib::GzipReader.wrap entry do |gzio| gzio.read 16_384 until gzio.eof? # gzip checksum verification end rescue Zlib::GzipFile::Error => e @@ -127,7 +127,8 @@ class Gem::Package::TarHeader end def self.strict_oct(str) - return str.strip.oct if /\A[0-7]*\z/.match?(str.strip) raise ArgumentError, "#{str.inspect} is not an octal string" end @@ -137,7 +138,8 @@ class Gem::Package::TarHeader # \ff flags a negative 256-based number # In case we have a match, parse it as a signed binary value # in big-endian order, except that the high-order bit is ignored. - return str.unpack("N2").last if /\A[\x80\xff]/n.match?(str) strict_oct(str) end @@ -149,21 +151,23 @@ class Gem::Package::TarHeader raise ArgumentError, ":name, :size, :prefix and :mode required" end - vals[:uid] ||= 0 - vals[:gid] ||= 0 - vals[:mtime] ||= 0 - vals[:checksum] ||= "" - vals[:typeflag] = "0" if vals[:typeflag].nil? || vals[:typeflag].empty? - vals[:magic] ||= "ustar" - vals[:version] ||= "00" - vals[:uname] ||= "wheel" - vals[:gname] ||= "wheel" - vals[:devmajor] ||= 0 - vals[:devminor] ||= 0 - - FIELDS.each do |name| - instance_variable_set "@#{name}", vals[name] - end @empty = vals[:empty] end |