From 2cbe364c3cb0f6e213c87f582c7fb7e3bf9bf57e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Nov 2020 09:33:10 +0000 Subject: [PATCH] macho: require `codesign!` call to be done explicitly. As explained in https://github.com/Homebrew/brew/pull/9040#issuecomment-723888003 I think it's more desirable to have the `codesign!` calls happen inside Homebrew/brew instead of inside `macho/tools` methods. This makes it easier for Homebrew to turn this functionality on/off, change what platforms are affected, etc. without needing to tag and vendor a new release each time. --- lib/macho.rb | 3 +-- lib/macho/tools.rb | 12 ------------ 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/lib/macho.rb b/lib/macho.rb index 20f413fca..f0e6d33b5 100644 --- a/lib/macho.rb +++ b/lib/macho.rb @@ -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", diff --git a/lib/macho/tools.rb b/lib/macho/tools.rb index 00c80ef1c..2bb05fdd6 100644 --- a/lib/macho/tools.rb +++ b/lib/macho/tools.rb @@ -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, @@ -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 @@ -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. @@ -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 @@ -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. @@ -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