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