Created
November 17, 2013 08:42
-
-
Save 0xdevalias/7510924 to your computer and use it in GitHub Desktop.
Example of how to create/use a custom requirement for homebrew (in this case, checking the version of the installed ruby version) Note: Code isn't necessarily 100% complete/clean, but should give you the basic idea.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'formula' | |
require 'requirement' | |
class Ruby192EqualGreater < Requirement | |
fatal true | |
# default_formula 'ruby' | |
satisfy { | |
ruby_ver_required = Version.new('1.9.2') | |
if which('rvm') && ENV.has_key?('MY_RUBY_HOME') | |
ruby_ver_installed = Version.new(`$MY_RUBY_HOME/bin/ruby -e "puts RUBY_VERSION"`) # RVM Default | |
else | |
ruby_ver_installed = Version.new(`ruby -e "puts RUBY_VERSION"`) # System Default | |
end | |
if ruby_ver_installed >= ruby_ver_required | |
true | |
else | |
puts "Error: Requires ruby >=#{ruby_ver}. You have #{ruby_ver_installed}" | |
end | |
} | |
end | |
class Metasploit < Formula | |
homepage 'http://www.metasploit.com/framework/' | |
head 'https://github.com/rapid7/metasploit-framework.git' | |
url 'https://github.com/rapid7/metasploit-framework.git', :using => :git, :tag => '4.8.0' | |
depends_on Ruby192EqualGreater | |
# depends_on 'ruby' => '1.9.3' | |
depends_on 'bundler' => :ruby | |
def install | |
libexec.install Dir['*'] | |
bin.install_symlink Dir["#{libexec}/msf*"] | |
cd "#{libexec}" do | |
# if which('rvm') && ENV.has_key?('MY_RUBY_HOME') | |
# system "export PATH=$HOME/.rvm/bin:$PATH && bundle install" | |
# else | |
system "bundle install --without development test" | |
# end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment