Skip to content

Commit

Permalink
Merge pull request #287 from MikeMcQuaid/codesign-tweaks
Browse files Browse the repository at this point in the history
macho: require `codesign!` call to be done explicitly.
  • Loading branch information
MikeMcQuaid authored Nov 10, 2020
2 parents b93877d + 2cbe364 commit d6b492e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
3 changes: 1 addition & 2 deletions lib/macho.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ def self.open(filename)
# @return [void]
# @raise [ModificationError] if the operation fails
def self.codesign!(filename)
# codesign binary is not available on Linux
return if RUBY_PLATFORM !~ /darwin/
raise ArgumentError, "codesign binary is not available on Linux" if RUBY_PLATFORM !~ /darwin/
raise ArgumentError, "#{filename}: no such file" unless File.file?(filename)

_, _, status = Open3.capture3("codesign", "--sign", "-", "--force",
Expand Down
12 changes: 0 additions & 12 deletions lib/macho/tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ def self.change_dylib_id(filename, new_id, options = {})

file.change_dylib_id(new_id, options)
file.write!

MachO.codesign!(filename)
end

# Changes a shared library install name in a Mach-O or Fat binary,
Expand All @@ -43,8 +41,6 @@ def self.change_install_name(filename, old_name, new_name, options = {})

file.change_install_name(old_name, new_name, options)
file.write!

MachO.codesign!(filename)
end

# Changes a runtime path in a Mach-O or Fat binary, overwriting the source
Expand All @@ -61,8 +57,6 @@ def self.change_rpath(filename, old_path, new_path, options = {})

file.change_rpath(old_path, new_path, options)
file.write!

MachO.codesign!(filename)
end

# Add a runtime path to a Mach-O or Fat binary, overwriting the source file.
Expand All @@ -77,8 +71,6 @@ def self.add_rpath(filename, new_path, options = {})

file.add_rpath(new_path, options)
file.write!

MachO.codesign!(filename)
end

# Delete a runtime path from a Mach-O or Fat binary, overwriting the source
Expand All @@ -94,8 +86,6 @@ def self.delete_rpath(filename, old_path, options = {})

file.delete_rpath(old_path, options)
file.write!

MachO.codesign!(filename)
end

# Merge multiple Mach-Os into one universal (Fat) binary.
Expand All @@ -116,8 +106,6 @@ def self.merge_machos(filename, *files, fat64: false)

fat_macho = MachO::FatFile.new_from_machos(*machos, :fat64 => fat64)
fat_macho.write(filename)

MachO.codesign!(filename)
end
end
end

0 comments on commit d6b492e

Please sign in to comment.