Class: AbstractFileDownloadStrategy

Inherits:
AbstractDownloadStrategy show all
Defined in:
Library/Homebrew/download_strategy.rb

Instance Attribute Summary

Attributes inherited from AbstractDownloadStrategy

#cached_location, #meta, #name, #resource, #shutup, #version

Instance Method Summary collapse

Methods inherited from AbstractDownloadStrategy

#clear_cache, #expand_safe_system_args, #fetch, #initialize, #ohai, #puts, #quiet_safe_system, #safe_system, #shutup!, #source_modified_time

Methods included from FileUtils

#make, mkdir, mktemp, #old_mkdir, #old_ruby, #ruby, #scons, #xcodebuild

Constructor Details

This class inherits a constructor from AbstractDownloadStrategy

Instance Method Details

#stageObject



217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'Library/Homebrew/download_strategy.rb', line 217

def stage
  case type = cached_location.compression_type
  when :zip
    quiet_safe_system "unzip", "-qq", cached_location
    chdir
  when :gzip_only
    buffered_write "gunzip"
  when :bzip2_only
    buffered_write "bunzip2"
  when :gzip, :bzip2, :xz, :compress, :tar
    tar_flags = "x"
    if type == :gzip
      tar_flags << "z"
    elsif type == :bzip2
      tar_flags << "j"
    elsif type == :xz
      tar_flags << "J"
    end
    tar_flags << "f"
    if type == :xz && DependencyCollector.tar_needs_xz_dependency?
      pipe_to_tar xzpath
    else
      safe_system "tar", tar_flags, cached_location
    end
    chdir
  when :lzip
    pipe_to_tar lzippath
    chdir
  when :lha
    safe_system lhapath, "x", cached_location
  when :xar
    safe_system "/usr/bin/xar", "-xf", cached_location
  when :rar
    quiet_safe_system "unrar", "x", "-inul", cached_location
  when :p7zip
    safe_system "7zr", "x", cached_location
  else
    cp cached_location, basename_without_params, preserve: true
  end
end