Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Container::Executable. #2410

Merged
merged 1 commit into from
Mar 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions Library/Homebrew/cask/lib/hbc/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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"
Expand Down Expand Up @@ -39,6 +40,7 @@ def self.autodetect_containers
Gzip, # pure gzip
Lzma, # pure lzma
Xz, # pure xz
Executable,
]
# for explicit use only (never autodetected):
# Hbc::Container::Naked
Expand Down
18 changes: 18 additions & 0 deletions Library/Homebrew/cask/lib/hbc/container/executable.rb
Original file line number Diff line number Diff line change
@@ -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