[PATCH] vendor_ruby support
From:
Marcus Rueckert <mrueckert@...>
Date:
2007-02-21 14:57:05 UTC
List:
ruby-core #10387
Hi,
Disclaimer: I am not the original author of this patch. I am just a
happy user of the patches and I just updated them for
trunk and 1.8.x to apply cleanly.
So far ruby has two directories $libdir/ruby/1.8 and
$libdir/ruby/site_ruby/1.8. Sadly this does not leave space for
packagers. If you install library packages into $libdir/ruby/1.8 you mix
them with stdlib. If you go for $libdir/ruby/site_ruby/1.8 it is hard
for an user to differ between library packages and manually installed
libraries.
A few months ago a friend gave me the link to the vendor_ruby patch.
I applied the patch and so far i had no issues with it.
The patch adds $libdir/ruby/vendor_ruby/1.8 to the search list.
For my 1.8.x branch installation it looks like:
[[[
$ /opt/ruby/1.8.x/bin/ruby -v -rpp -e 'pp $LOAD_PATH'
ruby 1.8.6 (2007-02-19 patchlevel 5000) [i686-linux]
["/opt/ruby/1.8.x/lib/ruby/site_ruby/1.8",
"/opt/ruby/1.8.x/lib/ruby/site_ruby/1.8/i686-linux",
"/opt/ruby/1.8.x/lib/ruby/site_ruby",
"/opt/ruby/1.8.x/lib/ruby/vendor_ruby/1.8",
"/opt/ruby/1.8.x/lib/ruby/vendor_ruby/1.8/i686-linux",
"/opt/ruby/1.8.x/lib/ruby/vendor_ruby",
"/opt/ruby/1.8.x/lib/ruby/1.8",
"/opt/ruby/1.8.x/lib/ruby/1.8/i686-linux",
"."]
]]]
The patch makes the life of ruby packagers much easier:
[[[
ruby -rvendor-specific setup.rb config
ruby -rvendor-specific setup.rb setup
ruby -rvendor-specific setup.rb install \
--prefix=/var/tmp/ruby-xmpp4r-0.3-build
]]]
The defaults stay with site_ruby of course.
The impact of the patch is pretty low. I would appreciate if we could
integrate it into 1.8.6 and 1.9.
with kind regards,
darix
attached: ruby-1.8.x_vendor_ruby.patch
attached: ruby-trunk_vendor_ruby.patch
--
openSUSE - SUSE Linux is my linux
openSUSE is good for you
www.opensuse.org
Attachments (2)
ruby-1.8.x_vendor_ruby.patch
(7.5 KB, text/x-diff)
Index: configure.in
===================================================================
--- configure.in (revision 11806)
+++ configure.in (working copy)
@@ -1580,9 +1580,28 @@
AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${RUBY_SITE_LIB_PATH}")
AC_DEFINE_UNQUOTED(RUBY_SITE_LIB2, "${RUBY_SITE_LIB_PATH2}")
+AC_ARG_WITH(vendordir,
+ [ --with-vendordir=DIR vendor libraries in DIR [LIBDIR/ruby/vendor_ruby]],
+ [vendordir=$withval],
+ [vendordir='${prefix}/lib/ruby/vendor_ruby'])
+VENDOR_DIR="`eval \"echo ${vendordir}\"`"
+case "$target_os" in
+ cygwin*|mingw*|*djgpp*|os2_emx*)
+ RUBY_VENDOR_LIB_PATH="`expr "$VENDOR_DIR" : "$prefix\(/.*\)"`" ||
+ RUBY_VENDOR_LIB_PATH="$VENDOR_DIR";;
+ *)
+ RUBY_VENDOR_LIB_PATH="$VENDOR_DIR";;
+esac
+RUBY_VENDOR_LIB_PATH2="${RUBY_VENDOR_LIB_PATH}/${MAJOR}.${MINOR}"
+
+AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB, "${RUBY_VENDOR_LIB_PATH}")
+AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB2, "${RUBY_VENDOR_LIB_PATH2}")
+
AC_SUBST(arch)dnl
AC_SUBST(sitearch)dnl
+AC_SUBST(vendorarch)dnl
AC_SUBST(sitedir)dnl
+AC_SUBST(vendordir)dnl
configure_args=$ac_configure_args
AC_SUBST(configure_args)dnl
@@ -1595,6 +1614,8 @@
AC_DEFINE_UNQUOTED(RUBY_SITE_THIN_ARCHLIB,
"${RUBY_SITE_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}")
+ AC_DEFINE_UNQUOTED(RUBY_VENDOR_THIN_ARCHLIB,
+ "${RUBY_VENDOR_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}")
AC_DEFINE_UNQUOTED(RUBY_PLATFORM, __ARCHITECTURE__ "-${target_os}")
else
arch="${target_cpu}-${target_os}"
@@ -1602,12 +1623,15 @@
fi
case "$target_os" in
- mingw*) sitearch="i386-$rb_cv_msvcrt" ;;
- *) sitearch="${arch}" ;;
+ mingw*) sitearch="i386-$rb_cv_msvcrt"
+ vendorarch="i386-$rb_cv_msvcrt" ;;
+ *) sitearch="${arch}"
+ vendorarch="${arch}" ;;
esac
AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${RUBY_LIB_PATH}/${arch}")
AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${RUBY_SITE_LIB_PATH2}/${sitearch}")
+AC_DEFINE_UNQUOTED(RUBY_VENDOR_ARCHLIB, "${RUBY_VENDOR_LIB_PATH2}/${vendorarch}")
AC_ARG_WITH(search-path,
[ --with-search-path=DIR specify the additional search path],
Index: mkconfig.rb
===================================================================
--- mkconfig.rb (revision 11806)
+++ mkconfig.rb (working copy)
@@ -139,6 +139,14 @@
CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"
CONFIG["sitearchdir"] = "$(sitelibdir)/$(sitearch)"
+ CONFIG["vendorlibdir"] = "$(vendordir)/$(ruby_version)"
+ CONFIG["vendorarchdir"] = "$(vendorlibdir)/$(vendorarch)"
+ if defined?(VENDOR_SPECIFIC) && VENDOR_SPECIFIC
+ CONFIG["sitearch"] = CONFIG["vendorarch"]
+ CONFIG["sitedir"] = CONFIG["vendordir"]
+ CONFIG["sitelibdir"] = CONFIG["vendorlibdir"]
+ CONFIG["sitearchdir"] = CONFIG["vendorarchdir"]
+ end
CONFIG["topdir"] = File.dirname(__FILE__)
MAKEFILE_CONFIG = {}
CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
Index: lib/vendor-specific.rb
===================================================================
--- lib/vendor-specific.rb (revision 0)
+++ lib/vendor-specific.rb (revision 0)
@@ -0,0 +1,14 @@
+# $Id: vendor-specific.rb,v 1.1 2004/04/02 04:47:43 rshaw Exp $
+# Custom vendor_ruby install library setting for DarwinPorts module
+# installation. You can force vendor installation with the following:
+#
+# ruby -rvendor-specific extconf.rb
+# or
+# ruby -rvendor-specific install.rb
+#
+# This causes vendor-specific installation mode. The default without
+# this is to do a site-specific installation, which is recommended for
+# general user installation of modules.
+#
+VENDOR_SPECIFIC=true
+
Index: lib/site-specific.rb
===================================================================
--- lib/site-specific.rb (revision 0)
+++ lib/site-specific.rb (revision 0)
@@ -0,0 +1,14 @@
+# $Id: site-specific.rb,v 1.1 2004/04/02 04:47:43 rshaw Exp $
+# Default site_ruby install library setting for normal module
+# installation. You can force site installation with the following:
+#
+# ruby -rsite-specific extconf.rb
+# or
+# ruby -rsite-specific install.rb
+#
+# This is not required for normal user module installation as they will
+# default to site_ruby, it is only provided for consistency. Developers
+# creating packages/ports should use the vendor-specific option.
+#
+VENDOR_SPECIFIC=false
+
Index: lib/mkmf.rb
===================================================================
--- lib/mkmf.rb (revision 11806)
+++ lib/mkmf.rb (working copy)
@@ -51,6 +51,9 @@
$sitedir = CONFIG["sitedir"]
$sitelibdir = CONFIG["sitelibdir"]
$sitearchdir = CONFIG["sitearchdir"]
+$vendordir = CONFIG["vendordir"]
+$vendorlibdir = CONFIG["vendorlibdir"]
+$vendorarchdir = CONFIG["vendorarchdir"]
$mswin = /mswin/ =~ RUBY_PLATFORM
$bccwin = /bccwin/ =~ RUBY_PLATFORM
@@ -410,7 +413,7 @@
def try_func(func, libs, headers = nil, &b)
headers = cpp_include(headers)
- try_link(<<"SRC", libs, &b) or try_link(<<"SRC", libs, &b)
+ try_link(<<"SRC", libs, &b) or try_link(<<"SRC", libs, &b) or try_link(<<"SRC", libs, &b)
#{COMMON_HEADERS}
#{headers}
/*top*/
@@ -422,6 +425,11 @@
int main() { return 0; }
int t() { #{func}(); return 0; }
SRC
+int #{func}();
+/*top*/
+int main() { return 0; }
+int t() { #{func}(); return 0; }
+SRC
end
def try_var(var, headers = nil, &b)
@@ -1087,6 +1095,7 @@
RUBY_SO_NAME = #{CONFIG['RUBY_SO_NAME']}
arch = #{CONFIG['arch']}
sitearch = #{CONFIG['sitearch']}
+vendorarch = #{CONFIG['vendorarch']}
ruby_version = #{Config::CONFIG['ruby_version']}
ruby = #{$ruby}
RUBY = $(ruby#{sep})
Index: Makefile.in
===================================================================
--- Makefile.in (revision 11806)
+++ Makefile.in (working copy)
@@ -24,6 +24,8 @@
arch = @arch@
sitearch = @sitearch@
sitedir = @sitedir@
+vendorarch = @vendorarch@
+vendordir = @vendordir@
TESTUI = console
TESTS =
Index: instruby.rb
===================================================================
--- instruby.rb (revision 11806)
+++ instruby.rb (working copy)
@@ -162,6 +162,8 @@
archlibdir = CONFIG["archdir"]
sitelibdir = CONFIG["sitelibdir"]
sitearchlibdir = CONFIG["sitearchdir"]
+vendorlibdir = with_destdir(CONFIG["vendorlibdir"])
+vendorarchlibdir = with_destdir(CONFIG["vendorarchdir"])
mandir = File.join(CONFIG["mandir"], "man")
configure_args = Shellwords.shellwords(CONFIG["configure_args"])
enable_shared = CONFIG["ENABLE_SHARED"] == 'yes'
@@ -202,7 +204,7 @@
extout = "#$extout"
install?(:ext, :arch, :'ext-arch') do
puts "installing extension objects"
- makedirs [archlibdir, sitearchlibdir]
+ makedirs [archlibdir, sitearchlibdir, vendorarchlibdir]
if noinst = CONFIG["no_install_files"] and noinst.empty?
noinst = nil
end
@@ -210,7 +212,7 @@
end
install?(:ext, :comm, :'ext-comm') do
puts "installing extension scripts"
- makedirs [rubylibdir, sitelibdir]
+ makedirs [rubylibdir, sitelibdir, vendorlibdir]
install_recursive("#{extout}/common", rubylibdir)
end
end
Index: ruby.c
===================================================================
--- ruby.c (revision 11806)
+++ ruby.c (working copy)
@@ -298,6 +298,13 @@
ruby_incpush(RUBY_RELATIVE(RUBY_SITE_ARCHLIB));
ruby_incpush(RUBY_RELATIVE(RUBY_SITE_LIB));
+ ruby_incpush(RUBY_RELATIVE(RUBY_VENDOR_LIB2));
+#ifdef RUBY_VENDOR_THIN_ARCHLIB
+ ruby_incpush(RUBY_RELATIVE(RUBY_VENDOR_THIN_ARCHLIB));
+#endif
+ ruby_incpush(RUBY_RELATIVE(RUBY_VENDOR_ARCHLIB));
+ ruby_incpush(RUBY_RELATIVE(RUBY_VENDOR_LIB));
+
ruby_incpush(RUBY_RELATIVE(RUBY_LIB));
#ifdef RUBY_THIN_ARCHLIB
ruby_incpush(RUBY_RELATIVE(RUBY_THIN_ARCHLIB));
ruby-trunk_vendor_ruby.patch
(7.51 KB, text/x-diff)
Index: configure.in
===================================================================
--- configure.in (revision 11806)
+++ configure.in (working copy)
@@ -1578,9 +1578,28 @@
AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${RUBY_SITE_LIB_PATH}")
AC_DEFINE_UNQUOTED(RUBY_SITE_LIB2, "${RUBY_SITE_LIB_PATH2}")
+AC_ARG_WITH(vendordir,
+ [ --with-vendordir=DIR vendor libraries in DIR [LIBDIR/ruby/vendor_ruby]],
+ [vendordir=$withval],
+ [vendordir='${prefix}/lib/ruby/vendor_ruby'])
+VENDOR_DIR="`eval \"echo ${vendordir}\"`"
+case "$target_os" in
+ cygwin*|mingw*|*djgpp*|os2_emx*)
+ RUBY_VENDOR_LIB_PATH="`expr "$VENDOR_DIR" : "$prefix\(/.*\)"`" ||
+ RUBY_VENDOR_LIB_PATH="$VENDOR_DIR";;
+ *)
+ RUBY_VENDOR_LIB_PATH="$VENDOR_DIR";;
+esac
+RUBY_VENDOR_LIB_PATH2="${RUBY_VENDOR_LIB_PATH}/${MAJOR}.${MINOR}"
+
+AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB, "${RUBY_VENDOR_LIB_PATH}")
+AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB2, "${RUBY_VENDOR_LIB_PATH2}")
+
AC_SUBST(arch)dnl
AC_SUBST(sitearch)dnl
+AC_SUBST(vendorarch)dnl
AC_SUBST(sitedir)dnl
+AC_SUBST(vendordir)dnl
configure_args=$ac_configure_args
AC_SUBST(configure_args)dnl
@@ -1593,6 +1612,8 @@
AC_DEFINE_UNQUOTED(RUBY_SITE_THIN_ARCHLIB,
"${RUBY_SITE_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}")
+ AC_DEFINE_UNQUOTED(RUBY_VENDOR_THIN_ARCHLIB,
+ "${RUBY_VENDOR_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}")
AC_DEFINE_UNQUOTED(RUBY_PLATFORM, __ARCHITECTURE__ "-${target_os}")
else
arch="${target_cpu}-${target_os}"
@@ -1600,12 +1621,15 @@
fi
case "$target_os" in
- mingw*) sitearch="i386-$rb_cv_msvcrt" ;;
- *) sitearch="${arch}" ;;
+ mingw*) sitearch="i386-$rb_cv_msvcrt"
+ vendorarch="i386-$rb_cv_msvcrt" ;;
+ *) sitearch="${arch}"
+ vendorarch="${arch}" ;;
esac
AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${RUBY_LIB_PATH}/${arch}")
AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${RUBY_SITE_LIB_PATH2}/${sitearch}")
+AC_DEFINE_UNQUOTED(RUBY_VENDOR_ARCHLIB, "${RUBY_VENDOR_LIB_PATH2}/${vendorarch}")
AC_ARG_WITH(search-path,
[ --with-search-path=DIR specify the additional search path],
Index: mkconfig.rb
===================================================================
--- mkconfig.rb (revision 11806)
+++ mkconfig.rb (working copy)
@@ -139,6 +139,14 @@
CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"
CONFIG["sitearchdir"] = "$(sitelibdir)/$(sitearch)"
+ CONFIG["vendorlibdir"] = "$(vendordir)/$(ruby_version)"
+ CONFIG["vendorarchdir"] = "$(vendorlibdir)/$(vendorarch)"
+ if defined?(VENDOR_SPECIFIC) && VENDOR_SPECIFIC
+ CONFIG["sitearch"] = CONFIG["vendorarch"]
+ CONFIG["sitedir"] = CONFIG["vendordir"]
+ CONFIG["sitelibdir"] = CONFIG["vendorlibdir"]
+ CONFIG["sitearchdir"] = CONFIG["vendorarchdir"]
+ end
CONFIG["topdir"] = File.dirname(__FILE__)
MAKEFILE_CONFIG = {}
CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
Index: lib/vendor-specific.rb
===================================================================
--- lib/vendor-specific.rb (revision 0)
+++ lib/vendor-specific.rb (revision 0)
@@ -0,0 +1,14 @@
+# $Id: vendor-specific.rb,v 1.1 2004/04/02 04:47:43 rshaw Exp $
+# Custom vendor_ruby install library setting for DarwinPorts module
+# installation. You can force vendor installation with the following:
+#
+# ruby -rvendor-specific extconf.rb
+# or
+# ruby -rvendor-specific install.rb
+#
+# This causes vendor-specific installation mode. The default without
+# this is to do a site-specific installation, which is recommended for
+# general user installation of modules.
+#
+VENDOR_SPECIFIC=true
+
Index: lib/site-specific.rb
===================================================================
--- lib/site-specific.rb (revision 0)
+++ lib/site-specific.rb (revision 0)
@@ -0,0 +1,14 @@
+# $Id: site-specific.rb,v 1.1 2004/04/02 04:47:43 rshaw Exp $
+# Default site_ruby install library setting for normal module
+# installation. You can force site installation with the following:
+#
+# ruby -rsite-specific extconf.rb
+# or
+# ruby -rsite-specific install.rb
+#
+# This is not required for normal user module installation as they will
+# default to site_ruby, it is only provided for consistency. Developers
+# creating packages/ports should use the vendor-specific option.
+#
+VENDOR_SPECIFIC=false
+
Index: lib/mkmf.rb
===================================================================
--- lib/mkmf.rb (revision 11806)
+++ lib/mkmf.rb (working copy)
@@ -51,6 +51,9 @@
$sitedir = CONFIG["sitedir"]
$sitelibdir = CONFIG["sitelibdir"]
$sitearchdir = CONFIG["sitearchdir"]
+$vendordir = CONFIG["vendordir"]
+$vendorlibdir = CONFIG["vendorlibdir"]
+$vendorarchdir = CONFIG["vendorarchdir"]
$mswin = /mswin/ =~ RUBY_PLATFORM
$bccwin = /bccwin/ =~ RUBY_PLATFORM
@@ -410,7 +413,7 @@
def try_func(func, libs, headers = nil, &b)
headers = cpp_include(headers)
- try_link(<<"SRC", libs, &b) or try_link(<<"SRC", libs, &b)
+ try_link(<<"SRC", libs, &b) or try_link(<<"SRC", libs, &b) or try_link(<<"SRC", libs, &b)
#{COMMON_HEADERS}
#{headers}
/*top*/
@@ -422,6 +425,11 @@
int main() { return 0; }
int t() { #{func}(); return 0; }
SRC
+int #{func}();
+/*top*/
+int main() { return 0; }
+int t() { #{func}(); return 0; }
+SRC
end
def try_var(var, headers = nil, &b)
@@ -1096,6 +1104,7 @@
RUBY_SO_NAME = #{CONFIG['RUBY_SO_NAME']}
arch = #{CONFIG['arch']}
sitearch = #{CONFIG['sitearch']}
+vendorarch = #{CONFIG['vendorarch']}
ruby_version = #{RbConfig::CONFIG['ruby_version']}
ruby = #{$ruby}
RUBY = $(ruby#{sep})
Index: Makefile.in
===================================================================
--- Makefile.in (revision 11806)
+++ Makefile.in (working copy)
@@ -25,6 +25,8 @@
arch = @arch@
sitearch = @sitearch@
sitedir = @sitedir@
+vendorarch = @vendorarch@
+vendordir = @vendordir@
TESTUI = console
TESTS =
Index: instruby.rb
===================================================================
--- instruby.rb (revision 11806)
+++ instruby.rb (working copy)
@@ -162,6 +162,8 @@
archlibdir = CONFIG["archdir"]
sitelibdir = CONFIG["sitelibdir"]
sitearchlibdir = CONFIG["sitearchdir"]
+vendorlibdir = with_destdir(CONFIG["vendorlibdir"])
+vendorarchlibdir = with_destdir(CONFIG["vendorarchdir"])
mandir = File.join(CONFIG["mandir"], "man")
configure_args = Shellwords.shellwords(CONFIG["configure_args"])
enable_shared = CONFIG["ENABLE_SHARED"] == 'yes'
@@ -202,7 +204,7 @@
extout = "#$extout"
install?(:ext, :arch, :'ext-arch') do
puts "installing extension objects"
- makedirs [archlibdir, sitearchlibdir]
+ makedirs [archlibdir, sitearchlibdir, vendorarchlibdir]
if noinst = CONFIG["no_install_files"] and noinst.empty?
noinst = nil
end
@@ -210,7 +212,7 @@
end
install?(:ext, :comm, :'ext-comm') do
puts "installing extension scripts"
- makedirs [rubylibdir, sitelibdir]
+ makedirs [rubylibdir, sitelibdir, vendorlibdir]
install_recursive("#{extout}/common", rubylibdir)
end
end
Index: ruby.c
===================================================================
--- ruby.c (revision 11806)
+++ ruby.c (working copy)
@@ -326,6 +326,13 @@
ruby_incpush(RUBY_RELATIVE(RUBY_SITE_ARCHLIB));
ruby_incpush(RUBY_RELATIVE(RUBY_SITE_LIB));
+ ruby_incpush(RUBY_RELATIVE(RUBY_VENDOR_LIB2));
+#ifdef RUBY_VENDOR_THIN_ARCHLIB
+ ruby_incpush(RUBY_RELATIVE(RUBY_VENDOR_THIN_ARCHLIB));
+#endif
+ ruby_incpush(RUBY_RELATIVE(RUBY_VENDOR_ARCHLIB));
+ ruby_incpush(RUBY_RELATIVE(RUBY_VENDOR_LIB));
+
ruby_incpush(RUBY_RELATIVE(RUBY_LIB));
#ifdef RUBY_THIN_ARCHLIB
ruby_incpush(RUBY_RELATIVE(RUBY_THIN_ARCHLIB));