2015-07-02 20:30:58 +00:00
|
|
|
require 'rbconfig'
|
|
|
|
require 'yaml'
|
|
|
|
|
2014-06-02 17:54:46 +00:00
|
|
|
module Metasploit
|
|
|
|
module Framework
|
|
|
|
module Version
|
2015-07-02 20:30:58 +00:00
|
|
|
# Determines the git hash for this source tree
|
|
|
|
#
|
|
|
|
# @return [String] the git hash for this source tree
|
|
|
|
def self.get_hash
|
|
|
|
@@git_hash ||= begin
|
|
|
|
root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..'))
|
|
|
|
version_yml = File.join(root, 'version.yml')
|
|
|
|
hash = ''
|
|
|
|
|
|
|
|
if File.exist?(version_yml)
|
|
|
|
version_info = YAML.load_file(version_yml)
|
|
|
|
hash = '-' + version_info['build_framework_rev']
|
|
|
|
else
|
|
|
|
# determine if git is installed
|
2015-10-15 21:14:20 +00:00
|
|
|
null = RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL' : '/dev/null'
|
|
|
|
git_installed = system("git --version > #{null} 2>&1")
|
2015-07-02 20:30:58 +00:00
|
|
|
|
|
|
|
# get the hash of the HEAD commit
|
|
|
|
if git_installed && File.exist?(File.join(root, '.git'))
|
2015-10-15 21:14:20 +00:00
|
|
|
hash = '-' + `git rev-parse --short HEAD`
|
2015-07-02 20:30:58 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
hash.strip
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-06-02 17:54:46 +00:00
|
|
|
MAJOR = 4
|
2014-12-15 20:42:09 +00:00
|
|
|
MINOR = 11
|
2015-10-30 14:37:00 +00:00
|
|
|
PATCH = 5
|
2014-06-02 17:54:46 +00:00
|
|
|
PRERELEASE = 'dev'
|
2015-07-02 20:30:58 +00:00
|
|
|
HASH = get_hash
|
2014-06-02 17:54:46 +00:00
|
|
|
end
|
|
|
|
|
2015-07-02 20:30:58 +00:00
|
|
|
VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::PATCH}-#{Version::PRERELEASE}#{Version::HASH}"
|
|
|
|
GEM_VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::PATCH}"
|
2014-06-02 17:54:46 +00:00
|
|
|
end
|
|
|
|
end
|