Skip to content

Commit e6e88ab

Browse files
committed
Allow declaring root via env var in gemspecs
The bundle build tasks temporarily relocate Gemfile and gemspecs to temporary directories when packing bundles. For this to work, we can't depend on the Gemfile/gemspec exisiting in a specific location relative to other code. This allows specifying the project root via the MSP_ROOT environment variable. If you do not specify MSP_ROOT, the behavior is unchanged. MSP-10684
1 parent 147c6d8 commit e6e88ab

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

metasploit-framework.gemspec

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
# coding: utf-8
2-
# have to use realpath as metasploit-framework is often loaded through a symlink and tools like Coverage and debuggers
3-
# require realpaths.
4-
lib = File.realpath(File.expand_path('../lib', __FILE__))
2+
3+
# During build, the Gemfile is temporarily moved and
4+
# we must manually define the project root
5+
if ENV['MSP_ROOT']
6+
lib = Pathname.new(ENV['MSP_ROOT']).join('msf3', 'lib').to_path
7+
else
8+
# have to use realpath as metasploit-framework is often loaded through a symlink and tools like Coverage and debuggers
9+
# require realpaths.
10+
lib = File.realpath(File.expand_path('../lib', __FILE__))
11+
end
12+
513
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
614
require 'metasploit/framework/version'
715

0 commit comments

Comments
 (0)