diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2020-01-15 15:51:32 +0000 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2020-01-15 15:51:32 +0000 |
commit | 21435953e16cda318a82334ddbadb3b5c36d9ea7 (patch) | |
tree | e1810a4b135afce04b34862ef0fab2bfaeb8aeca /dev-ruby/rubygems/files/gentoo-defaults-4.rb | |
parent | 7bc9c63c9da678a7e6fceb095d56c634afd22c56 (diff) |
gentoo resync : 15.01.2020
Diffstat (limited to 'dev-ruby/rubygems/files/gentoo-defaults-4.rb')
-rw-r--r-- | dev-ruby/rubygems/files/gentoo-defaults-4.rb | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/dev-ruby/rubygems/files/gentoo-defaults-4.rb b/dev-ruby/rubygems/files/gentoo-defaults-4.rb new file mode 100644 index 000000000000..1da07f64ddef --- /dev/null +++ b/dev-ruby/rubygems/files/gentoo-defaults-4.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +# Gentoo defaults for rubygems 3.x +# +# Gentoo policy is to install all manually installed code into +# /usr/local and to keep /usr managed by Gentoo. This policy file +# ensures that all manually installed gems using "gem install" are +# installed in /usr/local. Gentoo gems are installed in /usr. + +# TODO: We used to manipulate the default_dir, but this no longer +# works since this is now the base for the new "default" gems that +# ruby 2.6 uses with irb. So default_dir should refer to the system +# default now. rubygems also provides various hooks so we may be able +# to use those to install gems in /usr/local by default in a less +# intrusive way. +module Gem + + class << self + def portage_gems_dir + RbConfig::CONFIG['sitelibdir'].gsub('site_ruby', 'gems') + end + + def local_dir + portage_gems_dir.gsub('@GENTOO_PORTAGE_EPREFIX@/usr', + '@GENTOO_PORTAGE_EPREFIX@/usr/local') + end + + def install_dir + Process.euid.zero? ? local_dir : user_dir + end + + undef :default_path + def default_path + path = [] + path << user_dir if user_home && File.exist?(user_home) + path << default_dir + path << vendor_dir if vendor_dir && File.directory?(vendor_dir) + path << local_dir + path << portage_gems_dir + end + + def system_config_path + '@GENTOO_PORTAGE_EPREFIX@/etc' + end + + # Set Gentoo defaults for gem commands + begin + undef :operating_system_defaults + rescue NameError + # Avoid either runtime errors or redefinition warnings since + # this method is not present in all rubygem versions distributed + # with dev-lang/ruby. + end + def operating_system_defaults + { + 'install' => "--install-dir #{install_dir}", + 'uninstall' => "--install-dir #{install_dir}", + 'update' => "--install-dir #{install_dir}" + } + end + + end +end |