1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

extlibs.rb: separate commands

* tool/extlibs.rb (do_extract): separate expansion and extraction
  processes to each commands.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-12-23 14:14:27 +00:00
parent 840fa8086e
commit e8c22d746b

View file

@ -38,7 +38,30 @@ def do_extract(cache, dir)
$stdout.puts "extracting #{cache} into #{dir}" $stdout.puts "extracting #{cache} into #{dir}"
$stdout.flush $stdout.flush
end end
Process.wait(Process.spawn("tar", "xpf", "-", in: cache, chdir: dir)) ext = File.extname(cache)
case ext
when '.gz', '.tgz'
f = IO.popen(["gzip", "-c", cache])
cache = cache.chomp('.gz')
when '.bz2', '.tbz'
f = IO.popen(["bzip2", "-c", cache])
cache = cache.chomp('.bz2')
when '.xz', '.txz'
f = IO.popen(["xz", "-c", cache])
cache = cache.chomp('.xz')
else
inp = cache
end
inp ||= f
ext = File.extname(cache)
case ext
when '.tar', /\A\.t[gbx]z\z/
pid = Process.spawn("tar", "xpf", "-", in: inp, chdir: dir)
when '.zip'
pid = Process.spawn("unzip", inp, "-d", dir)
end
f.close if f
Process.wait(pid)
$?.success? or raise "failed to extract #{cache}" $?.success? or raise "failed to extract #{cache}"
end end