Move .tar.xz logic from Xz to Tar.
This commit is contained in:
parent
281ead3096
commit
f8dc9eff58
@ -30,7 +30,17 @@ module UnpackStrategy
|
||||
private
|
||||
|
||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||
system_command! "tar", args: ["xf", path, "-C", unpack_dir]
|
||||
Dir.mktmpdir do |tmpdir|
|
||||
tar_path = path
|
||||
|
||||
if DependencyCollector.tar_needs_xz_dependency? && Xz.can_extract?(path)
|
||||
tmpdir = Pathname(tmpdir)
|
||||
Xz.new(path).extract(to: tmpdir)
|
||||
tar_path = tmpdir.children.first
|
||||
end
|
||||
|
||||
system_command! "tar", args: ["xf", tar_path, "-C", unpack_dir]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -24,19 +24,6 @@ module UnpackStrategy
|
||||
system_command! "unxz",
|
||||
args: [*quiet_flags, "-T0", "--", unpack_dir/basename],
|
||||
env: { "PATH" => PATH.new(Formula["xz"].opt_bin, ENV["PATH"]) }
|
||||
extract_nested_tar(unpack_dir)
|
||||
end
|
||||
|
||||
def extract_nested_tar(unpack_dir)
|
||||
return unless DependencyCollector.tar_needs_xz_dependency?
|
||||
return if (children = unpack_dir.children).count != 1
|
||||
return if (tar = children.first).extname != ".tar"
|
||||
|
||||
Dir.mktmpdir do |tmpdir|
|
||||
tmpdir = Pathname(tmpdir)
|
||||
FileUtils.mv tar, tmpdir/tar.basename
|
||||
Tar.new(tmpdir/tar.basename).extract(to: unpack_dir)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user