Skip to content

Commit

Permalink
codesign in keg_relocate instead of keg methods
Browse files Browse the repository at this point in the history
Currently the codesign_patched_binary method may be called many
times for the same file when installing a keg.

This removes the calls to codesign_patched_binary from os/mac/keg
and adds a single call to the relocate_dynamic_linkage and
fix_dynamic_linkage methods in extend/os/mac/keg_relocate
to speed up keg installation.
  • Loading branch information
scpeters committed Sep 8, 2023
1 parent 704b97d commit 27d694e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Library/Homebrew/extend/os/mac/keg_relocate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def relocate_dynamic_linkage(relocation)
new_name = relocated_name_for(old_name, relocation)
change_rpath(old_name, new_name, file) if new_name
end

# codesign the file once after other steps
codesign_patched_binary(file)

Check warning on line 40 in Library/Homebrew/extend/os/mac/keg_relocate.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/mac/keg_relocate.rb#L40

Added line #L40 was not covered by tests
end
end
end
Expand Down Expand Up @@ -71,6 +74,9 @@ def fix_dynamic_linkage

delete_rpath(bad_name, file)
end

# codesign the file once after other steps
codesign_patched_binary(file)
end
end

Expand Down
4 changes: 0 additions & 4 deletions Library/Homebrew/os/mac/keg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def change_dylib_id(id, file)
@require_relocation = true
odebug "Changing dylib ID of #{file}\n from #{file.dylib_id}\n to #{id}"
file.change_dylib_id(id, strict: false)
codesign_patched_binary(file)
rescue MachO::MachOError
onoe <<~EOS
Failed changing dylib ID of #{file}
Expand All @@ -24,7 +23,6 @@ def change_install_name(old, new, file)
@require_relocation = true
odebug "Changing install name in #{file}\n from #{old}\n to #{new}"
file.change_install_name(old, new, strict: false)
codesign_patched_binary(file)
rescue MachO::MachOError
onoe <<~EOS
Failed changing install name in #{file}
Expand All @@ -40,7 +38,6 @@ def change_rpath(old, new, file)
@require_relocation = true
odebug "Changing rpath in #{file}\n from #{old}\n to #{new}"
file.change_rpath(old, new, strict: false)
codesign_patched_binary(file)
rescue MachO::MachOError
onoe <<~EOS
Failed changing rpath in #{file}
Expand All @@ -53,7 +50,6 @@ def change_rpath(old, new, file)
def delete_rpath(rpath, file)
odebug "Deleting rpath #{rpath} in #{file}"
file.delete_rpath(rpath, strict: false)
codesign_patched_binary(file)
rescue MachO::MachOError
onoe <<~EOS
Failed deleting rpath #{rpath} in #{file}
Expand Down

0 comments on commit 27d694e

Please sign in to comment.