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