diff options
| author | Markus Reiter | 2017-03-28 15:34:34 +0200 |
|---|---|---|
| committer | Markus Reiter | 2017-03-28 15:34:34 +0200 |
| commit | 1be120f4c1d7f0be24ead200a6cb0925acc90129 (patch) | |
| tree | e86d0f95e1ead0eced381202dd0535cfc7a292f8 /Library | |
| parent | 676c4a9e33672cd6035ef9225f5d3f9e9d63f810 (diff) | |
| download | brew-1be120f4c1d7f0be24ead200a6cb0925acc90129.tar.bz2 | |
Add `Container::Executable`.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/container.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/container/executable.rb | 18 |
2 files changed, 20 insertions, 0 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/container.rb b/Library/Homebrew/cask/lib/hbc/container.rb index fc7246f3d..c6b2c3c37 100644 --- a/Library/Homebrew/cask/lib/hbc/container.rb +++ b/Library/Homebrew/cask/lib/hbc/container.rb @@ -4,6 +4,7 @@ require "hbc/container/bzip2" require "hbc/container/cab" require "hbc/container/criteria" require "hbc/container/dmg" +require "hbc/container/executable" require "hbc/container/generic_unar" require "hbc/container/gzip" require "hbc/container/lzma" @@ -39,6 +40,7 @@ module Hbc Gzip, # pure gzip Lzma, # pure lzma Xz, # pure xz + Executable, ] # for explicit use only (never autodetected): # Hbc::Container::Naked diff --git a/Library/Homebrew/cask/lib/hbc/container/executable.rb b/Library/Homebrew/cask/lib/hbc/container/executable.rb new file mode 100644 index 000000000..848f6d4be --- /dev/null +++ b/Library/Homebrew/cask/lib/hbc/container/executable.rb @@ -0,0 +1,18 @@ +require "hbc/container/naked" +require "vendor/macho/macho" + +module Hbc + class Container + class Executable < Naked + def self.me?(criteria) + return true if criteria.magic_number(/^#!\s*\S+/) + + begin + MachO.open(criteria.path).header.executable? + rescue MachO::MagicError + false + end + end + end + end +end |
