Unzip Casks w/ extended attributes with ditto

Fixes Homebrew/homebrew-cask#61386
This commit is contained in:
L. E. Segovia 2019-04-08 22:54:33 +00:00
parent 1337da0f89
commit e09d4336a9
No known key found for this signature in database
GPG Key ID: D5D1DC48B52B7AD5
2 changed files with 16 additions and 9 deletions

View File

@ -13,20 +13,23 @@ module UnpackStrategy
return
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
.split("\n")
.map { |l| l[/\A skipping: (.+) volume label\Z/, 1] }
.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?
Dir.mktmpdir do |tmp_unpack_dir|

View File

@ -14,6 +14,10 @@ module UnpackStrategy
private
def contains_extended_attributes?(path)
path.zipinfo.grep(/(^__MACOSX|\._)/).any?
end
def extract_to_dir(unpack_dir, basename:, verbose:)
quiet_flags = verbose ? [] : ["-qq"]
result = system_command! "unzip",