pvalena / rpms / ruby

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