in lib/omnibus/fetchers/net_fetcher.rb [238:276]
def extract
compression_switch = ""
compression_switch = "z" if downloaded_file.end_with?("gz")
compression_switch = "--lzma -" if downloaded_file.end_with?("lzma")
compression_switch = "j" if downloaded_file.end_with?("bz2")
compression_switch = "J" if downloaded_file.end_with?("xz")
if Ohai["platform"] == "windows"
if downloaded_file.end_with?(*TAR_EXTENSIONS) && source[:extract] != :seven_zip
returns = [0]
returns << 1 if source[:extract] == :lax_tar
shellout!("tar #{compression_switch}xf #{downloaded_file} --force-local -C#{project_dir}", returns: returns)
elsif downloaded_file.end_with?(*COMPRESSED_TAR_EXTENSIONS)
Dir.mktmpdir do |temp_dir|
log.debug(log_key) { "Temporarily extracting `#{safe_downloaded_file}' to `#{temp_dir}'" }
shellout!("7z.exe x #{safe_downloaded_file} -o#{windows_safe_path(temp_dir)} -r -y")
fname = File.basename(downloaded_file, File.extname(downloaded_file))
fname << ".tar" if downloaded_file.end_with?("tgz", "txz")
next_file = windows_safe_path(File.join(temp_dir, fname))
log.debug(log_key) { "Temporarily extracting `#{next_file}' to `#{safe_project_dir}'" }
shellout!("7z.exe x #{next_file} -o#{safe_project_dir} -r -y")
end
else
shellout!("7z.exe x #{safe_downloaded_file} -o#{safe_project_dir} -r -y")
end
elsif downloaded_file.end_with?(".7z")
shellout!("7z x #{safe_downloaded_file} -o#{safe_project_dir} -r -y")
elsif downloaded_file.end_with?(".zip")
shellout!("unzip #{safe_downloaded_file} -d #{safe_project_dir}")
else
shellout!("#{tar} #{compression_switch}xf #{safe_downloaded_file} -C#{safe_project_dir}")
end
end