Blame SOURCES/ruby-2.1.0-custom-rubygems-location.patch

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