Unzip Casks w/ extended attributes with ditto
Fixes Homebrew/homebrew-cask#61386
This commit is contained in:
parent
1337da0f89
commit
e09d4336a9
@ -13,20 +13,23 @@ module UnpackStrategy
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if contains_extended_attributes?(path)
|
||||||
|
# Merge ._ files back into extended attributes.
|
||||||
|
# We use ditto, because dot_clean has issues if the __MACOSX
|
||||||
|
# folder has incorrect permissions.
|
||||||
|
# (Also, Homebrew's ZIP artifact automatically deletes this folder.)
|
||||||
|
system_command! "ditto",
|
||||||
|
args: ["-x", "-k", path, unpack_dir],
|
||||||
|
verbose: verbose,
|
||||||
|
print_stderr: false
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
volumes = result.stderr.chomp
|
volumes = result.stderr.chomp
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.map { |l| l[/\A skipping: (.+) volume label\Z/, 1] }
|
.map { |l| l[/\A skipping: (.+) volume label\Z/, 1] }
|
||||||
.compact
|
.compact
|
||||||
|
|
||||||
if result.stderr.lines.any? { |line| line.start_with?("._") }
|
|
||||||
# Merge ._ files back into extended attributes.
|
|
||||||
# ._ files inside volumes are automatically merged by ditto.
|
|
||||||
system_command!("dot_clean",
|
|
||||||
args: ["-mv", "--keep=dotbar", unpack_dir],
|
|
||||||
verbose: verbose,
|
|
||||||
print_stderr: false)
|
|
||||||
end
|
|
||||||
|
|
||||||
return if volumes.empty?
|
return if volumes.empty?
|
||||||
|
|
||||||
Dir.mktmpdir do |tmp_unpack_dir|
|
Dir.mktmpdir do |tmp_unpack_dir|
|
||||||
|
|||||||
@ -14,6 +14,10 @@ module UnpackStrategy
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def contains_extended_attributes?(path)
|
||||||
|
path.zipinfo.grep(/(^__MACOSX|\._)/).any?
|
||||||
|
end
|
||||||
|
|
||||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||||
quiet_flags = verbose ? [] : ["-qq"]
|
quiet_flags = verbose ? [] : ["-qq"]
|
||||||
result = system_command! "unzip",
|
result = system_command! "unzip",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user