Skip to content

Commit

Permalink
Merge pull request #988 from chef/improve_mac_logging
Browse files Browse the repository at this point in the history
Avoid double logging removal of non-mach-o libs
  • Loading branch information
tas50 committed Jan 19, 2022
2 parents 2bf77bb + d8aef34 commit e4d23a2
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions lib/omnibus/packagers/pkg.rb
Expand Up @@ -431,23 +431,21 @@ def sign_binary(bin, hardened_runtime = false)
end

def is_binary?(bin)
is_binary = File.file?(bin) &&
File.executable?(bin) &&
!File.symlink?(bin)
log.debug(log_key) { " removing non-binary file from signing: #{bin}" } unless is_binary
is_binary
return false unless File.file?(bin) && File.executable?(bin) && !File.symlink?(bin)

log.debug(log_key) { " skipping non-binary file from signing: #{bin}" }
true
end

def is_macho?(lib)
is_macho = false
if is_binary?(lib)
command = "file #{lib}"
return false unless File.file?(bin) && File.executable?(bin) && !File.symlink?(bin)

stdout = shellout!(command).stdout
is_macho = stdout.match?(/Mach-O.*(library|bundle)/)
if shellout!("file #{lib}").stdout.match?(/Mach-O.*(library|bundle)/) # https://rubular.com/r/nRgaQlAbkM9wHL
log.debug(log_key) { " skipping non-Mach-O library file from signing: #{lib}" }
return true
end
log.debug(log_key) { " removing non-Mach-O library file from signing: #{lib}" } unless is_macho
is_macho

false
end
end
end

0 comments on commit e4d23a2

Please sign in to comment.