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