Blob Blame History Raw
From b5e9dc3683cb085aa57e7b12c35a4f21b2cc1482 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
Date: Fri, 11 Nov 2011 13:14:45 +0100
Subject: [PATCH] Allow to install RubyGems into custom location, outside of
 Ruby tree.

---
 configure.in      | 8 ++++++++
 tool/rbinstall.rb | 9 +++++++++
 version.c         | 4 ++++
 3 files changed, 21 insertions(+)

diff --git a/configure.in b/configure.in
index 1627d12..e064b2b 100644
--- a/configure.in
+++ b/configure.in
@@ -3349,6 +3349,13 @@ AC_ARG_WITH(vendorarchdir,
             [vendorarchdir=$withval],
             [vendorarchdir=${multiarch+'${rubysitearchprefix}/vendor_ruby/${ruby_version}'}${multiarch-'${vendorlibdir}/${sitearch}'}])
 
+AC_ARG_WITH(rubygemsdir,
+           AS_HELP_STRING([--with-rubygemsdir=DIR], [custom rubygems directory]),
+            [rubygemsdir=$withval])
+if test "$rubygemsdir" != ""; then
+    AC_DEFINE_UNQUOTED(RUBYGEMS_DIR,"$rubygemsdir" !<verconf>!)
+fi
+
 unexpand_shvar rubylibprefix       exec_prefix libdir RUBY_BASE_NAME
 unexpand_shvar rubyarchprefix      exec_prefix libdir arch RUBY_BASE_NAME archlibdir rubylibprefix
 unexpand_shvar rubysitearchprefix  exec_prefix libdir sitearch arch RUBY_BASE_NAME archlibdir sitearchlibdir rubylibprefix
@@ -3415,6 +3422,7 @@ AC_SUBST(sitearchdir)dnl
 AC_SUBST(vendordir)dnl
 AC_SUBST(vendorlibdir)dnl
 AC_SUBST(vendorarchdir)dnl
+AC_SUBST(rubygemsdir)dnl
 
 configure_args=$ac_configure_args
 AC_SUBST(configure_args)dnl
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
index 92e54c6..c72dfb6 100755
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -313,6 +313,7 @@ sitelibdir = CONFIG["sitelibdir"]
 sitearchlibdir = CONFIG["sitearchdir"]
 vendorlibdir = CONFIG["vendorlibdir"]
 vendorarchlibdir = CONFIG["vendorarchdir"]
+rubygemsdir = CONFIG["rubygemsdir"]
 mandir = CONFIG["mandir", true]
 docdir = CONFIG["docdir", true]
 configure_args = Shellwords.shellwords(CONFIG["configure_args"])
@@ -500,7 +501,15 @@ end
 install?(:local, :comm, :lib) do
   prepare "library scripts", rubylibdir
   noinst = %w[README* *.txt *.rdoc *.gemspec]
+  noinst += %w[*ubygems.rb rubygems/ datadir.rb] if rubygemsdir
   install_recursive(File.join(srcdir, "lib"), rubylibdir, :no_install => noinst, :mode => $data_mode)
+  if rubygemsdir
+    noinst = %w[obsolete.rb]
+    install_recursive(File.join(srcdir, "lib", "rubygems"), File.join(rubygemsdir, "rubygems"), :mode => $data_mode)
+    install_recursive(File.join(srcdir, "lib", "rbconfig"), File.join(rubygemsdir, "rbconfig"), :no_install => noinst, :mode => $data_mode)
+    install(File.join(srcdir, "lib", "ubygems.rb"), File.join(rubygemsdir, "ubygems.rb"), :mode => $data_mode)
+    install(File.join(srcdir, "lib", "rubygems.rb"), File.join(rubygemsdir, "rubygems.rb"), :mode => $data_mode)
+  end
 end
 
 install?(:local, :arch, :lib) do
diff --git a/version.c b/version.c
index 54c4513..d76100b 100644
--- a/version.c
+++ b/version.c
@@ -99,6 +99,10 @@ const char ruby_initial_load_paths[] =
 #endif
 #endif
 
+#ifdef RUBYGEMS_DIR
+    RUBYGEMS_DIR "\0"
+#endif
+
     RUBY_LIB "\0"
 #ifdef RUBY_THINARCH
     RUBY_ARCH_LIB_FOR(RUBY_THINARCH) "\0"
-- 
1.8.1.2