Detect if rubygems are running under rpmbuild.
This allows to install binaryi extensions on suitable place and clears the .spec files a bit.
This commit is contained in:
parent
02ee7904a4
commit
19ff4992f3
@ -11,6 +11,15 @@ module Gem
|
||||
end
|
||||
private :previous_but_one_dir_to
|
||||
|
||||
##
|
||||
# Tries to detect, if arguments and environment variables suggest that
|
||||
# 'gem install' is executed from rpmbuild.
|
||||
|
||||
def rpmbuild?
|
||||
(ARGV.include?('--install-dir') || ARGV.include?('-i')) && ENV['RPM_PACKAGE_NAME']
|
||||
end
|
||||
private :rpmbuild?
|
||||
|
||||
##
|
||||
# Default gems locations allowed on FHS system (/usr, /usr/share).
|
||||
# The locations are derived from directories specified during build
|
||||
@ -78,8 +87,16 @@ module Gem
|
||||
end
|
||||
|
||||
def default_ext_dir_for base_dir
|
||||
dirs = Gem.default_dirs.detect {|location, paths| paths[:gem_dir] == base_dir}
|
||||
dirs && File.join(dirs.last[:ext_dir], RbConfig::CONFIG['RUBY_INSTALL_NAME'])
|
||||
dir = if rpmbuild?
|
||||
build_dir = base_dir.chomp Gem.default_dirs[:system][:gem_dir]
|
||||
if build_dir != base_dir
|
||||
File.join build_dir, Gem.default_dirs[:system][:ext_dir]
|
||||
end
|
||||
else
|
||||
dirs = Gem.default_dirs.detect {|location, paths| paths[:gem_dir] == base_dir}
|
||||
dirs && dirs.last[:ext_dir]
|
||||
end
|
||||
dir && File.join(dir, RbConfig::CONFIG['RUBY_INSTALL_NAME'])
|
||||
end
|
||||
|
||||
# This method should be available since RubyGems 2.2 until RubyGems 3.0.
|
||||
|
Loading…
Reference in New Issue
Block a user