extend/os/mac: ensure writable file for codesign
This commit is contained in:
parent
77311e4045
commit
5a4840dbc8
@ -31,6 +31,7 @@ class Keg
|
|||||||
return unless Hardware::CPU.arm?
|
return unless Hardware::CPU.arm?
|
||||||
|
|
||||||
odebug "Codesigning #{file}"
|
odebug "Codesigning #{file}"
|
||||||
|
prepare_codesign_writable_files(file) do
|
||||||
# Use quiet_system to squash notifications about resigning binaries
|
# Use quiet_system to squash notifications about resigning binaries
|
||||||
# which already have valid signatures.
|
# which already have valid signatures.
|
||||||
return if quiet_system("codesign", "--sign", "-", "--force",
|
return if quiet_system("codesign", "--sign", "-", "--force",
|
||||||
@ -62,6 +63,28 @@ class Keg
|
|||||||
#{result.stderr}
|
#{result.stderr}
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def prepare_codesign_writable_files(file)
|
||||||
|
result = system_command("codesign", args: [
|
||||||
|
"--display", "--file-list", "-", file
|
||||||
|
], print_stderr: false)
|
||||||
|
return unless result.success?
|
||||||
|
|
||||||
|
files = result.stdout.lines.map { |f| Pathname(f.chomp) }
|
||||||
|
saved_perms = {}
|
||||||
|
files.each do |f|
|
||||||
|
unless f.writable_real?
|
||||||
|
saved_perms[f] = f.stat.mode
|
||||||
|
FileUtils.chmod "u+rw", f.to_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
saved_perms&.each do |f, p|
|
||||||
|
f.chmod p if p
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def prepare_debug_symbols
|
def prepare_debug_symbols
|
||||||
binary_executable_or_library_files.each do |file|
|
binary_executable_or_library_files.each do |file|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user