Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xdevalias/7510924 to your computer and use it in GitHub Desktop.
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.
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