Avoid shell quoting issues when extracting xz and lz archives
This commit is contained in:
parent
120bd43f87
commit
e0286c5aae
@ -174,10 +174,10 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy
|
|||||||
with_system_path { safe_system 'tar', 'xf', cached_location }
|
with_system_path { safe_system 'tar', 'xf', cached_location }
|
||||||
chdir
|
chdir
|
||||||
when :xz
|
when :xz
|
||||||
with_system_path { safe_system "#{xzpath} -dc \"#{cached_location}\" | tar xf -" }
|
with_system_path { pipe_to_tar(xzpath) }
|
||||||
chdir
|
chdir
|
||||||
when :lzip
|
when :lzip
|
||||||
with_system_path { safe_system "#{lzippath} -dc \"#{cached_location}\" | tar xf -" }
|
with_system_path { pipe_to_tar(lzippath) }
|
||||||
chdir
|
chdir
|
||||||
when :xar
|
when :xar
|
||||||
safe_system "/usr/bin/xar", "-xf", cached_location
|
safe_system "/usr/bin/xar", "-xf", cached_location
|
||||||
@ -200,6 +200,15 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def pipe_to_tar(tool)
|
||||||
|
Utils.popen_read(tool, "-dc", cached_location.to_s) do |rd|
|
||||||
|
Utils.popen_write("tar", "xf", "-") do |wr|
|
||||||
|
buf = ""
|
||||||
|
wr.write(buf) while rd.read(16384, buf)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# gunzip and bunzip2 write the output file in the same directory as the input
|
# gunzip and bunzip2 write the output file in the same directory as the input
|
||||||
# file regardless of the current working directory, so we need to write it to
|
# file regardless of the current working directory, so we need to write it to
|
||||||
# the correct location ourselves.
|
# the correct location ourselves.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user