Fix XzUnpackStrategy
.
This commit is contained in:
parent
633c590aac
commit
ec7e22e16f
@ -151,7 +151,7 @@ class CompressUnpackStrategy < TarUnpackStrategy
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class XzUnpackStrategy < TarUnpackStrategy
|
class XzUnpackStrategy < UnpackStrategy
|
||||||
def self.can_extract?(path:, magic_number:)
|
def self.can_extract?(path:, magic_number:)
|
||||||
magic_number.match?(/\A\xFD7zXZ\x00/n)
|
magic_number.match?(/\A\xFD7zXZ\x00/n)
|
||||||
end
|
end
|
||||||
@ -159,13 +159,23 @@ class XzUnpackStrategy < TarUnpackStrategy
|
|||||||
private
|
private
|
||||||
|
|
||||||
def extract_to_dir(unpack_dir, basename:)
|
def extract_to_dir(unpack_dir, basename:)
|
||||||
if DependencyCollector.tar_needs_xz_dependency?
|
|
||||||
unpack_path = unpack_dir/path.basename
|
unpack_path = unpack_dir/path.basename
|
||||||
FileUtils.cp path, unpack_path, preserve: true
|
FileUtils.cp path, unpack_path, preserve: true
|
||||||
|
|
||||||
safe_system Formula["xz"].opt_bin/"xz", "-d", "-q", "-T0", unpack_path
|
safe_system Formula["xz"].opt_bin/"xz", "-d", "-q", "-T0", unpack_path
|
||||||
else
|
|
||||||
super
|
extract_nested_tar(unpack_dir, basename: basename)
|
||||||
|
end
|
||||||
|
|
||||||
|
def extract_nested_tar(unpack_dir, basename:)
|
||||||
|
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
|
||||||
|
TarUnpackStrategy.new(tmpdir/tar.basename).extract(to: unpack_dir, basename: basename)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user