b8524a
From b5e9dc3683cb085aa57e7b12c35a4f21b2cc1482 Mon Sep 17 00:00:00 2001
b8524a
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
b8524a
Date: Fri, 11 Nov 2011 13:14:45 +0100
b8524a
Subject: [PATCH] Allow to install RubyGems into custom location, outside of
b8524a
 Ruby tree.
b8524a
b8524a
---
b8524a
 configure.in      | 8 ++++++++
b8524a
 tool/rbinstall.rb | 9 +++++++++
b8524a
 version.c         | 4 ++++
b8524a
 3 files changed, 21 insertions(+)
b8524a
b8524a
diff --git a/configure.in b/configure.in
b8524a
index 1627d12..e064b2b 100644
b8524a
--- a/configure.in
b8524a
+++ b/configure.in
b8524a
@@ -3401,6 +3401,13 @@ AC_ARG_WITH(vendorarchdir,
b8524a
             [vendorarchdir=$withval],
b8524a
             [vendorarchdir=${multiarch+'${rubysitearchprefix}/vendor_ruby/${ruby_version}'}${multiarch-'${vendorlibdir}/${sitearch}'}])
b8524a
 
b8524a
+AC_ARG_WITH(rubygemsdir,
b8524a
+           AS_HELP_STRING([--with-rubygemsdir=DIR], [custom rubygems directory]),
b8524a
+            [rubygemsdir=$withval])
b8524a
+if test "$rubygemsdir" != ""; then
b8524a
+    AC_DEFINE_UNQUOTED(RUBYGEMS_DIR,"$rubygemsdir" !<verconf>!)
b8524a
+fi
b8524a
+
b8524a
 unexpand_shvar rubylibprefix       exec_prefix libdir RUBY_BASE_NAME
b8524a
 unexpand_shvar rubyarchprefix      exec_prefix libdir arch RUBY_BASE_NAME archlibdir rubylibprefix
b8524a
 unexpand_shvar rubysitearchprefix  exec_prefix libdir sitearch arch RUBY_BASE_NAME archlibdir sitearchlibdir rubylibprefix
b8524a
@@ -3467,6 +3474,7 @@ AC_SUBST(sitearchdir)dnl
b8524a
 AC_SUBST(vendordir)dnl
b8524a
 AC_SUBST(vendorlibdir)dnl
b8524a
 AC_SUBST(vendorarchdir)dnl
b8524a
+AC_SUBST(rubygemsdir)dnl
b8524a
 
b8524a
 configure_args=$ac_configure_args
b8524a
 AC_SUBST(configure_args)dnl
b8524a
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
b8524a
index 92e54c6..c72dfb6 100755
b8524a
--- a/tool/rbinstall.rb
b8524a
+++ b/tool/rbinstall.rb
b8524a
@@ -320,6 +320,7 @@ sitelibdir = CONFIG["sitelibdir"]
b8524a
 sitearchlibdir = CONFIG["sitearchdir"]
b8524a
 vendorlibdir = CONFIG["vendorlibdir"]
b8524a
 vendorarchlibdir = CONFIG["vendorarchdir"]
b8524a
+rubygemsdir = CONFIG["rubygemsdir"]
b8524a
 mandir = CONFIG["mandir", true]
b8524a
 docdir = CONFIG["docdir", true]
b8524a
 configure_args = Shellwords.shellwords(CONFIG["configure_args"])
b8524a
@@ -507,7 +508,15 @@ end
b8524a
 install?(:local, :comm, :lib) do
b8524a
   prepare "library scripts", rubylibdir
b8524a
   noinst = %w[README* *.txt *.rdoc *.gemspec]
b8524a
+  noinst += %w[*ubygems.rb rubygems/ datadir.rb] if rubygemsdir
b8524a
   install_recursive(File.join(srcdir, "lib"), rubylibdir, :no_install => noinst, :mode => $data_mode)
b8524a
+  if rubygemsdir
b8524a
+    noinst = %w[obsolete.rb]
b8524a
+    install_recursive(File.join(srcdir, "lib", "rubygems"), File.join(rubygemsdir, "rubygems"), :mode => $data_mode)
b8524a
+    install_recursive(File.join(srcdir, "lib", "rbconfig"), File.join(rubygemsdir, "rbconfig"), :no_install => noinst, :mode => $data_mode)
b8524a
+    install(File.join(srcdir, "lib", "ubygems.rb"), File.join(rubygemsdir, "ubygems.rb"), :mode => $data_mode)
b8524a
+    install(File.join(srcdir, "lib", "rubygems.rb"), File.join(rubygemsdir, "rubygems.rb"), :mode => $data_mode)
b8524a
+  end
b8524a
 end
b8524a
 
b8524a
 install?(:local, :arch, :lib) do
b8524a
diff --git a/version.c b/version.c
b8524a
index 54c4513..d76100b 100644
b8524a
--- a/version.c
b8524a
+++ b/version.c
b8524a
@@ -99,6 +99,10 @@ const char ruby_initial_load_paths[] =
b8524a
 #endif
b8524a
 #endif
b8524a
 
b8524a
+#ifdef RUBYGEMS_DIR
b8524a
+    RUBYGEMS_DIR "\0"
b8524a
+#endif
b8524a
+
b8524a
     RUBY_LIB "\0"
b8524a
 #ifdef RUBY_THINARCH
b8524a
     RUBY_ARCH_LIB_FOR(RUBY_THINARCH) "\0"
b8524a
-- 
b8524a
1.8.1.2
b8524a