From e8c22d746b775a11a79ad304c6221f50b12bcc99 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 23 Dec 2014 14:14:27 +0000 Subject: [PATCH] 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 --- tool/extlibs.rb | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tool/extlibs.rb b/tool/extlibs.rb index 116964c2af..aab08d0372 100755 --- a/tool/extlibs.rb +++ b/tool/extlibs.rb @@ -38,7 +38,30 @@ def do_extract(cache, dir) $stdout.puts "extracting #{cache} into #{dir}" $stdout.flush 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}" end