f8d165
From 94da59aafacc6a9efe829529eb51385588d6f149 Mon Sep 17 00:00:00 2001
f8d165
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
f8d165
Date: Fri, 11 Nov 2011 13:14:45 +0100
f8d165
Subject: [PATCH] Allow to install RubyGems into custom location, outside of
f8d165
 Ruby tree.
f8d165
f8d165
---
f8d165
 configure.ac            | 5 +++++
f8d165
 loadpath.c              | 4 ++++
f8d165
 template/verconf.h.tmpl | 3 +++
f8d165
 tool/rbinstall.rb       | 7 +++++++
f8d165
 4 files changed, 19 insertions(+)
f8d165
f8d165
diff --git a/configure.ac b/configure.ac
f8d165
index 6bba453e3c..028ef7ca3e 100644
f8d165
--- a/configure.ac
f8d165
+++ b/configure.ac
f8d165
@@ -4288,6 +4288,10 @@ AC_ARG_WITH(vendorarchdir,
f8d165
             [vendorarchdir=$withval],
f8d165
             [vendorarchdir=${multiarch+'${rubysitearchprefix}/vendor_ruby'${ruby_version_dir}}${multiarch-'${vendorlibdir}/${sitearch}'}])
f8d165
 
f8d165
+AC_ARG_WITH(rubygemsdir,
f8d165
+           AS_HELP_STRING([--with-rubygemsdir=DIR], [custom rubygems directory]),
f8d165
+            [rubygemsdir=$withval])
f8d165
+
f8d165
 AS_IF([test "${LOAD_RELATIVE+set}"], [
f8d165
     AC_DEFINE_UNQUOTED(LOAD_RELATIVE, $LOAD_RELATIVE)
f8d165
     RUBY_EXEC_PREFIX=''
f8d165
@@ -4312,6 +4316,7 @@ AC_SUBST(sitearchdir)dnl
f8d165
 AC_SUBST(vendordir)dnl
f8d165
 AC_SUBST(vendorlibdir)dnl
f8d165
 AC_SUBST(vendorarchdir)dnl
f8d165
+AC_SUBST(rubygemsdir)dnl
f8d165
 
f8d165
 AC_SUBST(CONFIGURE, "`echo $0 | sed 's|.*/||'`")dnl
f8d165
 AC_SUBST(configure_args, "`echo "${ac_configure_args}" | sed 's/\\$/$$/g'`")dnl
f8d165
diff --git a/loadpath.c b/loadpath.c
f8d165
index 623dc9d..74c5d9e 100644
f8d165
--- a/loadpath.c
f8d165
+++ b/loadpath.c
f8d165
@@ -94,6 +94,10 @@ const char ruby_initial_load_paths[] =
f8d165
 #endif
f8d165
 #endif
f8d165
 
f8d165
+#ifdef RUBYGEMS_DIR
f8d165
+    RUBYGEMS_DIR "\0"
f8d165
+#endif
f8d165
+
f8d165
     RUBY_LIB "\0"
f8d165
 #ifdef RUBY_THINARCH
f8d165
     RUBY_ARCH_LIB_FOR(RUBY_THINARCH) "\0"
f8d165
diff --git a/template/verconf.h.tmpl b/template/verconf.h.tmpl
f8d165
index 79c003e..34f2382 100644
f8d165
--- a/template/verconf.h.tmpl
f8d165
+++ b/template/verconf.h.tmpl
f8d165
@@ -36,6 +36,9 @@
f8d165
 % if C["RUBY_SEARCH_PATH"]
f8d165
 #define RUBY_SEARCH_PATH		"${RUBY_SEARCH_PATH}"
f8d165
 % end
f8d165
+% if C["rubygemsdir"]
f8d165
+#define RUBYGEMS_DIR			"${rubygemsdir}"
f8d165
+% end
f8d165
 %
f8d165
 % R = {}
f8d165
 % R["ruby_version"] = '"RUBY_LIB_VERSION"'
f8d165
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
f8d165
index b47b6e1..0b99408 100755
f8d165
--- a/tool/rbinstall.rb
f8d165
+++ b/tool/rbinstall.rb
dec771
@@ -335,6 +335,7 @@ def CONFIG.[](name, mandatory = false)
dec771
   vendorlibdir = CONFIG["vendorlibdir"]
dec771
   vendorarchlibdir = CONFIG["vendorarchdir"]
dec771
 end
f8d165
+rubygemsdir = CONFIG["rubygemsdir"]
f8d165
 mandir = CONFIG["mandir", true]
f8d165
 docdir = CONFIG["docdir", true]
f8d165
 configure_args = Shellwords.shellwords(CONFIG["configure_args"])
dec771
@@ -541,7 +542,13 @@ def install(src, cmd)
f8d165
 install?(:local, :comm, :lib) do
f8d165
   prepare "library scripts", rubylibdir
f8d165
   noinst = %w[*.txt *.rdoc *.gemspec]
f8d165
+  noinst += %w[rubygems.rb rubygems/ datadir.rb] if rubygemsdir
f8d165
   install_recursive(File.join(srcdir, "lib"), rubylibdir, :no_install => noinst, :mode => $data_mode)
f8d165
+  if rubygemsdir
f8d165
+    noinst = %w[obsolete.rb]
f8d165
+    install_recursive(File.join(srcdir, "lib", "rubygems"), File.join(rubygemsdir, "rubygems"), :mode => $data_mode)
f8d165
+    install(File.join(srcdir, "lib", "rubygems.rb"), File.join(rubygemsdir, "rubygems.rb"), :mode => $data_mode)
f8d165
+  end
f8d165
 end
f8d165
 
f8d165
 install?(:local, :comm, :hdr, :'comm-hdr') do
f8d165
-- 
f8d165
1.8.3.1
f8d165