ruby: move sitedir/vendordir to prefix in postinstall

This ensures that they can be installed under the sandbox (in which case
HOMEBREW_PREFIX is not writeable), and helps improve the bottle.
This commit is contained in:
Misty De Meo 2015-08-18 19:21:33 -07:00
parent d64da5a5b7
commit 100effa540

View file

@ -68,6 +68,20 @@ class Ruby < Formula
args << "--with-opt-dir=#{paths.join(":")}"
system "./configure", *args
# Ruby has been configured to look in the HOMEBREW_PREFIX for the
# sitedir and vendordir directories; however we don't actually want to create
# them during the install.
#
# These directories are empty on install; sitedir is used for non-rubygems
# third party libraries, and vendordir is used for packager-provided libraries.
inreplace "tool/rbinstall.rb" do |s|
s.gsub! 'prepare "extension scripts", sitelibdir', ""
s.gsub! 'prepare "extension scripts", vendorlibdir', ""
s.gsub! 'prepare "extension objects", sitearchlibdir', ""
s.gsub! 'prepare "extension objects", vendorarchlibdir', ""
end
system "make"
system "make", "install"
end
@ -75,7 +89,13 @@ class Ruby < Formula
def post_install
# Customize rubygems to look/install in the global gem directory
# instead of in the Cellar, making gems last across reinstalls
(lib/"ruby/#{abi_version}/rubygems/defaults/operating_system.rb").write rubygems_config
config_file = lib/"ruby/#{abi_version}/rubygems/defaults/operating_system.rb"
config_file.unlink if config_file.exist?
config_file.write rubygems_config
# Create the sitedir and vendordir that were skipped during install
mkdir_p `#{bin}/ruby -e 'require "rbconfig"; print RbConfig::CONFIG["sitearchdir"]'`
mkdir_p `#{bin}/ruby -e 'require "rbconfig"; print RbConfig::CONFIG["vendorarchdir"]'`
end
def abi_version