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

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