[ruby] Update to Ruby 1.9.3.

Vít Ondruch vondruch at fedoraproject.org
Wed Jan 18 14:54:35 UTC 2012


commit 117278abd02a5bf1a482753a93fbe47c52752f6f
Author: Vít Ondruch <vondruch at redhat.com>
Date:   Wed Jan 18 15:54:01 2012 +0100

    Update to Ruby 1.9.3.

 .gitignore                                        |    1 +
 operating_system.rb                               |   70 ++
 ruby-1.8.7-always-use-i386.patch                  |   11 -
 ruby-1.8.7-lib-paths.patch                        |  228 ----
 ruby-1.8.7-multilib.patch                         |   34 -
 ruby-1.8.7-p249-mkmf-use-shared.patch             |   11 -
 ruby-1.8.7-p330-multilib.patch                    |   33 -
 ruby-1.8.7-p352-path-uniq.patch                   |   54 -
 ruby-1.9.3-added-site-and-vendor-arch-flags.patch |  188 ++++
 ruby-1.9.3-always-use-i386.patch                  |   11 +
 ruby-1.9.3-arch-specific-dir.patch                |  132 +++
 ruby-1.9.3-bignum-test-fix.patch                  |   31 +
 ruby-1.9.3-custom-rubygems-location.patch         |   97 ++
 ruby-1.9.3-disable-versioned-paths.patch          |  149 +++
 ruby-1.9.3-fix-json-parser.patch                  |   40 +
 ruby-1.9.3-fix-s390x-build.patch                  |   12 +
 ruby-1.9.3-prevent-optimizing-sp.patch            |   53 +
 ruby-1.9.3-rubygems-1.8.11-uninstaller.patch      |   76 ++
 ruby-1.9.3-webrick-test-fix.patch                 |   24 +
 ruby.spec                                         | 1162 ++++++++++++---------
 rubygems-1.8.11-binary-extensions.patch           |  296 ++++++
 sources                                           |    3 +-
 22 files changed, 1852 insertions(+), 864 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index c1f83dd..03a0175 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ ruby-rev415a3ef9ab82c65a7abc-ext_tk.tar.gz
 /ruby-1.8.7-p352.tar.bz2
 /ruby-revc2dfaa7d40531aef3706bcc16f38178b0c6633ee-ext_tk.tar.gz
 /ruby-1.8.7-p357.tar.bz2
+/ruby-1.9.3-p0.tar.gz
diff --git a/operating_system.rb b/operating_system.rb
new file mode 100644
index 0000000..b81425f
--- /dev/null
+++ b/operating_system.rb
@@ -0,0 +1,70 @@
+module Gem
+  class << self
+
+    ##
+    # Returns a string representing that part or the directory tree that is
+    # common to all specified directories.
+
+    def common_path(dirs)
+      paths = dirs.collect {|dir| dir.split(File::SEPARATOR)}
+      uncommon_idx = paths.transpose.each_with_index.find {|dirnames, idx| dirnames.uniq.length > 1}.last
+      paths[0][0 ... uncommon_idx].join(File::SEPARATOR)
+    end
+    private :common_path
+
+    ##
+    # Default gems locations allowed on FHS system (/usr, /usr/share).
+    # The locations are derived from directories specified during build
+    # configuration.
+
+    def default_locations
+      @default_locations ||= {
+        :system => common_path([ConfigMap[:vendorlibdir], ConfigMap[:vendorarchdir]]),
+        :local => common_path([ConfigMap[:sitelibdir], ConfigMap[:sitearchdir]])
+      }
+    end
+
+    ##
+    # For each location provides set of directories for binaries (:bin_dir)
+    # platform independent (:gem_dir) and dependent (:ext_dir) files.
+
+    def default_dirs
+      @default_dirs ||= Hash[default_locations.collect do |destination, path|
+        [destination, {
+          :bin_dir => File.join(path, ConfigMap[:bindir].split(File::SEPARATOR).last),
+          :gem_dir => File.join(path, ConfigMap[:datadir].split(File::SEPARATOR).last, 'gems'),
+          :ext_dir => File.join(path, ConfigMap[:libdir].split(File::SEPARATOR).last, 'gems')
+        }]
+      end]
+    end
+
+    ##
+    # RubyGems default overrides.
+
+    def default_dir
+      if Process.uid == 0
+        Gem.default_dirs[:local][:gem_dir]
+      else
+        Gem.user_dir
+      end
+    end
+
+    def default_path
+      path = default_dirs.collect {|location, paths| paths[:gem_dir]}
+      path.unshift Gem.user_dir if File.exist? Gem.user_home
+    end
+
+    def default_bindir
+      if Process.uid == 0
+        Gem.default_dirs[:local][:bin_dir]
+      else
+        File.join [Dir.home, 'bin']
+      end
+    end
+
+    def default_ext_dir_for base_dir
+      dirs = Gem.default_dirs.detect {|location, paths| paths[:gem_dir] == base_dir}
+      dirs && File.join(dirs.last[:ext_dir], 'exts')
+    end
+  end
+end
diff --git a/ruby-1.9.3-added-site-and-vendor-arch-flags.patch b/ruby-1.9.3-added-site-and-vendor-arch-flags.patch
new file mode 100644
index 0000000..9dff272
--- /dev/null
+++ b/ruby-1.9.3-added-site-and-vendor-arch-flags.patch
@@ -0,0 +1,188 @@
+From b0a875862d14244ca41cd1e1e9090f87757aaeb9 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch at redhat.com>
+Date: Mon, 5 Sep 2011 13:10:47 +0200
+Subject: [PATCH] Added configuration flags for site and vendor architecture
+ specific directories.
+
+---
+ Makefile.in      |    3 +++
+ configure.in     |   40 ++++++++++++++++++++++++++++++++++++++++
+ tool/mkconfig.rb |    8 ++++++--
+ version.c        |    4 ++++
+ 4 files changed, 53 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index bcdaf5f..f57e4c4 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -34,6 +34,9 @@ datadir = @datadir@
+ archdir = @archdir@
+ sitearch = @sitearch@
+ sitedir = @sitedir@
++sitearchdir= @sitearchdir@
++vendordir = @vendordir@
++vendorarchdir = @vendorarchdir@
+ ruby_version = @ruby_version@
+ 
+ TESTUI = console
+diff --git a/configure.in b/configure.in
+index 83e5d76..31532bd 100644
+--- a/configure.in
++++ b/configure.in
+@@ -2801,6 +2801,15 @@ until SITE_DIR=`eval echo \\"${dir}\\"`; test "x${dir}" = "x${SITE_DIR}"; do
+     dir="${SITE_DIR}"
+ done
+ 
++AC_ARG_WITH(sitearchdir,
++	    AS_HELP_STRING([--with-sitearchdir=DIR], [site libraries in DIR [[RUBY_LIB_PREFIX/site_ruby]]]),
++            [sitearchdir=$withval],
++            [sitearchdir='${rubylibprefix}/site_ruby/${arch}'])
++dir="${sitearchdir}"
++until SITEARCH_DIR=`eval echo \\"${dir}\\"`; test "x${dir}" = "x${SITEARCH_DIR}"; do
++    dir="${SITEARCH_DIR}"
++done
++
+ AC_ARG_WITH(vendordir,
+ 	    AS_HELP_STRING([--with-vendordir=DIR], [vendor libraries in DIR [[RUBY_LIB_PREFIX/vendor_ruby]]]),
+             [vendordir=$withval],
+@@ -2810,19 +2819,32 @@ until VENDOR_DIR=`eval echo \\"${dir}\\"`; test "x${dir}" = "x${VENDOR_DIR}"; do
+     dir="${VENDOR_DIR}"
+ done
+ 
++AC_ARG_WITH(vendorarchdir,
++	    AS_HELP_STRING([--with-vendorarchdir=DIR], [vendor libraries in DIR [[RUBY_LIB_PREFIX/vendor_ruby]]]),
++            [vendorarchdir=$withval],
++            [vendorarchdir='${rubylibprefix}/vendor_ruby/${arch}'])
++dir="${vendorarchdir}"
++until VENDORARCH_DIR=`eval echo \\"${dir}\\"`; test "x${dir}" = "x${VENDORARCH_DIR}"; do
++    dir="${VENDORARCH_DIR}"
++done
++
+ if test "${LOAD_RELATIVE+set}"; then
+     AC_DEFINE_UNQUOTED(LOAD_RELATIVE, $LOAD_RELATIVE)
+     RUBY_EXEC_PREFIX=""
+     RUBY_LIB_PREFIX="`eval echo "$RUBY_LIB_PREFIX" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
+     RUBY_ARCH_LIB_PATH="`eval echo "$ARCH_DIR" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
+     RUBY_SITE_LIB_PATH="`eval echo "$SITE_DIR" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
++    RUBY_SITE_ARCHLIB_PATH="`eval echo "$SITEARCH_DIR" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
+     RUBY_VENDOR_LIB_PATH="`eval echo "$VENDOR_DIR" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
++    RUBY_VENDOR_ARCHLIB_PATH="`eval echo "$VENDORARCH_DIR" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
+ else
+     RUBY_EXEC_PREFIX="`eval echo \\"$exec_prefix/\\" | sed 's|^NONE/|'"$prefix"'/|;s|/$||'`"
+     RUBY_LIB_PREFIX="`eval echo \\"$RUBY_LIB_PREFIX\\" | sed 's|^NONE/|'"$prefix"'/|'`"
+     RUBY_ARCH_LIB_PATH="`eval echo \\"$ARCH_DIR\\" | sed 's|^NONE/|'"$prefix"'/|'`"
+     RUBY_SITE_LIB_PATH="`eval echo \\"$SITE_DIR\\" | sed 's|^NONE/|'"$prefix"'/|'`"
++    RUBY_SITE_ARCHLIB_PATH="`eval echo \\"$SITEARCH_DIR\\" | sed 's|^NONE/|'"$prefix"'/|'`"
+     RUBY_VENDOR_LIB_PATH="`eval echo \\"$VENDOR_DIR\\" | sed 's|^NONE/|'"$prefix"'/|'`"
++    RUBY_VENDOR_ARCHLIB_PATH="`eval echo \\"$VENDORARCH_DIR\\" | sed 's|^NONE/|'"$prefix"'/|'`"
+ fi
+ 
+ pat=`echo "$RUBY_LIB_PREFIX/" | tr -c '\012' .`'\(.*\)'
+@@ -2840,6 +2862,13 @@ AS_CASE(["$RUBY_SITE_LIB_PATH"],
+   [
+     RUBY_SITE_LIB_PATH="\"${RUBY_SITE_LIB_PATH}\""
+     ])
++AS_CASE(["$RUBY_SITE_ARCHLIB_PATH"],
++  ["$RUBY_LIB_PREFIX/"*], [
++    RUBY_SITE_ARCHLIB_PATH='RUBY_LIB_PREFIX"/'"`expr \"$RUBY_SITE_ARCHLIB_PATH\" : \"$pat\"`"'"'
++    ],
++  [
++    RUBY_SITE_ARCHLIB_PATH="\"${RUBY_SITE_ARCHLIB_PATH}\""
++    ])
+ AS_CASE(["$RUBY_VENDOR_LIB_PATH"],
+   ["$RUBY_LIB_PREFIX/"*], [
+     RUBY_VENDOR_LIB_PATH='RUBY_LIB_PREFIX"/'"`expr \"$RUBY_VENDOR_LIB_PATH\" : \"$pat\"`"'"'
+@@ -2847,6 +2876,13 @@ AS_CASE(["$RUBY_VENDOR_LIB_PATH"],
+   [
+     RUBY_VENDOR_LIB_PATH="\"${RUBY_VENDOR_LIB_PATH}\""
+     ])
++AS_CASE(["$RUBY_VENDOR_ARCHLIB_PATH"],
++  ["$RUBY_LIB_PREFIX/"*], [
++    RUBY_VENDOR_ARCHLIB_PATH='RUBY_LIB_PREFIX"/'"`expr \"$RUBY_VENDOR_ARCHLIB_PATH\" : \"$pat\"`"'"'
++    ],
++  [
++    RUBY_VENDOR_ARCHLIB_PATH="\"${RUBY_VENDOR_ARCHLIB_PATH}\""
++    ])
+ pat=`echo "$RUBY_EXEC_PREFIX/" | tr -c '\012' .`'\(.*\)'
+ AS_CASE(["$RUBY_LIB_PREFIX"],
+   ["$RUBY_EXEC_PREFIX/"*], [
+@@ -2868,19 +2904,23 @@ if test "x$SITE_DIR" = xno; then
+     AC_DEFINE(NO_RUBY_SITE_LIB)
+ else
+     AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, ${RUBY_SITE_LIB_PATH})
++    AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, ${RUBY_SITE_ARCHLIB_PATH})
+ fi
+ if test "x$VENDOR_DIR" = xno; then
+     AC_DEFINE(NO_RUBY_VENDOR_LIB)
+ else
+     AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB, ${RUBY_VENDOR_LIB_PATH})
++    AC_DEFINE_UNQUOTED(RUBY_VENDOR_ARCHLIB, ${RUBY_VENDOR_ARCHLIB_PATH})
+ fi
+ 
+ AC_SUBST(arch)dnl
+ AC_SUBST(sitearch)dnl
+ AC_SUBST(ruby_version)dnl
+ AC_SUBST(archdir)dnl
+ AC_SUBST(sitedir)dnl
++AC_SUBST(sitearchdir)dnl
+ AC_SUBST(vendordir)dnl
++AC_SUBST(vendorarchdir)dnl
+ 
+ configure_args=$ac_configure_args
+ AC_SUBST(configure_args)dnl
+diff --git a/tool/mkconfig.rb b/tool/mkconfig.rb
+index b707c4b..6230720 100755
+--- a/tool/mkconfig.rb
++++ b/tool/mkconfig.rb
+@@ -44,6 +44,8 @@ v_others = []
+ continued_line = nil
+ path_version = "/$(ruby_version)"
+ archdir_override = "$(vendorlibdir)/$(sitearch)"
++sitearchdir_override = "$(sitelibdir)/$(sitearch)"
++vendorarchdir_override = "$(vendorlibdir)/$(sitearch)"
+ File.foreach "config.status" do |line|
+   next if /^#/ =~ line
+   name = nil
+@@ -79,6 +81,8 @@ File.foreach "config.status" do |line|
+     when /^RUBY_SO_NAME$/; next if $so_name
+     when /^arch$/; if val.empty? then val = arch else arch = val end
+     when /^archdir$/; archdir_override = val; next
++    when /^sitearchdir$/; sitearchdir_override = val; next
++    when /^vendorarchdir$/; vendorarchdir_override = val; next
+     when /^sitearch/; val = '$(arch)' if val.empty?
+     end
+     case val
+@@ -213,11 +217,11 @@ print <<EOS
+ EOS
+ print <<EOS unless v_disabled["sitedir"]
+   CONFIG["sitelibdir"] = "$(sitedir)#{path_version}"
+-  CONFIG["sitearchdir"] = "$(sitelibdir)/$(sitearch)"
++  CONFIG["sitearchdir"] = "#{sitearchdir_override}"
+ EOS
+ print <<EOS unless v_disabled["vendordir"]
+   CONFIG["vendorlibdir"] = "$(vendordir)#{path_version}"
+-  CONFIG["vendorarchdir"] = "$(vendorlibdir)/$(sitearch)"
++  CONFIG["vendorarchdir"] = "#{vendorarchdir_override}"
+ EOS
+ print <<EOS
+   CONFIG["topdir"] = File.dirname(__FILE__)
+diff --git a/version.c b/version.c
+index 59d4e5e..2558aa0 100644
+--- a/version.c
++++ b/version.c
+@@ -50,8 +50,12 @@
+ #ifndef RUBY_ARCHLIB
+ #define RUBY_ARCHLIB                RUBY_LIB         "/"RUBY_ARCH
+ #endif
++#ifndef RUBY_SITE_ARCHLIB
+ #define RUBY_SITE_ARCHLIB           RUBY_SITE_LIB2   "/"RUBY_SITEARCH
++#endif
++#ifndef RUBY_VENDOR_ARCHLIB
+ #define RUBY_VENDOR_ARCHLIB         RUBY_VENDOR_LIB2 "/"RUBY_SITEARCH
++#endif
+ #ifdef  RUBY_THINARCH
+ #define RUBY_THIN_ARCHLIB           RUBY_LIB         "/"RUBY_THINARCH
+ #define RUBY_SITE_THIN_ARCHLIB      RUBY_SITE_LIB2   "/"RUBY_THINARCH
+-- 
+1.7.6.1
+
diff --git a/ruby-1.9.3-always-use-i386.patch b/ruby-1.9.3-always-use-i386.patch
new file mode 100644
index 0000000..734c5eb
--- /dev/null
+++ b/ruby-1.9.3-always-use-i386.patch
@@ -0,0 +1,11 @@
+--- a/configure.in.orig	2011-10-18 08:56:21.587594685 +0200
++++ b/configure.in	2011-10-18 08:56:59.751593321 +0200
+@@ -2925,6 +2925,8 @@
+ configure_args=$ac_configure_args
+ AC_SUBST(configure_args)dnl
+ 
++target_cpu=`echo $target_cpu | sed s/i.86/i386/`
++
+ if test "${universal_binary-no}" = yes ; then
+     arch="universal-${target_os}"
+     AC_CACHE_CHECK(whether __ARCHITECTURE__ is available, rb_cv_architecture_available,
diff --git a/ruby-1.9.3-arch-specific-dir.patch b/ruby-1.9.3-arch-specific-dir.patch
new file mode 100644
index 0000000..b8feb96
--- /dev/null
+++ b/ruby-1.9.3-arch-specific-dir.patch
@@ -0,0 +1,132 @@
+From df4253a5b79b63f16f215f2c19f1b9666c4ca01e Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch at redhat.com>
+Date: Thu, 8 Sep 2011 15:30:05 +0200
+Subject: [PATCH] Add configuration arch specific dir flag.
+
+---
+ Makefile.in      |    1 +
+ configure.in     |   20 ++++++++++++++++++++
+ tool/mkconfig.rb |    4 +++-
+ version.c        |    2 ++
+ 4 files changed, 26 insertions(+), 1 deletions(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index bcdaf5f..d61b2ee 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -31,6 +31,7 @@ libexecdir = @libexecdir@
+ datarootdir = @datarootdir@
+ datadir = @datadir@
+ arch = @arch@
++archdir = @archdir@
+ sitearch = @sitearch@
+ sitedir = @sitedir@
+ ruby_version = @ruby_version@
+diff --git a/configure.in b/configure.in
+index 83e5d76..e6dc38c 100644
+--- a/configure.in
++++ b/configure.in
+@@ -2783,6 +2783,15 @@ else
+     RUBY_LIB_VERSION="\"${ruby_version}\""
+ fi
+ 
++AC_ARG_WITH(archdir,
++	    AS_HELP_STRING([--with-archdir=DIR], [architecture specific ruby libraries [[LIBDIR/RUBY_BASE_NAME/ARCH]]]),
++            [archdir=$withval],
++            [archdir='${rubylibprefix}/${arch}'])
++dir="${archdir}"
++until ARCH_DIR=`eval echo \\"${dir}\\"`; test "x${dir}" = "x${ARCH_DIR}"; do
++    dir="${ARCH_DIR}"
++done
++
+ AC_ARG_WITH(sitedir,
+ 	    AS_HELP_STRING([--with-sitedir=DIR], [site libraries in DIR [[RUBY_LIB_PREFIX/site_ruby]]]),
+             [sitedir=$withval],
+@@ -2805,16 +2814,25 @@ if test "${LOAD_RELATIVE+set}"; then
+     AC_DEFINE_UNQUOTED(LOAD_RELATIVE, $LOAD_RELATIVE)
+     RUBY_EXEC_PREFIX=""
+     RUBY_LIB_PREFIX="`eval echo "$RUBY_LIB_PREFIX" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
++    RUBY_ARCH_LIB_PATH="`eval echo "$ARCH_DIR" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
+     RUBY_SITE_LIB_PATH="`eval echo "$SITE_DIR" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
+     RUBY_VENDOR_LIB_PATH="`eval echo "$VENDOR_DIR" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
+ else
+     RUBY_EXEC_PREFIX="`eval echo \\"$exec_prefix/\\" | sed 's|^NONE/|'"$prefix"'/|;s|/$||'`"
+     RUBY_LIB_PREFIX="`eval echo \\"$RUBY_LIB_PREFIX\\" | sed 's|^NONE/|'"$prefix"'/|'`"
++    RUBY_ARCH_LIB_PATH="`eval echo \\"$ARCH_DIR\\" | sed 's|^NONE/|'"$prefix"'/|'`"
+     RUBY_SITE_LIB_PATH="`eval echo \\"$SITE_DIR\\" | sed 's|^NONE/|'"$prefix"'/|'`"
+     RUBY_VENDOR_LIB_PATH="`eval echo \\"$VENDOR_DIR\\" | sed 's|^NONE/|'"$prefix"'/|'`"
+ fi
+ 
+ pat=`echo "$RUBY_LIB_PREFIX/" | tr -c '\012' .`'\(.*\)'
++AS_CASE(["$RUBY_ARCH_LIB_PATH"],
++  ["$RUBY_LIB_PREFIX/"*], [
++    RUBY_ARCH_LIB_PATH='RUBY_LIB_PREFIX"/'"`expr \"$RUBY_ARCH_LIB_PATH\" : \"$pat\"`"'"'
++    ],
++  [
++    RUBY_ARCH_LIB_PATH="\"${RUBY_ARCH_LIB_PATH}\""
++    ])
+ AS_CASE(["$RUBY_SITE_LIB_PATH"],
+   ["$RUBY_LIB_PREFIX/"*], [
+     RUBY_SITE_LIB_PATH='RUBY_LIB_PREFIX"/'"`expr \"$RUBY_SITE_LIB_PATH\" : \"$pat\"`"'"'
+@@ -2845,6 +2863,7 @@ else
+ fi
+ AC_DEFINE_UNQUOTED(RUBY_EXEC_PREFIX, "${RUBY_EXEC_PREFIX}")
+ AC_DEFINE_UNQUOTED(RUBY_LIB_PREFIX, ${RUBY_LIB_PREFIX})
++AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, ${RUBY_ARCH_LIB_PATH})
+ if test "x$SITE_DIR" = xno; then
+     AC_DEFINE(NO_RUBY_SITE_LIB)
+ else
+@@ -2859,6 +2878,7 @@ fi
+ AC_SUBST(arch)dnl
+ AC_SUBST(sitearch)dnl
+ AC_SUBST(ruby_version)dnl
++AC_SUBST(archdir)dnl
+ AC_SUBST(sitedir)dnl
+ AC_SUBST(vendordir)dnl
+ 
+diff --git a/tool/mkconfig.rb b/tool/mkconfig.rb
+index b707c4b..9780ef2 100755
+--- a/tool/mkconfig.rb
++++ b/tool/mkconfig.rb
+@@ -43,6 +43,7 @@ v_others = []
+ continued_name = nil
+ continued_line = nil
+ path_version = "/$(ruby_version)"
++archdir_override = "$(vendorlibdir)/$(sitearch)"
+ File.foreach "config.status" do |line|
+   next if /^#/ =~ line
+   name = nil
+@@ -77,6 +78,7 @@ File.foreach "config.status" do |line|
+     when /^RUBY_INSTALL_NAME$/; next if $install_name
+     when /^RUBY_SO_NAME$/; next if $so_name
+     when /^arch$/; if val.empty? then val = arch else arch = val end
++    when /^archdir$/; archdir_override = val; next
+     when /^sitearch/; val = '$(arch)' if val.empty?
+     end
+     case val
+@@ -207,7 +209,7 @@ print(*v_fast)
+ print(*v_others)
+ print <<EOS
+   CONFIG["rubylibdir"] = "$(rubylibprefix)#{path_version}"
+-  CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
++  CONFIG["archdir"] = "#{archdir_override}"
+ EOS
+ print <<EOS unless v_disabled["sitedir"]
+   CONFIG["sitelibdir"] = "$(sitedir)#{path_version}"
+diff --git a/version.c b/version.c
+index 59d4e5e..915a0a2 100644
+--- a/version.c
++++ b/version.c
+@@ -47,7 +47,9 @@
+ #define RUBY_SITE_LIB2              RUBY_SITE_LIB    "/"RUBY_LIB_VERSION
+ #define RUBY_VENDOR_LIB2            RUBY_VENDOR_LIB  "/"RUBY_LIB_VERSION
+ #endif
++#ifndef RUBY_ARCHLIB
+ #define RUBY_ARCHLIB                RUBY_LIB         "/"RUBY_ARCH
++#endif
+ #define RUBY_SITE_ARCHLIB           RUBY_SITE_LIB2   "/"RUBY_SITEARCH
+ #define RUBY_VENDOR_ARCHLIB         RUBY_VENDOR_LIB2 "/"RUBY_SITEARCH
+ #ifdef  RUBY_THINARCH
+-- 
+1.7.6.1
+
diff --git a/ruby-1.9.3-bignum-test-fix.patch b/ruby-1.9.3-bignum-test-fix.patch
new file mode 100644
index 0000000..cb3682d
--- /dev/null
+++ b/ruby-1.9.3-bignum-test-fix.patch
@@ -0,0 +1,31 @@
+--- ruby-1.9.3-p0/test/ruby/test_bignum.rb.orig	2011-11-10 09:52:59.101925465 +0100
++++ ruby-1.9.3-p0/test/ruby/test_bignum.rb	2011-11-10 09:54:14.580798826 +0100
+@@ -378,7 +378,7 @@
+     assert_equal(true, (2**32).even?)
+   end
+ 
+-  def interrupt
++  def assert_interrupt
+     time = Time.now
+     start_flag = false
+     end_flag = false
+@@ -387,14 +387,16 @@
+       yield
+       end_flag = true
+     end
+-    sleep 1
++    Thread.pass until start_flag
+     thread.raise
+     thread.join rescue nil
+-    start_flag && !end_flag && Time.now - time < 10
++    time = Time.now - time
++    assert_equal([true, false], [start_flag, end_flag])
++    assert_operator(time, :<, 10)
+   end
+ 
+   def test_interrupt
+-    assert(interrupt { (65536 ** 65536).to_s })
++    assert_interrupt {(65536 ** 65536).to_s}
+   end
+ 
+   def test_too_big_to_s
diff --git a/ruby-1.9.3-custom-rubygems-location.patch b/ruby-1.9.3-custom-rubygems-location.patch
new file mode 100644
index 0000000..2566ef6
--- /dev/null
+++ b/ruby-1.9.3-custom-rubygems-location.patch
@@ -0,0 +1,97 @@
+From 279a693ce4ef3a887ce8d4fa59e0f2616a14d91a Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch at redhat.com>
+Date: Fri, 11 Nov 2011 13:14:45 +0100
+Subject: [PATCH] Allow to install RubyGems into custom location, outside of
+ Ruby tree.
+
+---
+ configure.in      |    8 ++++++++
+ tool/mkconfig.rb  |    1 +
+ tool/rbinstall.rb |    9 +++++++++
+ version.c         |    4 ++++
+ 4 files changed, 22 insertions(+), 0 deletions(-)
+
+diff --git a/configure.in b/configure.in
+index b1bc951..91c5d0d 100644
+--- a/configure.in
++++ b/configure.in
+@@ -2828,6 +2828,13 @@ until VENDOR_DIR=`eval echo \\"${dir}\\"`; test "x${dir}" = "x${VENDOR_DIR}"; do
+     dir="${VENDORARCH_DIR}"
+ done
+ 
++AC_ARG_WITH(rubygemsdir,
++           AS_HELP_STRING([--with-rubygemsdir=DIR], [custom rubygems directory]),
++            [rubygemsdir=$withval])
++if test "$rubygemsdir" != ""; then
++    AC_DEFINE_UNQUOTED(RUBYGEMS_DIR,"$rubygemsdir")
++fi
++
+ if test "${LOAD_RELATIVE+set}"; then
+     AC_DEFINE_UNQUOTED(LOAD_RELATIVE, $LOAD_RELATIVE)
+     RUBY_EXEC_PREFIX=""
+@@ -2921,6 +2928,7 @@ AC_SUBST(sitearch)dnl
+ AC_SUBST(sitearchdir)dnl
+ AC_SUBST(vendordir)dnl
+ AC_SUBST(vendorarchdir)dnl
++AC_SUBST(rubygemsdir)dnl
+ 
+ configure_args=$ac_configure_args
+ AC_SUBST(configure_args)dnl
+diff --git a/tool/mkconfig.rb b/tool/mkconfig.rb
+index b707c4b..9fecbfb 100755
+--- a/tool/mkconfig.rb
++++ b/tool/mkconfig.rb
+@@ -84,6 +84,7 @@ File.foreach "config.status" do |line|
+     when /^sitearchdir$/; sitearchdir_override = val; next
+     when /^vendorarchdir$/; vendorarchdir_override = val; next
+     when /^sitearch/; val = '$(arch)' if val.empty?
++    when /^rubygemsdir/; next if val.empty?
+     end
+     case val
+     when /^\$\(ac_\w+\)$/; next
+diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
+index 6bfc73e..31dc446 100755
+--- a/tool/rbinstall.rb
++++ b/tool/rbinstall.rb
+@@ -300,6 +300,7 @@ sitelibdir = CONFIG["sitelibdir"]
+ sitearchlibdir = CONFIG["sitearchdir"]
+ vendorlibdir = CONFIG["vendorlibdir"]
+ vendorarchlibdir = CONFIG["vendorarchdir"]
++rubygemsdir = CONFIG["rubygemsdir"]
+ mandir = CONFIG["mandir"]
+ capidir = CONFIG["docdir"]
+ configure_args = Shellwords.shellwords(CONFIG["configure_args"])
+@@ -487,7 +488,15 @@ end
+ install?(:local, :comm, :lib) do
+   prepare "library scripts", rubylibdir
+   noinst = %w[README* *.txt *.rdoc]
++  noinst += %w[*ubygems.rb rubygems/ datadir.rb] if rubygemsdir
+   install_recursive(File.join(srcdir, "lib"), rubylibdir, :no_install => noinst, :mode => $data_mode)
++  if rubygemsdir
++    noinst = %w[obsolete.rb]
++    install_recursive(File.join(srcdir, "lib", "rubygems"), File.join(rubygemsdir, "rubygems"), :mode => $data_mode)
++    install_recursive(File.join(srcdir, "lib", "rbconfig"), File.join(rubygemsdir, "rbconfig"), :no_install => noinst, :mode => $data_mode)
++    install(File.join(srcdir, "lib", "ubygems.rb"), File.join(rubygemsdir, "ubygems.rb"), :mode => $data_mode)
++    install(File.join(srcdir, "lib", "rubygems.rb"), File.join(rubygemsdir, "rubygems.rb"), :mode => $data_mode)
++  end
+ end
+ 
+ install?(:local, :arch, :lib) do
+diff --git a/version.c b/version.c
+index 59d4e5e..12ba7e9 100644
+--- a/version.c
++++ b/version.c
+@@ -103,6 +103,10 @@ const char ruby_initial_load_paths[] =
+ #endif
+ #endif
+ 
++#ifdef RUBYGEMS_DIR
++    RUBYGEMS_DIR "\0"
++#endif
++
+     RUBY_LIB "\0"
+ #ifdef RUBY_THIN_ARCHLIB
+     RUBY_THIN_ARCHLIB "\0"
+-- 
+1.7.7
+
diff --git a/ruby-1.9.3-disable-versioned-paths.patch b/ruby-1.9.3-disable-versioned-paths.patch
new file mode 100644
index 0000000..afafb04
--- /dev/null
+++ b/ruby-1.9.3-disable-versioned-paths.patch
@@ -0,0 +1,149 @@
+From fa1a50ad10814f724b8713865dc222724cb955ab Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch at redhat.com>
+Date: Thu, 25 Aug 2011 14:33:51 +0200
+Subject: [PATCH] Allow to disable versioned paths.
+
+---
+ configure.in     |   11 +++++++++++
+ tool/mkconfig.rb |    9 ++++++---
+ version.c        |   10 ++++++++++
+ 3 files changed, 27 insertions(+), 3 deletions(-)
+
+diff --git a/configure.in b/configure.in
+index e742e74..86cb68f 100644
+--- a/configure.in
++++ b/configure.in
+@@ -2953,6 +2953,17 @@ else
+ fi
+ AC_SUBST(USE_RUBYGEMS)
+ 
++AC_ARG_ENABLE(versioned-paths,
++	AS_HELP_STRING([--disable-versioned-paths], [disable paths with version number]),
++	[enable_versioned_paths="$enableval"], [enable_versioned_paths=yes])
++if test x"$enable_versioned_paths" = xno; then
++    AC_DEFINE(DISABLE_VERSIONED_PATHS, 1)
++    USE_VERSIONED_PATHS=NO
++else
++    USE_VERSIONED_PATHS=YES
++fi
++AC_SUBST(USE_VERSIONED_PATHS)
++
+ arch_hdrdir="${EXTOUT}/include/${arch}/ruby"
+ AS_MKDIR_P("${arch_hdrdir}")
+ config_h="${arch_hdrdir}/config.h"
+diff --git a/tool/mkconfig.rb b/tool/mkconfig.rb
+index a2221f0..47d8c8f 100755
+--- a/tool/mkconfig.rb
++++ b/tool/mkconfig.rb
+@@ -42,6 +42,7 @@ v_others = []
+ vars = {}
+ continued_name = nil
+ continued_line = nil
++path_version = "/$(ruby_version)"
+ File.foreach "config.status" do |line|
+   next if /^#/ =~ line
+   name = nil
+@@ -138,6 +139,8 @@ File.foreach "config.status" do |line|
+     case name
+     when "ruby_version"
+       version = val[/\A"(.*)"\z/, 1]
++    when /^USE_VERSIONED_PATHS$/
++      path_version = nil if /NO/ =~ val
+     end
+   end
+ #  break if /^CEOF/
+@@ -203,15 +206,15 @@ end
+ print(*v_fast)
+ print(*v_others)
+ print <<EOS
+-  CONFIG["rubylibdir"] = "$(rubylibprefix)/$(ruby_version)"
++  CONFIG["rubylibdir"] = "$(rubylibprefix)#{path_version}"
+   CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
+ EOS
+ print <<EOS unless v_disabled["sitedir"]
+-  CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"
++  CONFIG["sitelibdir"] = "$(sitedir)#{path_version}"
+   CONFIG["sitearchdir"] = "$(sitelibdir)/$(sitearch)"
+ EOS
+ print <<EOS unless v_disabled["vendordir"]
+-  CONFIG["vendorlibdir"] = "$(vendordir)/$(ruby_version)"
++  CONFIG["vendorlibdir"] = "$(vendordir)#{path_version}"
+   CONFIG["vendorarchdir"] = "$(vendorlibdir)/$(sitearch)"
+ EOS
+ print <<EOS
+diff --git a/version.c b/version.c
+index 59d4e5e..641dc33 100644
+--- a/version.c
++++ b/version.c
+@@ -38,9 +38,15 @@
+ #define RUBY_VENDOR_LIB RUBY_LIB_PREFIX"/vendor_ruby"
+ #endif
+ 
++#ifdef DISABLE_VERSIONED_PATHS
++#define RUBY_LIB                    RUBY_LIB_PREFIX
++#define RUBY_SITE_LIB2              RUBY_SITE_LIB
++#define RUBY_VENDOR_LIB2            RUBY_VENDOR_LIB
++#else
+ #define RUBY_LIB                    RUBY_LIB_PREFIX  "/"RUBY_LIB_VERSION
+ #define RUBY_SITE_LIB2              RUBY_SITE_LIB    "/"RUBY_LIB_VERSION
+ #define RUBY_VENDOR_LIB2            RUBY_VENDOR_LIB  "/"RUBY_LIB_VERSION
++#endif
+ #define RUBY_ARCHLIB                RUBY_LIB         "/"RUBY_ARCH
+ #define RUBY_SITE_ARCHLIB           RUBY_SITE_LIB2   "/"RUBY_SITEARCH
+ #define RUBY_VENDOR_ARCHLIB         RUBY_VENDOR_LIB2 "/"RUBY_SITEARCH
+@@ -75,8 +81,10 @@ const char ruby_initial_load_paths[] =
+     RUBY_SITE_THIN_ARCHLIB "\0"
+ #endif
+     RUBY_SITE_ARCHLIB "\0"
++#ifndef DISABLE_VERSIONED_PATHS
+     RUBY_SITE_LIB "\0"
+ #endif
++#endif
+ 
+ #ifndef NO_RUBY_VENDOR_LIB
+     RUBY_VENDOR_LIB2 "\0"
+@@ -84,8 +92,10 @@ const char ruby_initial_load_paths[] =
+     RUBY_VENDOR_THIN_ARCHLIB "\0"
+ #endif
+     RUBY_VENDOR_ARCHLIB "\0"
++#ifndef DISABLE_VERSIONED_PATHS
+     RUBY_VENDOR_LIB "\0"
+ #endif
++#endif
+ 
+     RUBY_LIB "\0"
+ #ifdef RUBY_THIN_ARCHLIB
+-- 
+1.7.7.3
+diff --git a/lib/rdoc/ri/paths.rb b/lib/rdoc/ri/paths.rb
+index a3c65bf..0575730 100644
+--- a/lib/rdoc/ri/paths.rb
++++ b/lib/rdoc/ri/paths.rb
+@@ -11,9 +11,9 @@ module RDoc::RI::Paths
+   version = RbConfig::CONFIG['ruby_version']
+ 
+   base    = if RbConfig::CONFIG.key? 'ridir' then
+-              File.join RbConfig::CONFIG['ridir'], version
++              File.join [RbConfig::CONFIG['ridir'], RbConfig::CONFIG['USE_VERSIONED_PATHS'] == 'YES' ? version : nil].compact
+             else
+-              File.join RbConfig::CONFIG['datadir'], 'ri', version
++              File.join [RbConfig::CONFIG['datadir'], 'ri', RbConfig::CONFIG['USE_VERSIONED_PATHS'] == 'YES' ? version : nil].compact
+             end
+ 
+   SYSDIR  = File.join base, "system"
+diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
+index cec8c9f..fed14d2 100755
+--- a/tool/rbinstall.rb
++++ b/tool/rbinstall.rb
+@@ -379,7 +379,7 @@ end
+ 
+ install?(:doc, :rdoc) do
+   if $rdocdir
+-    ridatadir = File.join(CONFIG['ridir'], CONFIG['ruby_version'], "system")
++    ridatadir = File.join([CONFIG['ridir'], RbConfig::CONFIG['USE_VERSIONED_PATHS'] == 'YES' ? version : nil, "system"].compact)
+     prepare "rdoc", ridatadir
+     install_recursive($rdocdir, ridatadir, :mode => $data_mode)
+   end
+-- 
+1.7.6
+
diff --git a/ruby-1.9.3-fix-json-parser.patch b/ruby-1.9.3-fix-json-parser.patch
new file mode 100644
index 0000000..9621c72
--- /dev/null
+++ b/ruby-1.9.3-fix-json-parser.patch
@@ -0,0 +1,40 @@
+diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c
+index d1d14c7..1773616 100644
+--- a/ext/json/parser/parser.c
++++ b/ext/json/parser/parser.c
+@@ -1293,6 +1293,7 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
+ {
+     char *p = string, *pe = string, *unescape;
+     int unescape_len;
++    char buf[4];
+ 
+     while (pe < stringEnd) {
+         if (*pe == '\\') {
+@@ -1325,7 +1326,6 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
+                     if (pe > stringEnd - 4) {
+                         return Qnil;
+                     } else {
+-                        char buf[4];
+                         UTF32 ch = unescape_unicode((unsigned char *) ++pe);
+                         pe += 3;
+                         if (UNI_SUR_HIGH_START == (ch & 0xFC00)) {
+diff --git a/ext/json/parser/parser.rl b/ext/json/parser/parser.rl
+index e7d47e1..33e775c 100644
+--- a/ext/json/parser/parser.rl
++++ b/ext/json/parser/parser.rl
+@@ -393,6 +393,7 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
+ {
+     char *p = string, *pe = string, *unescape;
+     int unescape_len;
++    char buf[4];
+ 
+     while (pe < stringEnd) {
+         if (*pe == '\\') {
+@@ -425,7 +426,6 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
+                     if (pe > stringEnd - 4) {
+                         return Qnil;
+                     } else {
+-                        char buf[4];
+                         UTF32 ch = unescape_unicode((unsigned char *) ++pe);
+                         pe += 3;
+                         if (UNI_SUR_HIGH_START == (ch & 0xFC00)) {
diff --git a/ruby-1.9.3-fix-s390x-build.patch b/ruby-1.9.3-fix-s390x-build.patch
new file mode 100644
index 0000000..d0ade91
--- /dev/null
+++ b/ruby-1.9.3-fix-s390x-build.patch
@@ -0,0 +1,12 @@
+diff -up ruby-1.9.3-p0/ext/tk/extconf.rb.orig ruby-1.9.3-p0/ext/tk/extconf.rb
+--- ruby-1.9.3-p0/ext/tk/extconf.rb.orig	2011-06-29 16:11:19.000000000 +0200
++++ ruby-1.9.3-p0/ext/tk/extconf.rb	2011-10-18 16:15:59.406299659 +0200
+@@ -114,7 +114,7 @@ def is_macosx?
+ end
+ 
+ def maybe_64bit?
+-  /64|universal/ =~ RUBY_PLATFORM
++  /64|universal|s390x/ =~ RUBY_PLATFORM
+ end
+ 
+ def check_tcltk_version(version)
diff --git a/ruby-1.9.3-prevent-optimizing-sp.patch b/ruby-1.9.3-prevent-optimizing-sp.patch
new file mode 100644
index 0000000..085d7f8
--- /dev/null
+++ b/ruby-1.9.3-prevent-optimizing-sp.patch
@@ -0,0 +1,53 @@
+Index: ChangeLog
+===================================================================
+--- ChangeLog	(revision 34277)
++++ ChangeLog	(revision 34278)
+@@ -1,3 +1,13 @@
++Thu Jan 12 13:51:00 2012  NARUSE, Yui  <naruse at ruby-lang.org>
++
++	* cont.c (cont_restore_0): prevent optimizing out `sp'. sp is used for
++	  reserving a memory space with ALLOCA_N for restoring machine stack
++	  stored in cont->machine_stack, but clang optimized out it (and
++	  maybe #5851 is also caused by this).
++	  This affected TestContinuation#test_check_localvars.
++
++	* cont.c (cont_restore_1): revert workaround introduced in r32201.
++
+ Mon Oct 10 22:33:12 2011  KOSAKI Motohiro  <kosaki.motohiro at gmail.com>
+ 
+ 	* test/-ext-/old_thread_select/test_old_thread_select.rb:
+Index: cont.c
+===================================================================
+--- cont.c	(revision 34277)
++++ cont.c	(revision 34278)
+@@ -669,10 +669,9 @@
+     }
+ #endif
+     if (cont->machine_stack_src) {
+-	size_t i;
+ 	FLUSH_REGISTER_WINDOWS;
+-	for (i = 0; i < cont->machine_stack_size; i++)
+-	    cont->machine_stack_src[i] = cont->machine_stack[i];
++	MEMCPY(cont->machine_stack_src, cont->machine_stack,
++		VALUE, cont->machine_stack_size);
+     }
+ 
+ #ifdef __ia64
+@@ -742,7 +741,7 @@
+ 	    if (&space[0] > end) {
+ # ifdef HAVE_ALLOCA
+ 		volatile VALUE *sp = ALLOCA_N(VALUE, &space[0] - end);
+-		(void)sp;
++		space[0] = *sp;
+ # else
+ 		cont_restore_0(cont, &space[0]);
+ # endif
+@@ -758,7 +757,7 @@
+ 	    if (&space[STACK_PAD_SIZE] < end) {
+ # ifdef HAVE_ALLOCA
+ 		volatile VALUE *sp = ALLOCA_N(VALUE, end - &space[STACK_PAD_SIZE]);
+-		(void)sp;
++		space[0] = *sp;
+ # else
+ 		cont_restore_0(cont, &space[STACK_PAD_SIZE-1]);
+ # endif
diff --git a/ruby-1.9.3-rubygems-1.8.11-uninstaller.patch b/ruby-1.9.3-rubygems-1.8.11-uninstaller.patch
new file mode 100644
index 0000000..af1cff2
--- /dev/null
+++ b/ruby-1.9.3-rubygems-1.8.11-uninstaller.patch
@@ -0,0 +1,76 @@
+--- ruby-1.9.3-p0/lib/rubygems/uninstaller.rb.orig	2011-10-31 10:22:36.321579483 +0100
++++ ruby-1.9.3-p0/lib/rubygems/uninstaller.rb	2011-10-31 10:34:25.563626119 +0100
+@@ -51,15 +51,14 @@
+     @bin_dir           = options[:bin_dir]
+     @format_executable = options[:format_executable]
+ 
++    if options[:force]
++      @force_all = true
++      @force_ignore = true
++    end
++
+     # only add user directory if install_dir is not set
+     @user_install = false
+     @user_install = options[:user_install] unless options[:install_dir]
+-
+-    if @user_install then
+-      Gem.use_paths Gem.user_dir, @gem_home
+-    else
+-      Gem.use_paths @gem_home
+-    end
+   end
+ 
+   ##
+@@ -69,10 +68,24 @@
+   def uninstall
+     list = Gem::Specification.find_all_by_name(@gem, @version)
+ 
++    list, other_repo_specs = list.partition do |spec|
++      @gem_home == spec.base_dir or
++      (@user_install and spec.base_dir == Gem.user_dir)
++    end
++
+     if list.empty? then
+-      raise Gem::InstallError, "gem #{@gem.inspect} is not installed"
++      raise Gem::InstallError, "gem #{@gem.inspect} is not installed" if
++        other_repo_specs.empty?
++
++      other_repos = other_repo_specs.map { |spec| spec.base_dir }.uniq
++
++      message = ["#{@gem} is not installed in GEM_HOME, try:"]
++      message.concat other_repos.map { |repo|
++        "\tgem uninstall -i #{repo} #{@gem}"
++      }
+ 
+-    elsif list.size > 1 and @force_all then
++      raise Gem::InstallError, message.join("\n")
++    elsif @force_all then
+       remove_all list
+ 
+     elsif list.size > 1 then
+@@ -250,12 +263,10 @@
+     msg << "\t#{spec.full_name}"
+ 
+     spec.dependent_gems.each do |dep_spec, dep, satlist|
+-      msg <<
+-        ("#{dep_spec.name}-#{dep_spec.version} depends on " +
+-         "[#{dep.name} (#{dep.requirement})]")
++      msg << "#{dep_spec.name}-#{dep_spec.version} depends on #{dep}"
+     end
+ 
+-    msg << 'If you remove this gems, one or more dependencies will not be met.'
++    msg << 'If you remove this gem, one or more dependencies will not be met.'
+     msg << 'Continue with Uninstall?'
+     return ask_yes_no(msg.join("\n"), true)
+   end
+
+--- ruby-1.9.3-p0/test/rubygems/test_gem_uninstaller.rb.orig	2011-11-03 08:58:31.411272176 +0100
++++ ruby-1.9.3-p0/test/rubygems/test_gem_uninstaller.rb	2011-11-03 08:58:43.010272351 +0100
+@@ -225,7 +225,7 @@
+ 
+     uninstaller = Gem::Uninstaller.new('a')
+ 
+-    use_ui Gem::MockGemUi.new("2\n") do
++    use_ui Gem::MockGemUi.new("2\ny\n") do
+       uninstaller.uninstall
+     end
diff --git a/ruby-1.9.3-webrick-test-fix.patch b/ruby-1.9.3-webrick-test-fix.patch
new file mode 100644
index 0000000..c6eb3fa
--- /dev/null
+++ b/ruby-1.9.3-webrick-test-fix.patch
@@ -0,0 +1,24 @@
+diff --git a/test/webrick/test_cgi.rb b/test/webrick/test_cgi.rb
+index 1185316..0ef1b37 100644
+--- a/test/webrick/test_cgi.rb
++++ b/test/webrick/test_cgi.rb
+@@ -14,6 +14,7 @@ class TestWEBrickCGI < Test::Unit::TestCase
+         def req.meta_vars
+           meta = super
+           meta["RUBYLIB"] = $:.join(File::PATH_SEPARATOR)
++          meta[RbConfig::CONFIG['LIBPATHENV']] = ENV[RbConfig::CONFIG['LIBPATHENV']]
+           return meta
+         end
+       },
+diff --git a/test/webrick/test_filehandler.rb b/test/webrick/test_filehandler.rb
+index bcdb3df..f78ba5c 100644
+--- a/test/webrick/test_filehandler.rb
++++ b/test/webrick/test_filehandler.rb
+@@ -252,6 +252,7 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase
+         def req.meta_vars
+           meta = super
+           meta["RUBYLIB"] = $:.join(File::PATH_SEPARATOR)
++          meta[RbConfig::CONFIG['LIBPATHENV']] = ENV[RbConfig::CONFIG['LIBPATHENV']]
+           return meta
+         end
+       },
diff --git a/ruby.spec b/ruby.spec
index be7066a..a8c8bf2 100644
--- a/ruby.spec
+++ b/ruby.spec
@@ -1,82 +1,109 @@
-%global	rubyxver	1.8
-%global	rubyver	1.8.7
-%global	_patchlevel	357
-
-%global	dotpatchlevel	%{?_patchlevel:.%{_patchlevel}}
-%global	patchlevel	%{?_patchlevel:-p%{_patchlevel}}
-%global	arcver		%{rubyver}%{?patchlevel}
-
-%{!?vendorlibbase:	%global vendorlibbase	%{_prefix}/lib/ruby}
-%{!?vendorarchbase:	%global vendorarchbase	%{_libdir}/ruby}
-%{!?sitelibbase:	%global sitelibbase	%{vendorlibbase}/site_ruby}
-%{!?sitearchbase:	%global sitearchbase	%{vendorarchbase}/site_ruby}
-
-%global	_normalized_cpu	%(echo %{_target_cpu} | sed 's/^ppc/powerpc/;s/i.86/i386/;s/sparcv./sparc/')
-# Fri Jul 15 21:28:10 2011 +0000
-%global	ruby_tk_git_revision	c2dfaa7d40531aef3706bcc16f38178b0c6633ee
-
-Name:		ruby
-Version:	%{rubyver}%{?dotpatchlevel}
-Release:	2%{?dist}
-# Please check if ruby upstream changes this to "Ruby or GPLv2+"
-License:	Ruby or GPLv2
-URL:		http://www.ruby-lang.org/
-
-BuildRequires:	compat-readline5-devel
-BuildRequires:	db4-devel
-%if 0%{?fedora} < 17
-BuildRequires:	gdbm-devel
-%endif
-BuildRequires:	libX11-devel
-BuildRequires:	ncurses-devel
-BuildRequires:	openssl-devel
-BuildRequires:	tcl-devel
-BuildRequires:	tk-devel
-
-BuildRequires:	autoconf
-BuildRequires:	bison
-BuildRequires:	byacc
-
-# Official ruby source release tarball
-Source0:	ftp://ftp.ruby-lang.org/pub/%{name}/%{rubyxver}/%{name}-%{arcver}.tar.bz2
-
-# Source100: contains ext/tk directory of the ruby source head
-# see http://lists.fedoraproject.org/pipermail/ruby-sig/2010-May/000096.html 
-# and bug 560053, 590503.
-# To checkout, run the following commands
-# (replacing 'ruby_tk_git_revision' with the value of the macro above):
-# *  git clone http://github.com/ruby/ruby.git
-# *  cd ruby
-# *  git checkout %%{ruby_tk_git_revision} ext/tk
-# *  tar czvf ruby-rev%%{ruby_tk_git_revision}-ext_tk.tar.gz ext/tk
-Source100:	ruby-rev%{ruby_tk_git_revision}-ext_tk.tar.gz
-
-# Patches 23, 29, and 33 brought over from ruby 1.8.6
-#  (updated to apply against 1.8.7 source)
-# If building against a 64bit arch, use 64bit libdir
-Patch23:	ruby-1.8.7-p330-multilib.patch
-# Mark all i.86 arch's (eg i586, i686, etc) as i386
-Patch29:	ruby-1.8.7-always-use-i386.patch
-# Use shared libs as opposed to static for mkmf
-# See bug 428384
-Patch33:	ruby-1.8.7-p249-mkmf-use-shared.patch
-# Remove duplicate path entry
-# bug 718695
-Patch34:	ruby-1.8.7-p352-path-uniq.patch
-# Change ruby load path to conform to Fedora/ruby
-# library placement (various 1.8.6 patches consolidated into this)
-Patch100:	ruby-1.8.7-lib-paths.patch
-
-Summary:	An interpreter of object-oriented scripting language
-Group:		Development/Languages
-Requires:	%{name}-libs%{?_isa} = %{version}-%{release}
-
-# emacs-23.2.x itself now provides the ruby mode
-# And no Provides here
-Obsoletes:	%{name}-mode < 1.8.7
-# remove old documentation
-# And no Provides here
-Obsoletes:	%{name}-docs < 1.8.7
+%global major_version 1
+%global minor_version 9
+%global teeny_version 3
+%global patch_level 0
+
+%global major_minor_version %{major_version}.%{minor_version}
+
+%global ruby_version %{major_minor_version}.%{teeny_version}
+%global ruby_version_patch_level %{major_minor_version}.%{teeny_version}.%{patch_level}
+%global ruby_abi %{major_minor_version}.1
+
+%global ruby_archive %{name}-%{ruby_version}-p%{patch_level}
+
+%global ruby_libdir %{_datadir}/%{name}
+%global ruby_libarchdir %{_libdir}/%{name}
+
+# This is the local lib/arch and should not be used for packaging.
+%global ruby_sitedir site_ruby
+%global ruby_sitelibdir %{_prefix}/local/share/ruby/%{ruby_sitedir}
+%global ruby_sitearchdir %{_prefix}/local/%{_lib}/ruby/%{ruby_sitedir}
+
+# This is the general location for libs/archs compatible with all
+# or most of the Ruby versions available in the Fedora repositories.
+%global ruby_vendordir vendor_ruby
+%global ruby_vendorlibdir %{_datadir}/ruby/%{ruby_vendordir}
+%global ruby_vendorarchdir %{_libdir}/ruby/%{ruby_vendordir}
+
+%global rubygems_version 1.8.11
+
+# The RubyGems library has to stay out of Ruby directory three, since the
+# RubyGems should be share by all Ruby implementations.
+%global rubygems_dir %{_datadir}/rubygems
+
+# Specify custom RubyGems root.
+%global gem_dir %{_datadir}/gems
+# TODO: Should we create arch specific rubygems-filesystem?
+%global gem_extdir %{_exec_prefix}/lib{,64}/gems
+
+%global rake_version 0.9.2.2
+# TODO: The IRB has strange versioning. Keep the Ruby's versioning ATM.
+# http://redmine.ruby-lang.org/issues/5313
+%global irb_version %{ruby_version_patch_level}
+%global rdoc_version 3.9.4
+%global bigdecimal_version 1.1.0
+%global io_console_version 0.3
+%global json_version 1.5.4
+%global minitest_version 2.5.1
+
+%global	_normalized_cpu	%(echo %{_target_cpu} | sed 's/^ppc/powerpc/;s/i.86/i386/;s/sparcv./sparc/;s/armv.*/arm/')
+
+Summary: An interpreter of object-oriented scripting language
+Name: ruby
+Version: %{ruby_version_patch_level}
+Release: 5%{?dist}
+Group: Development/Languages
+License: Ruby or BSD
+URL: http://ruby-lang.org/
+Source0: ftp://ftp.ruby-lang.org/pub/%{name}/%{major_minor_version}/%{ruby_archive}.tar.gz
+Source1: operating_system.rb
+
+# http://redmine.ruby-lang.org/issues/5231
+Patch0: ruby-1.9.3-disable-versioned-paths.patch
+# TODO: Should be submitted upstream?
+Patch1: ruby-1.9.3-arch-specific-dir.patch
+# http://redmine.ruby-lang.org/issues/5281
+Patch2: ruby-1.9.3-added-site-and-vendor-arch-flags.patch
+# Force multiarch directories for i.86 to be always named i386. This solves
+# some differencies in build between Fedora and RHEL.
+Patch3: ruby-1.9.3-always-use-i386.patch
+# http://redmine.ruby-lang.org/issues/5465
+Patch4: ruby-1.9.3-fix-s390x-build.patch
+# Fix the uninstaller, so that it doesn't say that gem doesn't exist
+# when it exists outside of the GEM_HOME (already fixed in the upstream)
+Patch5: ruby-1.9.3-rubygems-1.8.11-uninstaller.patch
+# http://redmine.ruby-lang.org/issues/5135 - see comment 29
+Patch6: ruby-1.9.3-webrick-test-fix.patch
+# Already fixed upstream:
+# https://github.com/ruby/ruby/commit/f212df564a4e1025f9fb019ce727022a97bfff53
+Patch7: ruby-1.9.3-bignum-test-fix.patch
+# Allows to install RubyGems into custom directory, outside of Ruby's tree.
+# http://redmine.ruby-lang.org/issues/5617
+Patch8: ruby-1.9.3-custom-rubygems-location.patch
+# Add support for installing binary extensions according to FHS.
+# https://github.com/rubygems/rubygems/issues/210
+Patch9: rubygems-1.8.11-binary-extensions.patch
+# Fixes segfaults when build with GCC 4.7.
+# http://bugs.ruby-lang.org/issues/5851
+Patch10: ruby-1.9.3-prevent-optimizing-sp.patch
+# Fixes json encoding failures when build with GCC 4.7.
+# http://bugs.ruby-lang.org/issues/5888
+Patch11: ruby-1.9.3-fix-json-parser.patch
+
+Requires: %{name}-libs%{?_isa} = %{version}-%{release}
+Requires: ruby(rubygems) >= %{rubygems_version}
+
+BuildRequires: autoconf
+BuildRequires: gdbm-devel
+BuildRequires: ncurses-devel
+BuildRequires: db4-devel
+BuildRequires: libffi-devel
+BuildRequires: openssl-devel
+BuildRequires: libyaml-devel
+BuildRequires: readline-devel
+BuildRequires: tk-devel
+# Needed to pass test_set_program_name(TestRubyOptions)
+BuildRequires: procps
 
 %description
 Ruby is the interpreted scripting language for quick and easy
@@ -85,465 +112,618 @@ files and to do system management tasks (as in Perl).  It is simple,
 straight-forward, and extensible.
 
 
-%package	libs
-Summary:	Libraries necessary to run Ruby
-Group:		Development/Libraries
-# ext/bigdecimal/bigdecimal.{c,h} are under (GPL+ or Artistic) which
-# are used for bigdecimal.so
-License:	(Ruby or GPLv2) and (GPL+ or Artistic)
-Provides:	ruby(abi) = %{rubyxver}
-Provides:	libruby = %{version}-%{release}
-Obsoletes:	libruby < %{version}-%{release}
+%package devel
+Summary:    A Ruby development environment
+Group:      Development/Languages
+# Requires:   %{name}-libs = %{version}-%{release}
+Requires:   %{name}%{?_isa} = %{version}-%{release}
 
-%description libs
-This package includes the libruby, necessary to run Ruby.
-
-
-%package	devel
-Summary:	A Ruby development environment
-Group:		Development/Languages
-Requires:	%{name}-libs%{?_isa} = %{version}-%{release}
+%description devel
+Header files and libraries for building an extension library for the
+Ruby or an application embedding Ruby.
 
-%description	devel
-Header files and libraries for building a extension library for the
-Ruby or an application embedded Ruby.
+%package libs
+Summary:    Libraries necessary to run Ruby
+Group:      Development/Libraries
+License:    Ruby or BSD
+Provides:   ruby(abi) = %{ruby_abi}
 
-%package	static
-Summary:	Static libraries for Ruby development environment
-Group:		Development/Languages
-Requires:	%{name}-devel%{?_isa} = %{version}-%{release}
-
-%description	static
-Static libraries for for building a extension library for the
-Ruby or an application embedded Ruby.
+%description libs
+This package includes the libruby, necessary to run Ruby.
 
-%package	irb
-Summary:	The Interactive Ruby
-Group:		Development/Languages
-# No isa specific
-Requires:	%{name} = %{version}-%{release}
-Provides:	irb = %{version}-%{release}
-Obsoletes:	irb < %{version}-%{release}
-BuildArch:	noarch
+# TODO: Rename or not rename to ruby-rubygems?
+%package -n rubygems
+Summary:    The Ruby standard for packaging ruby libraries
+Version:    %{rubygems_version}
+Group:      Development/Libraries
+License:    Ruby or MIT
+Requires:   ruby(abi) = %{ruby_abi}
+Requires:   rubygem(rdoc) = %{rdoc_version}
+Requires:   rubygem(io-console) = %{io_console_version}
+Provides:   gem = %{version}-%{release}
+Provides:   ruby(rubygems) = %{version}-%{release}
+BuildArch:  noarch
+
+%description -n rubygems
+RubyGems is the Ruby standard for publishing and managing third party
+libraries.
+
+
+%package -n rubygems-devel
+Summary:    Macros and development tools for packagin RubyGems
+Version:    %{rubygems_version}
+Group:      Development/Libraries
+License:    Ruby or MIT
+Requires:   ruby(rubygems) = %{version}-%{release}
+BuildArch:  noarch
+
+%description -n rubygems-devel
+Macros and development tools for packagin RubyGems.
+
+
+%package -n rubygem-rake
+Summary:    Ruby based make-like utility
+Version:    %{rake_version}
+Group:      Development/Libraries
+License:    Ruby or MIT
+Requires:   ruby(abi) = %{ruby_abi}
+Requires:   ruby(rubygems) = %{rubygems_version}
+Provides:   rake = %{version}-%{release}
+Provides:   rubygem(rake) = %{version}-%{release}
+BuildArch:  noarch
+
+%description -n rubygem-rake
+Rake is a Make-like program implemented in Ruby. Tasks and dependencies are
+specified in standard Ruby syntax.
+
+
+%package irb
+Summary:    The Interactive Ruby
+Version:    %{irb_version}
+Group:      Development/Libraries
+Requires:   %{name}-libs = %{ruby_version_patch_level}
+Provides:   irb = %{version}-%{release}
+Provides:   ruby(irb) = %{version}-%{release}
+BuildArch:  noarch
 
 %description irb
 The irb is acronym for Interactive Ruby.  It evaluates ruby expression
 from the terminal.
 
 
-%package	rdoc
-Summary:	A tool to generate documentation from Ruby source files
-Group:		Development/Languages
-# generators/template/html/html.rb is under CC-BY
-License:	(GPLv2 or Ruby) and CC-BY
-# No isa specific
-Requires:	%{name}-irb = %{version}-%{release}
-Provides:	rdoc = %{version}-%{release}
-Obsoletes:	rdoc < %{version}-%{release}
-BuildArch:	noarch
-
-%description rdoc
-The rdoc is a tool to generate the documentation from Ruby source files.
-It supports some output formats, like HTML, Ruby interactive reference (ri),
-XML and Windows Help file (chm).
-
-
-%package	ri
-Summary:	Ruby interactive reference
-Group:		Documentation
-## ruby-irb requires ruby, which ruby-rdoc requires
-#Requires: %%{name} = %%{version}-%%{release}
-# No isa specific
-Requires:	%{name}-rdoc = %{version}-%{release}
-Provides:	ri = %{version}-%{release}
-Obsoletes:	ri < %{version}-%{release}
-# FIXME: Make ruby-ri really arch independent
-# BuildArch:	noarch # Currently commented out
-
-%description ri
-ri is a command line tool that displays descriptions of built-in
-Ruby methods, classes and modules. For methods, it shows you the calling
-sequence and a description. For classes and modules, it shows a synopsis
-along with a list of the methods the class or module implements.
-
-##
-## ruby-tcltk
-##
-%package	tcltk
-Summary:	Tcl/Tk interface for scripting language Ruby
-Group:		Development/Languages
-Requires:	%{name}-libs%{?_isa} = %{version}-%{release}
+%package -n rubygem-rdoc
+Summary:    A tool to generate HTML and command-line documentation for Ruby projects
+Version:    %{rdoc_version}
+Group:      Development/Libraries
+License:    GPLv2 and Ruby and MIT
+Requires:   ruby(abi) = %{ruby_abi}
+Requires:   ruby(rubygems) = %{rubygems_version}
+Requires:   ruby(irb) = %{irb_version}
+Provides:   rdoc = %{version}-%{release}
+Provides:   ri = %{version}-%{release}
+Provides:   rubygem(rdoc) = %{version}-%{release}
+Obsoletes:  ruby-rdoc < %{version}
+Obsoletes:  ruby-ri < %{version}
+# TODO: It seems that ri documentation differs from platform to platform due to
+# some encoding bugs, therefore the documentation should be split out of this gem
+# or kept platform specific.
+# https://github.com/rdoc/rdoc/issues/71
+# BuildArch:  noarch
+
+%description -n rubygem-rdoc
+RDoc produces HTML and command-line documentation for Ruby projects.  RDoc
+includes the 'rdoc' and 'ri' tools for generating and displaying online
+documentation.
+
+
+%package -n rubygem-bigdecimal
+Summary:    BigDecimal provides arbitrary-precision floating point decimal arithmetic
+Version:    %{bigdecimal_version}
+Group:      Development/Libraries
+License:    GPL+ or Artistic
+Requires:   ruby(abi) = %{ruby_abi}
+Requires:   ruby(rubygems) = %{rubygems_version}
+Provides:   rubygem(bigdecimal) = %{version}-%{release}
+
+%description -n rubygem-bigdecimal
+Ruby provides built-in support for arbitrary precision integer arithmetic.
+For example:
+
+42**13 -> 1265437718438866624512
+
+BigDecimal provides similar support for very large or very accurate floating
+point numbers. Decimal arithmetic is also useful for general calculation,
+because it provides the correct answers people expect–whereas normal binary
+floating point arithmetic often introduces subtle errors because of the
+conversion between base 10 and base 2.
+
+
+%package -n rubygem-io-console
+Summary:    IO/Console is a simple console utilizing library
+Version:    %{io_console_version}
+Group:      Development/Libraries
+Requires:   ruby(abi) = %{ruby_abi}
+Requires:   ruby(rubygems) = %{rubygems_version}
+Provides:   rubygem(io-console) = %{version}-%{release}
+
+%description -n rubygem-io-console
+IO/Console provides very simple and portable access to console. It doesn’t
+provide higher layer features, such like curses and readline.
+
+
+%package -n rubygem-json
+Summary:    This is a JSON implementation as a Ruby extension in C
+Version:    %{json_version}
+Group:      Development/Libraries
+License:    Ruby or GPLv2
+Requires:   ruby(abi) = %{ruby_abi}
+Requires:   ruby(rubygems) = %{rubygems_version}
+Provides:   rubygem(json) = %{version}-%{release}
+
+%description -n rubygem-json
+This is a implementation of the JSON specification according to RFC 4627.
+You can think of it as a low fat alternative to XML, if you want to store
+data to disk or transmit it over a network rather than use a verbose
+markup language.
+
+
+%package -n rubygem-minitest
+Summary:    Minitest provides a complete suite of testing facilities.
+Version:    %{minitest_version}
+Group:      Development/Libraries
+License:    MIT
+Requires:   ruby(abi) = %{ruby_abi}
+Requires:   ruby(rubygems) = %{rubygems_version}
+Provides:   rubygem(minitest) = %{version}-%{release}
+BuildArch:  noarch
+
+%description -n rubygem-minitest
+minitest/unit is a small and incredibly fast unit testing framework.
+
+minitest/spec is a functionally complete spec engine.
+
+minitest/benchmark is an awesome way to assert the performance of your
+algorithms in a repeatable manner.
+
+minitest/mock by Steven Baker, is a beautifully tiny mock object
+framework.
+
+minitest/pride shows pride in testing and adds coloring to your test
+output.
+
+
+%package tcltk
+Summary:    Tcl/Tk interface for scripting language Ruby
+Group:      Development/Languages
+Requires:   %{name}-libs%{?_isa} = %{ruby_version_patch_level}
+Provides:   ruby(tcltk) = %{ruby_version_patch_level}-%{release}
 
 %description tcltk
 Tcl/Tk interface for the object-oriented scripting language Ruby.
 
 %prep
-%setup -q -c -a 100
-pushd %{name}-%{arcver}
-%patch23 -p1
-%patch29 -p1
-%patch33 -p1
-%patch34 -p1
-%patch100 -p1
+%setup -q -n %{ruby_archive}
+
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
+%patch6 -p1
+%patch7 -p1
+%patch8 -p1
+%patch9 -p1
+%patch10
+%patch11 -p1
 
-( 
-	cd ext
-	rm -rf tk
-	cp -a ../../ext/tk tk
-	find tk -type d -name \.svn | sort -r | xargs rm -rf
+%build
+autoconf
 
-# Remove rpath
-	sed -i.rpath -e 's|-Wl,-R|-L|g' tk/extconf.rb
-) 
+%configure \
+        --with-rubylibprefix='%{ruby_libdir}' \
+        --with-archdir='%{ruby_libarchdir}' \
+        --with-sitedir='%{ruby_sitelibdir}' \
+        --with-sitearchdir='%{ruby_sitearchdir}' \
+        --with-vendordir='%{ruby_vendorlibdir}' \
+        --with-vendorarchdir='%{ruby_vendorarchdir}' \
+        --with-rubyhdrdir='%{_includedir}' \
+        --with-rubygemsdir='%{rubygems_dir}' \
+        --disable-rpath \
+        --enable-shared \
+        --disable-versioned-paths
+
+# Q= makes the build output more verbose and allows to check Fedora
+# compiler options.
+make %{?_smp_mflags} COPY="cp -p" Q=
 
-popd
 
-# Once fix FTBTS issue (bug 716021). Remove the below
-# when it is no longer needed.
-sed -i.redirect  -e '\@RUBY at s@\.rb >@\.rb | cat >@' %{name}-%{arcver}/ext/dl/depend
+%install
+rm -rf %{buildroot}
+make install DESTDIR=%{buildroot}
+
+# Dump the macros into macro.ruby to use them to build other Ruby libraries.
+mkdir -p %{buildroot}%{_sysconfdir}/rpm
+cat >> %{buildroot}%{_sysconfdir}/rpm/macros.ruby << \EOF
+%%ruby_libdir %{_datadir}/%{name}
+%%ruby_libarchdir %{_libdir}/%{name}
+
+# This is the local lib/arch and should not be used for packaging.
+%%ruby_sitedir site_ruby
+%%ruby_sitelibdir %{_prefix}/local/share/ruby/%{ruby_sitedir}
+%%ruby_sitearchdir %{_prefix}/local/%{_lib}/ruby/%{ruby_sitedir}
+
+# This is the general location for libs/archs compatible with all
+# or most of the Ruby versions available in the Fedora repositories.
+%%ruby_vendordir vendor_ruby
+%%ruby_vendorlibdir %{_datadir}/ruby/%{ruby_vendordir}
+%%ruby_vendorarchdir %{_libdir}/ruby/%{ruby_vendordir}
+EOF
 
-# Disable gdbm support on F-17 for now
-%if 0%{?fedora} >= 17
-sed -i '\@dblib =@s|gdbm[^ ]*||g' %{name}-%{arcver}/ext/dbm/extconf.rb
-%endif
+cat >> %{buildroot}%{_sysconfdir}/rpm/macros.rubygems << \EOF
+# The RubyGems root folder.
+%%gem_dir %{gem_dir}
+
+# Common gem locations and files.
+%%gem_instdir %%{gem_dir}/gems/%%{gem_name}-%%{version}
+%%gem_extdir %%{_libdir}/gems/exts/%%{gem_name}-%%{version}
+%%gem_libdir %%{gem_instdir}/lib
+%%gem_cache %%{gem_dir}/cache/%%{gem_name}-%%{version}.gem
+%%gem_spec %%{gem_dir}/specifications/%%{gem_name}-%%{version}.gemspec
+%%gem_docdir %%{gem_dir}/doc/%%{gem_name}-%%{version}
+EOF
 
+# Install custom operating_system.rb.
+mkdir -p %{buildroot}%{rubygems_dir}/rubygems/defaults
+cp %{SOURCE1} %{buildroot}%{rubygems_dir}/rubygems/defaults
 
-%build
-pushd %{name}-%{arcver}
-for i in config.sub config.guess; do
-	test -f %{_datadir}/libtool/$i && cp -p %{_datadir}/libtool/$i .
-done
-autoconf
+# Move gems root into common direcotry, out of Ruby directory structure.
+mv %{buildroot}%{ruby_libdir}/gems/%{ruby_abi} %{buildroot}%{gem_dir}
 
-rb_cv_func_strtod=no
-export rb_cv_func_strtod
+# Create folders for gem binary extensions.
+mkdir -p %{buildroot}%{gem_extdir}/exts
 
-# bug 489990
-CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing"
-export CFLAGS
+# Move bundled rubygems to %%gem_dir and %%gem_extdir
+mkdir -p %{buildroot}%{gem_dir}/gems/rake-%{rake_version}/lib
+mv %{buildroot}%{ruby_libdir}/rake* %{buildroot}%{gem_dir}/gems/rake-%{rake_version}/lib
 
-%configure \
-	--with-default-kcode=none \
-	--enable-shared \
-	--enable-pthread \
-	--disable-rpath \
-	--with-readline-include=%{_includedir}/readline5 \
-	--with-readline-lib=%{_libdir}/readline5 \
-	--with-sitedir='%{sitelibbase}' \
-	--with-sitearchdir='%{sitearchbase}' \
-	--with-vendordir='%{vendorlibbase}' \
-	--with-vendorarchdir='%{vendorarchbase}'
-
-# For example ext/socket/extconf.rb uses try_run (for getaddrinfo test),
-# which executes conftest and setting LD_LIBRARY_PATH for libruby.so is
-# needed.
-export LD_LIBRARY_PATH=$(pwd)
-
-make RUBY_INSTALL_NAME=ruby \
-	COPY="cp -p" \
-	%{?_smp_mflags}
-%ifarch ia64
-# Miscompilation? Buggy code?
-rm -f parse.o
-make OPT=-O0 RUBY_INSTALL_NAME=ruby \
-	%{?_smp_mflags}
-%endif
-
-# Avoid multilib conflict on -libs (bug 649174)
-# Maybe dlconfig.rb is unneeded anyway, however for now moving
-# dlconfig.rb and add wrapper (need checking)
-CONFIGARCH=$(./miniruby -rrbconfig -e "puts Config::CONFIG['arch']")
-[ -z "$CONFIGARCH" ] && exit 1
-pushd ext/dl
-mkdir $CONFIGARCH
-mv dlconfig.rb $CONFIGARCH/
-cat > dlconfig.rb <<EOF
-require 'rbconfig'
-dlconfig_path=File.join(File.dirname(__FILE__), Config::CONFIG['arch'], 'dlconfig')
-require dlconfig_path
-EOF
-popd
+mkdir -p %{buildroot}%{gem_dir}/gems/rdoc-%{rdoc_version}/lib
+mv %{buildroot}%{ruby_libdir}/rdoc* %{buildroot}%{gem_dir}/gems/rdoc-%{rdoc_version}/lib
 
+mkdir -p %{buildroot}%{gem_dir}/gems/bigdecimal-%{bigdecimal_version}/lib
+mkdir -p %{buildroot}%{_libdir}/gems/exts/bigdecimal-%{bigdecimal_version}/lib
+mv %{buildroot}%{ruby_libdir}/bigdecimal %{buildroot}%{gem_dir}/gems/bigdecimal-%{bigdecimal_version}/lib
+mv %{buildroot}%{ruby_libarchdir}/bigdecimal.so %{buildroot}%{_libdir}/gems/exts/bigdecimal-%{bigdecimal_version}/lib
 
-# Generate ri doc
-rm -rf .ext/rdoc
-rm -rf ./RI_TMPDIR
-mkdir ./RI_TMPDIR
-make \
-	DESTDIR=$(pwd)/RI_TMPDIR \
-	install-doc
+mkdir -p %{buildroot}%{gem_dir}/gems/io-console-%{io_console_version}/lib
+mkdir -p %{buildroot}%{_libdir}/gems/exts/io-console-%{io_console_version}/lib/io
+mv %{buildroot}%{ruby_libdir}/io %{buildroot}%{gem_dir}/gems/io-console-%{io_console_version}/lib
+mv %{buildroot}%{ruby_libarchdir}/io/console.so %{buildroot}%{_libdir}/gems/exts/io-console-%{io_console_version}/lib/io
 
-popd
+mkdir -p %{buildroot}%{gem_dir}/gems/json-%{json_version}/lib
+mkdir -p %{buildroot}%{_libdir}/gems/exts/json-%{json_version}/lib
+mv %{buildroot}%{ruby_libdir}/json* %{buildroot}%{gem_dir}/gems/json-%{json_version}/lib
+mv %{buildroot}%{ruby_libarchdir}/json/ %{buildroot}%{_libdir}/gems/exts/json-%{json_version}/lib/
 
-%check
-pushd %{name}-%{arcver}
-%ifarch ppc64
-make test || true
-%else
-make test
-%endif
-popd
+mkdir -p %{buildroot}%{gem_dir}/gems/minitest-%{minitest_version}/lib
+mv %{buildroot}%{ruby_libdir}/minitest %{buildroot}%{gem_dir}/gems/minitest-%{minitest_version}/lib
 
-%install
-# install documenation in tmp directory to be
-# picked up by %%doc macros in %%files sections
-rm -rf tmp-ruby-docs
-mkdir tmp-ruby-docs
-pushd tmp-ruby-docs
-
-mkdir \
-	ruby ruby-libs ruby-tcltk irb
-
-# First gather all samples
-cp -a  ../%{name}-%{arcver}/sample/ ruby
-cp -a \
-	../%{name}-%{arcver}/lib/README* ../%{name}-%{arcver}/doc/ \
-	ruby-libs
-# Use tar to keep directory hierarchy
-cd ruby-libs
-(
-	cd ../../%{name}-%{arcver} ; \
-	find ext \
-	-mindepth 1 \
-	\( -path '*/sample/*' -o -path '*/demo/*' \) -o \
-	\( -name '*.rb' -not -path '*/lib/*' -not -name extconf.rb \) -o \
-	\( -name 'README*' -o -name '*.txt*' -o -name 'MANUAL*' \) \
-	\
-	| xargs tar cf -
-) \
-	| tar xf -
-cd ..
-
-# make sure that all doc files are the world-readable 
-find -type f | xargs chmod 0644
-
-# Fix shebang
-grep -rl '#![ \t]*%{_prefix}/local/bin' . | \
-	xargs sed -i -e '1s|\(#![ \t]*\)%{_prefix}/local/bin|\1%{_bindir}|'
-grep -rl '#![ \t]*\./ruby' . | \
-	xargs sed -i -e '1s|\(#![ \t]*\)\./ruby|%{_bindir}/ruby|'
-
-# Fix encoding
-# Suppress message
-set +x
-find . -type f | while read f ; do
-	file $f | grep -q 'text' || continue
-	iconv -f UTF-8 -t UTF-8 $f &> /dev/null && continue
-	for encoding in \
-		EUC-JP ISO-8859-1
-	do
-		iconv -f $encoding -t UTF-8 $f -o $f.tmp 2>/dev/null && \
-			{ touch -r $f $f.tmp ; mv $f.tmp $f ; \
-				echo -e "$f\t: converted from $encoding -t UTF-8" ; continue 2; } || \
-			rm -f $f.tmp
-	done
-done
-# Enable message
-set -x
-
-# irb
-mv ruby-libs/doc/irb/* irb
-rm -rf ruby-libs/doc/irb
-
-# tcltk
-mv ruby-libs/ext/tk/* ruby-tcltk/
-rmdir ruby-libs/ext/tk
-
-## Fix encodings
-pushd ruby-tcltk
-cd sample
-find . -path ./demos-jp/\*.rb -or -path ./tkoptdb\*.rb -or -path ./msgs_rb2/ja.msg | \
-	xargs sed -i -e 's|euc-jp|utf-8|'
-sed -i \
-	-e '/KCODE =/s|euc|utf-8|' -e 's|EUC-JP|UTF-8|' \
-	demos-jp/widget
-cd ..
-sed -i -e 's|EUC-JP|UTF-8|' README.1st
-popd
-
-# done w/ docs
-popd
-
-# installing binaries ...
-make \
-	-C $RPM_BUILD_DIR/%{name}-%{version}/%{name}-%{arcver} \
-	DESTDIR=$RPM_BUILD_ROOT \
-	install
-
-# install ri doc
-cp -a ./%{name}-%{arcver}/RI_TMPDIR/* $RPM_BUILD_ROOT
-
-mkdir -p $RPM_BUILD_ROOT%{sitelibbase}/%{rubyxver}
-mkdir -p $RPM_BUILD_ROOT%{sitearchbase}/%{rubyxver}/%{_normalized_cpu}-%{_target_os}
-
-# remove shebang
-for i in \
-	$RPM_BUILD_ROOT%{vendorlibbase}/%{rubyxver}/{abbrev,generator,irb/{cmd/subirb,ext/save-history},matrix,rdoc/{markup/sample/rdoc2latex,parsers/parse_rb},set,tsort}.rb; \
-	do
-	sed -i -e '/^#!.*/,1D' $i
-done
-# The following can be executable
-chmod 0755 $RPM_BUILD_ROOT%{vendorlibbase}/%{rubyxver}/tkextlib/pkg_checker.rb
-chmod 0644 $RPM_BUILD_ROOT%{vendorarchbase}/%{rubyxver}/%{_normalized_cpu}-%{_target_os}/*.h
-
-find $RPM_BUILD_ROOT/ -name "*.so" -exec chmod 755 {} \;
-
-%clean
-rm -rf $RPM_BUILD_ROOT
+# Adjust the gemspec files so that the gems will load properly
+sed -i '2 a\
+  s.require_paths = ["lib"]' %{buildroot}/%{gem_dir}/specifications/rake-%{rake_version}.gemspec
+
+sed -i '2 a\
+  s.require_paths = ["lib"]' %{buildroot}/%{gem_dir}/specifications/rdoc-%{rdoc_version}.gemspec
+
+sed -i -e '2 a\
+  s.require_paths = ["lib"]' -e '3 a\
+  s.extensions = ["bigdecimal.so"]' %{buildroot}/%{gem_dir}/specifications/bigdecimal-%{bigdecimal_version}.gemspec
+
+sed -i -e '2 a\
+  s.require_paths = ["lib"]' -e '3 a\
+  s.extensions = ["io/console.so"]' %{buildroot}/%{gem_dir}/specifications/io-console-%{io_console_version}.gemspec
+
+sed -i -e '2 a\
+  s.require_paths = ["lib"]' -e '3 a\
+  s.extensions = ["json/ext/parser.so", "json/ext/generator.so"]' %{buildroot}/%{gem_dir}/specifications/json-%{json_version}.gemspec
+
+sed -i '2 a\
+  s.require_paths = ["lib"]' %{buildroot}/%{gem_dir}/specifications/minitest-%{minitest_version}.gemspec
+
+%check
+make check
 
 %post libs -p /sbin/ldconfig
 
 %postun libs -p /sbin/ldconfig
 
 %files
-%defattr(-, root, root, -)
-%doc	%{name}-%{arcver}/COPYING*
-%doc	%{name}-%{arcver}/ChangeLog
-%doc	%{name}-%{arcver}/GPL
-%doc	%{name}-%{arcver}/LEGAL
-%doc	%{name}-%{arcver}/LGPL
-%doc	%{name}-%{arcver}/NEWS
-%doc	%{name}-%{arcver}/README
-%lang(ja)	%doc	%{name}-%{arcver}/README.ja
-%doc	%{name}-%{arcver}/ToDo
-%doc	tmp-ruby-docs/ruby/*
-%{_bindir}/ruby
+%doc COPYING
+%lang(ja) %doc COPYING.ja
+%doc ChangeLog
+%doc GPL
+%doc LEGAL
+%doc NEWS
+%doc README
+%lang(ja) %doc README.ja
+%doc ToDo
+%doc doc/ChangeLog-*
+%doc doc/NEWS-*
 %{_bindir}/erb
+%{_bindir}/ruby
 %{_bindir}/testrb
-%{_mandir}/man1/ruby.1*
-
-%files	devel
-%defattr(-, root, root, -)
-%doc	%{name}-%{arcver}/COPYING*
-%doc	%{name}-%{arcver}/ChangeLog
-%doc	%{name}-%{arcver}/GPL
-%doc	%{name}-%{arcver}/LEGAL
-%doc	%{name}-%{arcver}/LGPL
-%doc	%{name}-%{arcver}/README.EXT
-%lang(ja)	%doc	%{name}-%{arcver}/README.EXT.ja
+%{_mandir}/man1/erb*
+%{_mandir}/man1/ruby*
+
+# http://fedoraproject.org/wiki/Packaging:Guidelines#Packaging_Static_Libraries
+%exclude %{_libdir}/libruby-static.a
+
+%files devel
+%doc COPYING*
+%doc GPL
+%doc LEGAL
+%doc README.EXT
+%lang(ja) %doc README.EXT.ja
+
+%config(noreplace) %{_sysconfdir}/rpm/macros.ruby
+
+%{_includedir}/ruby.h
+%{_includedir}/ruby
+%dir %{_includedir}/%{_normalized_cpu}-%{_target_os}
+%{_includedir}/%{_normalized_cpu}-%{_target_os}/ruby
+
 %{_libdir}/libruby.so
-%{vendorarchbase}/%{rubyxver}/%{_normalized_cpu}-%{_target_os}/*.h
-
-%files	static
-%defattr(-, root, root, -)
-%{_libdir}/libruby-static.a
-
-%files	libs
-%defattr(-, root, root, -)
-%doc %{name}-%{arcver}/README
-%lang(ja)	%doc	%{name}-%{arcver}/README.ja
-%doc	%{name}-%{arcver}/COPYING*
-%doc	%{name}-%{arcver}/ChangeLog
-%doc	%{name}-%{arcver}/GPL
-%doc	%{name}-%{arcver}/LEGAL
-%doc	%{name}-%{arcver}/LGPL
-%doc	tmp-ruby-docs/ruby-libs/*
-%dir	%{vendorlibbase}
-%dir	%{vendorlibbase}/%{rubyxver}
-%{sitelibbase}
-%ifarch ppc64 s390x sparc64 x86_64
-%dir	%{vendorarchbase}
-%dir	%{vendorarchbase}/%{rubyxver}
-%dir	%{vendorarchbase}/%{rubyxver}/%{_normalized_cpu}-%{_target_os}
-%{sitearchbase}
-%else
-%dir	%{vendorlibbase}/%{rubyxver}/%{_normalized_cpu}-%{_target_os}
-%endif
-## the following files should goes into ruby-tcltk package.
-%exclude	%{vendorlibbase}/%{rubyxver}/*tk.rb
-%exclude	%{vendorlibbase}/%{rubyxver}/tcltk.rb
-%exclude	%{vendorlibbase}/%{rubyxver}/tk
-%exclude	%{vendorlibbase}/%{rubyxver}/tk*.rb
-%exclude	%{vendorlibbase}/%{rubyxver}/tkextlib
-%exclude	%{vendorarchbase}/%{rubyxver}/%{_normalized_cpu}-%{_target_os}/tcltklib.so
-%exclude	%{vendorarchbase}/%{rubyxver}/%{_normalized_cpu}-%{_target_os}/tkutil.so
-## the following files should goes into ruby-rdoc package.
-%exclude	%{vendorlibbase}/%{rubyxver}/rdoc
-## the following files should goes into ruby-irb package.
-%exclude	%{vendorlibbase}/%{rubyxver}/irb.rb
-%exclude	%{vendorlibbase}/%{rubyxver}/irb
-## files in ruby-libs from here
-%{vendorlibbase}/%{rubyxver}/*.rb
-%{vendorlibbase}/%{rubyxver}/bigdecimal
-%{vendorlibbase}/%{rubyxver}/cgi
-%{vendorlibbase}/%{rubyxver}/date
-%{vendorlibbase}/%{rubyxver}/digest
-%{vendorlibbase}/%{rubyxver}/dl
-%{vendorlibbase}/%{rubyxver}/drb
-%{vendorlibbase}/%{rubyxver}/io
-%{vendorlibbase}/%{rubyxver}/net
-%{vendorlibbase}/%{rubyxver}/openssl
-%{vendorlibbase}/%{rubyxver}/optparse
-%{vendorlibbase}/%{rubyxver}/racc
-%{vendorlibbase}/%{rubyxver}/rexml
-%{vendorlibbase}/%{rubyxver}/rinda
-%{vendorlibbase}/%{rubyxver}/rss
-%{vendorlibbase}/%{rubyxver}/runit
-%{vendorlibbase}/%{rubyxver}/shell
-%{vendorlibbase}/%{rubyxver}/soap
-%{vendorlibbase}/%{rubyxver}/test
-%{vendorlibbase}/%{rubyxver}/uri
-%{vendorlibbase}/%{rubyxver}/webrick
-%{vendorlibbase}/%{rubyxver}/wsdl
-%{vendorlibbase}/%{rubyxver}/xmlrpc
-%{vendorlibbase}/%{rubyxver}/xsd
-%{vendorlibbase}/%{rubyxver}/yaml
+%{_libdir}/pkgconfig/ruby-1.9.pc
+
+%files libs
+%doc COPYING
+%lang(ja) %doc COPYING.ja
+%doc GPL
+%doc LEGAL
+%doc README
+%lang(ja) %doc README.ja
+# Exclude /usr/local directory since it is supposed to be managed by
+# local system administrator.
+%exclude %{ruby_sitelibdir}
+%exclude %{ruby_sitearchdir}
+%{ruby_vendorlibdir}
+%{ruby_vendorarchdir}
+
+# List all these files explicitly to prevent surprises
+# Platform independent libraries.
+%dir %{ruby_libdir}
+%{ruby_libdir}/*.rb
+%exclude %{ruby_libdir}/*-tk.rb
+%exclude %{ruby_libdir}/irb.rb
+%exclude %{ruby_libdir}/tcltk.rb
+%exclude %{ruby_libdir}/tk*.rb
+%{ruby_libdir}/cgi
+%{ruby_libdir}/date
+%{ruby_libdir}/digest
+%{ruby_libdir}/dl
+%{ruby_libdir}/drb
+%{ruby_libdir}/fiddle
+%exclude %{ruby_libdir}/gems
+%exclude %{ruby_libdir}/irb
+%{ruby_libdir}/matrix
+%{ruby_libdir}/net
+%{ruby_libdir}/openssl
+%{ruby_libdir}/optparse
+%{ruby_libdir}/psych
+%{ruby_libdir}/racc
+%{ruby_libdir}/rbconfig
+%{ruby_libdir}/rexml
+%{ruby_libdir}/rinda
+%{ruby_libdir}/ripper
+%{ruby_libdir}/rss
+%{ruby_libdir}/shell
+%{ruby_libdir}/syck
+%{ruby_libdir}/test
+%exclude %{ruby_libdir}/tk
+%exclude %{ruby_libdir}/tkextlib
+%{ruby_libdir}/uri
+%{ruby_libdir}/webrick
+%{ruby_libdir}/xmlrpc
+%{ruby_libdir}/yaml
+
+# Platform specific libraries.
 %{_libdir}/libruby.so.*
-%{vendorarchbase}/%{rubyxver}/%{_normalized_cpu}-%{_target_os}/*.so
-%{vendorarchbase}/%{rubyxver}/%{_normalized_cpu}-%{_target_os}/digest
-%{vendorarchbase}/%{rubyxver}/%{_normalized_cpu}-%{_target_os}/io
-%{vendorarchbase}/%{rubyxver}/%{_normalized_cpu}-%{_target_os}/racc
-%{vendorarchbase}/%{rubyxver}/%{_normalized_cpu}-%{_target_os}/rbconfig.rb
-
-%files tcltk
-%defattr(-, root, root, -)
-%doc	%{name}-%{arcver}/COPYING*
-%doc	%{name}-%{arcver}/ChangeLog
-%doc	%{name}-%{arcver}/GPL
-%doc	%{name}-%{arcver}/LEGAL
-%doc	%{name}-%{arcver}/LGPL
-%doc	tmp-ruby-docs/ruby-tcltk/*
-%{vendorlibbase}/%{rubyxver}/*-tk.rb
-%{vendorlibbase}/%{rubyxver}/tcltk.rb
-%{vendorlibbase}/%{rubyxver}/tk
-%{vendorlibbase}/%{rubyxver}/tk*.rb
-%{vendorlibbase}/%{rubyxver}/tkextlib
-%{vendorarchbase}/%{rubyxver}/%{_normalized_cpu}-%{_target_os}/tcltklib.so
-%{vendorarchbase}/%{rubyxver}/%{_normalized_cpu}-%{_target_os}/tkutil.so
-
-%files	rdoc
-%defattr(-, root, root, -)
-%doc	%{name}-%{arcver}/COPYING*
-%doc	%{name}-%{arcver}/ChangeLog
-%doc	%{name}-%{arcver}/GPL
-%doc	%{name}-%{arcver}/LEGAL
-%doc	%{name}-%{arcver}/LGPL
-%{_bindir}/rdoc
-%{vendorlibbase}/%{rubyxver}/rdoc
+%dir %{ruby_libarchdir}
+%{ruby_libarchdir}/continuation.so
+%{ruby_libarchdir}/coverage.so
+%{ruby_libarchdir}/curses.so
+%{ruby_libarchdir}/date_core.so
+%{ruby_libarchdir}/dbm.so
+%dir %{ruby_libarchdir}/digest
+%{ruby_libarchdir}/digest.so
+%{ruby_libarchdir}/digest/bubblebabble.so
+%{ruby_libarchdir}/digest/md5.so
+%{ruby_libarchdir}/digest/rmd160.so
+%{ruby_libarchdir}/digest/sha1.so
+%{ruby_libarchdir}/digest/sha2.so
+%dir %{ruby_libarchdir}/dl
+%{ruby_libarchdir}/dl.so
+%{ruby_libarchdir}/dl/callback.so
+%dir %{ruby_libarchdir}/enc
+%{ruby_libarchdir}/enc/big5.so
+%{ruby_libarchdir}/enc/cp949.so
+%{ruby_libarchdir}/enc/emacs_mule.so
+%{ruby_libarchdir}/enc/encdb.so
+%{ruby_libarchdir}/enc/euc_jp.so
+%{ruby_libarchdir}/enc/euc_kr.so
+%{ruby_libarchdir}/enc/euc_tw.so
+%{ruby_libarchdir}/enc/gb18030.so
+%{ruby_libarchdir}/enc/gb2312.so
+%{ruby_libarchdir}/enc/gbk.so
+%{ruby_libarchdir}/enc/iso_8859_1.so
+%{ruby_libarchdir}/enc/iso_8859_10.so
+%{ruby_libarchdir}/enc/iso_8859_11.so
+%{ruby_libarchdir}/enc/iso_8859_13.so
+%{ruby_libarchdir}/enc/iso_8859_14.so
+%{ruby_libarchdir}/enc/iso_8859_15.so
+%{ruby_libarchdir}/enc/iso_8859_16.so
+%{ruby_libarchdir}/enc/iso_8859_2.so
+%{ruby_libarchdir}/enc/iso_8859_3.so
+%{ruby_libarchdir}/enc/iso_8859_4.so
+%{ruby_libarchdir}/enc/iso_8859_5.so
+%{ruby_libarchdir}/enc/iso_8859_6.so
+%{ruby_libarchdir}/enc/iso_8859_7.so
+%{ruby_libarchdir}/enc/iso_8859_8.so
+%{ruby_libarchdir}/enc/iso_8859_9.so
+%{ruby_libarchdir}/enc/koi8_r.so
+%{ruby_libarchdir}/enc/koi8_u.so
+%{ruby_libarchdir}/enc/shift_jis.so
+%dir %{ruby_libarchdir}/enc/trans
+%{ruby_libarchdir}/enc/trans/big5.so
+%{ruby_libarchdir}/enc/trans/chinese.so
+%{ruby_libarchdir}/enc/trans/emoji.so
+%{ruby_libarchdir}/enc/trans/emoji_iso2022_kddi.so
+%{ruby_libarchdir}/enc/trans/emoji_sjis_docomo.so
+%{ruby_libarchdir}/enc/trans/emoji_sjis_kddi.so
+%{ruby_libarchdir}/enc/trans/emoji_sjis_softbank.so
+%{ruby_libarchdir}/enc/trans/escape.so
+%{ruby_libarchdir}/enc/trans/gb18030.so
+%{ruby_libarchdir}/enc/trans/gbk.so
+%{ruby_libarchdir}/enc/trans/iso2022.so
+%{ruby_libarchdir}/enc/trans/japanese.so
+%{ruby_libarchdir}/enc/trans/japanese_euc.so
+%{ruby_libarchdir}/enc/trans/japanese_sjis.so
+%{ruby_libarchdir}/enc/trans/korean.so
+%{ruby_libarchdir}/enc/trans/single_byte.so
+%{ruby_libarchdir}/enc/trans/transdb.so
+%{ruby_libarchdir}/enc/trans/utf8_mac.so
+%{ruby_libarchdir}/enc/trans/utf_16_32.so
+%{ruby_libarchdir}/enc/utf_16be.so
+%{ruby_libarchdir}/enc/utf_16le.so
+%{ruby_libarchdir}/enc/utf_32be.so
+%{ruby_libarchdir}/enc/utf_32le.so
+%{ruby_libarchdir}/enc/windows_1251.so
+%{ruby_libarchdir}/etc.so
+%{ruby_libarchdir}/fcntl.so
+%{ruby_libarchdir}/fiber.so
+%{ruby_libarchdir}/fiddle.so
+%{ruby_libarchdir}/gdbm.so
+%{ruby_libarchdir}/iconv.so
+%dir %{ruby_libarchdir}/io
+%{ruby_libarchdir}/io/nonblock.so
+%{ruby_libarchdir}/io/wait.so
+%dir %{ruby_libarchdir}/mathn
+%{ruby_libarchdir}/mathn/complex.so
+%{ruby_libarchdir}/mathn/rational.so
+%{ruby_libarchdir}/nkf.so
+%{ruby_libarchdir}/objspace.so
+%{ruby_libarchdir}/openssl.so
+%{ruby_libarchdir}/pathname.so
+%{ruby_libarchdir}/psych.so
+%{ruby_libarchdir}/pty.so
+%dir %{ruby_libarchdir}/racc
+%{ruby_libarchdir}/racc/cparse.so
+%{ruby_libarchdir}/rbconfig.rb
+%{ruby_libarchdir}/readline.so
+%{ruby_libarchdir}/ripper.so
+%{ruby_libarchdir}/sdbm.so
+%{ruby_libarchdir}/socket.so
+%{ruby_libarchdir}/stringio.so
+%{ruby_libarchdir}/strscan.so
+%{ruby_libarchdir}/syck.so
+%{ruby_libarchdir}/syslog.so
+%exclude %{ruby_libarchdir}/tcltklib.so
+%exclude %{ruby_libarchdir}/tkutil.so
+%{ruby_libarchdir}/zlib.so
+
+%files -n rubygems
+%{_bindir}/gem
+%{rubygems_dir}
+%{gem_dir}
+%exclude %{gem_dir}/gems/*
+%{_exec_prefix}/lib*/gems
+%exclude %{_exec_prefix}/lib*/gems/exts/bigdecimal-%{bigdecimal_version}
+%exclude %{_exec_prefix}/lib*/gems/exts/io-console-%{io_console_version}
+%exclude %{_exec_prefix}/lib*/gems/exts/json-%{json_version}
+%exclude %{gem_dir}/gems/rake-%{rake_version}
+%exclude %{gem_dir}/gems/rdoc-%{rdoc_version}
+%exclude %{gem_dir}/specifications/bigdecimal-%{bigdecimal_version}.gemspec
+%exclude %{gem_dir}/specifications/io-console-%{io_console_version}.gemspec
+%exclude %{gem_dir}/specifications/json-%{json_version}.gemspec
+%exclude %{gem_dir}/specifications/minitest-%{minitest_version}.gemspec
+%exclude %{gem_dir}/specifications/rake-%{rake_version}.gemspec
+%exclude %{gem_dir}/specifications/rdoc-%{rdoc_version}.gemspec
+
+%files -n rubygems-devel
+%config(noreplace) %{_sysconfdir}/rpm/macros.rubygems
+
+%files -n rubygem-rake
+%{_bindir}/rake
+%{gem_dir}/gems/rake-%{rake_version}
+%{gem_dir}/specifications/rake-%{rake_version}.gemspec
+%{_mandir}/man1/rake.1*
 
 %files irb
-%defattr(-, root, root, -)
-%doc	%{name}-%{arcver}/COPYING*
-%doc	%{name}-%{arcver}/ChangeLog
-%doc	%{name}-%{arcver}/GPL
-%doc	%{name}-%{arcver}/LEGAL
-%doc	%{name}-%{arcver}/LGPL
-%doc	tmp-ruby-docs/irb/*
 %{_bindir}/irb
-%{vendorlibbase}/%{rubyxver}/irb.rb
-%{vendorlibbase}/%{rubyxver}/irb
-
-%files ri
-%defattr(-, root, root, -)
-%doc	%{name}-%{arcver}/COPYING*
-%doc	%{name}-%{arcver}/ChangeLog
-%doc	%{name}-%{arcver}/GPL
-%doc	%{name}-%{arcver}/LEGAL
-%doc	%{name}-%{arcver}/LGPL
+%{ruby_libdir}/irb.rb
+%{ruby_libdir}/irb
+%{_mandir}/man1/irb.1*
+
+%files -n rubygem-rdoc
+%{_bindir}/rdoc
 %{_bindir}/ri
+%{gem_dir}/gems/rdoc-%{rdoc_version}
+%{gem_dir}/specifications/rdoc-%{rdoc_version}.gemspec
+%{_mandir}/man1/ri*
 %{_datadir}/ri
 
+%files -n rubygem-bigdecimal
+%{_libdir}/gems/exts/bigdecimal-%{bigdecimal_version}
+%{gem_dir}/gems/bigdecimal-%{bigdecimal_version}
+%{gem_dir}/specifications/bigdecimal-%{bigdecimal_version}.gemspec
+
+%files -n rubygem-io-console
+%{_libdir}/gems/exts/io-console-%{io_console_version}
+%{gem_dir}/gems/io-console-%{io_console_version}
+%{gem_dir}/specifications/io-console-%{io_console_version}.gemspec
+
+%files -n rubygem-json
+%{_libdir}/gems/exts/json-%{json_version}
+%{gem_dir}/gems/json-%{json_version}
+%{gem_dir}/specifications/json-%{json_version}.gemspec
+
+%files -n rubygem-minitest
+%{gem_dir}/gems/minitest-%{minitest_version}
+%{gem_dir}/specifications/minitest-%{minitest_version}.gemspec
+
+%files tcltk
+%{ruby_libdir}/*-tk.rb
+%{ruby_libdir}/tcltk.rb
+%{ruby_libdir}/tk*.rb
+%{ruby_libarchdir}/tcltklib.so
+%{ruby_libarchdir}/tkutil.so
+%{ruby_libdir}/tk
+%{ruby_libdir}/tkextlib
+
 %changelog
+* Wed Jan 18 2012 Vít Ondruch <vondruch at redhat.com> - 1.9.3.0-5
+- Add rubygems dependency on io-console for user interactions.
+- Gems license clarification.
+
+* Tue Jan 17 2012 Vít Ondruch <vondruch at redhat.com> - 1.9.3.0-4
+- Bundled gems moved into dedicated directories and subpackages.
+- Create and own RubyGems directories for binary extensions.
+- Fix build with GCC 4.7.
+
+* Wed Jan 04 2012 Vít Ondruch <vondruch at redhat.com> - 1.9.3.0-3
+- Fix RHEL build.
+- Fixed directory ownership.
+- Verose build output.
+
+* Wed Dec 14 2011 Vít Ondruch <vondruch at redhat.com> - 1.9.3.0-2
+- Install RubyGems outside of Ruby directory structure.
+- RubyGems has not its own -devel subpackage.
+- Enhanced macros.ruby and macros.rubygems.
+- All tests are green now (bkabrda).
+
+* Tue Sep 23 2011 Vít Ondruch <vondruch at redhat.com> - 1.9.3.0-1
+- Initial package
+
 * Sat Jan 14 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.8.7.357-2
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
 
diff --git a/rubygems-1.8.11-binary-extensions.patch b/rubygems-1.8.11-binary-extensions.patch
new file mode 100644
index 0000000..5a3bfb4
--- /dev/null
+++ b/rubygems-1.8.11-binary-extensions.patch
@@ -0,0 +1,296 @@
+From 5a37a3489491a33f2e7011043fbbcd9a765e1777 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch at redhat.com>
+Date: Thu, 3 Nov 2011 16:43:05 +0100
+Subject: [PATCH 1/6] Add dedicate extensions folder into $LOAD_PATH.
+
+---
+ lib/rubygems/specification.rb |   37 ++++++++++++++++++++++++++++++-------
+ 1 files changed, 30 insertions(+), 7 deletions(-)
+
+diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
+index 97db19e..263e7d3 100644
+--- a/lib/rubygems/specification.rb
++++ b/lib/rubygems/specification.rb
+@@ -843,6 +843,12 @@ class Gem::Specification
+       File.join full_gem_path, path
+     end
+ 
++    unless extensions.empty?
++      paths += require_paths.map do |path|
++        File.join ext_dir, path
++      end
++    end
++
+     # gem directories must come after -I and ENV['RUBYLIB']
+     insert_index = Gem.load_path_insert_index
+ 
+@@ -954,16 +960,16 @@ class Gem::Specification
+ 
+   def contains_requirable_file? file
+     root = full_gem_path
++    ext = ext_dir
++
++    require_paths.any? do |lib|
++      base = ["#{root}/#{lib}/#{file}"]
++      base << "#{ext}/#{lib}/#{file}" unless extensions.empty?
+ 
+-    require_paths.each do |lib|
+-      base = "#{root}/#{lib}/#{file}"
+-      Gem.suffixes.each do |suf|
+-        path = "#{base}#{suf}"
+-        return true if File.file? path
++      base.any? do |path|
++        Gem.suffixes.any? { |suf| File.file? "#{path}#{suf}" }
+       end
+     end
+-
+-    return false
+   end
+ 
+   ##
+@@ -1273,6 +1279,23 @@ class Gem::Specification
+   end
+ 
+   ##
++  # Returns the full path to this spec's ext directory.
++  # eg: /usr/local/lib/ruby/1.8/exts/mygem-1.0
++
++  def ext_dir
++    @gem_dir ||= File.expand_path File.join(exts_dir, full_name)
++  end
++
++  ##
++  # Returns the full path to the exts directory containing this spec's
++  # gem directory. eg: /usr/local/lib/ruby/1.8/exts
++
++  def exts_dir
++    # TODO: this logic seems terribly broken, but tests fail if just base_dir
++    @exts_dir ||= File.join(loaded_from && base_dir || Gem.dir, "exts")
++  end
++
++  ##
+   # Deprecated and ignored, defaults to true.
+   #
+   # Formerly used to indicate this gem was RDoc-capable.
+-- 
+1.7.7.3
+
+
+From 671e4285bf9db948bc5f054d7d3d931cdd7a17f8 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch at redhat.com>
+Date: Wed, 16 Nov 2011 13:26:48 +0100
+Subject: [PATCH 2/6] Use spec's ext dir for extension installation.
+
+---
+ lib/rubygems/installer.rb     |    2 +-
+ lib/rubygems/specification.rb |    7 +++----
+ 2 files changed, 4 insertions(+), 5 deletions(-)
+
+diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
+index 74d803d..0063c7f 100644
+--- a/lib/rubygems/installer.rb
++++ b/lib/rubygems/installer.rb
+@@ -499,7 +499,7 @@ TEXT
+   def build_extensions
+     return if spec.extensions.empty?
+     say "Building native extensions.  This could take a while..."
+-    dest_path = File.join gem_dir, spec.require_paths.first
++    dest_path = spec.ext_dir
+     ran_rake = false # only run rake once
+ 
+     spec.extensions.each do |extension|
+diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
+index 263e7d3..d31b93b 100644
+--- a/lib/rubygems/specification.rb
++++ b/lib/rubygems/specification.rb
+@@ -1283,16 +1283,15 @@ class Gem::Specification
+   # eg: /usr/local/lib/ruby/1.8/exts/mygem-1.0
+ 
+   def ext_dir
+-    @gem_dir ||= File.expand_path File.join(exts_dir, full_name)
++    @ext_dir ||= File.join exts_dir, full_name, require_paths.first
+   end
+ 
+   ##
+   # Returns the full path to the exts directory containing this spec's
+-  # gem directory. eg: /usr/local/lib/ruby/1.8/exts
++  # gem directory. eg: /usr/local/lib/ruby/1.8/gems
+ 
+   def exts_dir
+-    # TODO: this logic seems terribly broken, but tests fail if just base_dir
+-    @exts_dir ||= File.join(loaded_from && base_dir || Gem.dir, "exts")
++    @exts_dir ||= gems_dir
+   end
+ 
+   ##
+-- 
+1.7.7.3
+
+
+From 11b4a0cbadd8b1d3320f838881aa60feb6f848e7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch at redhat.com>
+Date: Wed, 16 Nov 2011 14:52:16 +0100
+Subject: [PATCH 3/6] Simplify the extending of $LOAD_PATH for binary gems.
+
+---
+ lib/rubygems/specification.rb |   11 +++++------
+ 1 files changed, 5 insertions(+), 6 deletions(-)
+
+diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
+index d31b93b..e65ea2d 100644
+--- a/lib/rubygems/specification.rb
++++ b/lib/rubygems/specification.rb
+@@ -843,11 +843,7 @@ class Gem::Specification
+       File.join full_gem_path, path
+     end
+ 
+-    unless extensions.empty?
+-      paths += require_paths.map do |path|
+-        File.join ext_dir, path
+-      end
+-    end
++    paths << ext_dir unless extensions.empty? || paths.include?(ext_dir)
+ 
+     # gem directories must come after -I and ENV['RUBYLIB']
+     insert_index = Gem.load_path_insert_index
+@@ -1291,7 +1287,10 @@ class Gem::Specification
+   # gem directory. eg: /usr/local/lib/ruby/1.8/gems
+ 
+   def exts_dir
+-    @exts_dir ||= gems_dir
++    @exts_dir ||= begin
++      dirs = Gem.default_dirs.detect {|location, paths| paths[:gem_dir] == base_dir}
++      dirs ? File.join(dirs.last[:ext_dir], 'exts') : gems_dir
++    end
+   end
+ 
+   ##
+-- 
+1.7.7.3
+
+
+From 5d46cd2b1ac9517a9cbcfa430261e62bb3a376b8 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch at redhat.com>
+Date: Fri, 9 Dec 2011 16:31:04 +0100
+Subject: [PATCH 4/6] Fix the binary extension search path construction.
+
+---
+ lib/rubygems/installer.rb     |    2 +-
+ lib/rubygems/specification.rb |    4 ++--
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
+index 0063c7f..83b8fd5 100644
+--- a/lib/rubygems/installer.rb
++++ b/lib/rubygems/installer.rb
+@@ -499,7 +499,7 @@ TEXT
+   def build_extensions
+     return if spec.extensions.empty?
+     say "Building native extensions.  This could take a while..."
+-    dest_path = spec.ext_dir
++    dest_path = File.join spec.ext_dir, spec.require_paths.first
+     ran_rake = false # only run rake once
+ 
+     spec.extensions.each do |extension|
+diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
+index e65ea2d..8be2ade 100644
+--- a/lib/rubygems/specification.rb
++++ b/lib/rubygems/specification.rb
+@@ -843,7 +843,7 @@ class Gem::Specification
+       File.join full_gem_path, path
+     end
+ 
+-    paths << ext_dir unless extensions.empty? || paths.include?(ext_dir)
++    paths << File.join(ext_dir, require_paths.first) unless extensions.empty? || (ext_dir == full_gem_path)
+ 
+     # gem directories must come after -I and ENV['RUBYLIB']
+     insert_index = Gem.load_path_insert_index
+@@ -1279,7 +1279,7 @@ class Gem::Specification
+   # eg: /usr/local/lib/ruby/1.8/exts/mygem-1.0
+ 
+   def ext_dir
+-    @ext_dir ||= File.join exts_dir, full_name, require_paths.first
++    @ext_dir ||= File.join exts_dir, full_name
+   end
+ 
+   ##
+-- 
+1.7.7.3
+
+
+From 6229583633802b45e5a3e5689ab9077347cd9ef7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch at redhat.com>
+Date: Tue, 13 Dec 2011 12:14:54 +0100
+Subject: [PATCH 5/6] Remove binary extensions during uninstall.
+
+---
+ lib/rubygems/uninstaller.rb |    1 +
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+
+diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb
+index cc32ea4..94d78e0 100644
+--- a/lib/rubygems/uninstaller.rb
++++ b/lib/rubygems/uninstaller.rb
+@@ -213,6 +213,7 @@ class Gem::Uninstaller
+       File.writable?(spec.base_dir)
+ 
+     FileUtils.rm_rf spec.full_gem_path
++    FileUtils.rm_rf spec.ext_dir
+ 
+     # TODO: should this be moved to spec?... I vote eww (also exists in docmgr)
+     old_platform_name = [spec.name,
+-- 
+1.7.7.3
+
+
+From bc40e1b9f60a9a04456e3504ffe6ee600b6da269 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch at redhat.com>
+Date: Tue, 13 Dec 2011 14:27:14 +0100
+Subject: [PATCH 6/6] Avoid dependency on customized operating_system.rb.
+
+---
+ lib/rubygems/defaults.rb      |   11 +++++++++++
+ lib/rubygems/specification.rb |    5 +----
+ 2 files changed, 12 insertions(+), 4 deletions(-)
+
+diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
+index 20b4198..6d8711f 100644
+--- a/lib/rubygems/defaults.rb
++++ b/lib/rubygems/defaults.rb
+@@ -87,6 +87,17 @@ module Gem
+   end
+ 
+   ##
++  # Returns binary extensions dir for specified RubyGems base dir or nil
++  # if such directory cannot be determined.
++  #
++  # By default, the binary extensions are located side by side with their
++  # Ruby counterparts, therefore nil is returned
++
++  def self.default_ext_dir_for base_dir
++    nil
++  end
++
++  ##
+   # The default system-wide source info cache directory
+ 
+   def self.default_system_source_cache_dir
+diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
+index 8be2ade..f54210a 100644
+--- a/lib/rubygems/specification.rb
++++ b/lib/rubygems/specification.rb
+@@ -1287,10 +1287,7 @@ class Gem::Specification
+   # gem directory. eg: /usr/local/lib/ruby/1.8/gems
+ 
+   def exts_dir
+-    @exts_dir ||= begin
+-      dirs = Gem.default_dirs.detect {|location, paths| paths[:gem_dir] == base_dir}
+-      dirs ? File.join(dirs.last[:ext_dir], 'exts') : gems_dir
+-    end
++    @exts_dir ||= Gem.default_ext_dir_for(base_dir) || gems_dir
+   end
+ 
+   ##
+-- 
+1.7.7.3
+
diff --git a/sources b/sources
index 1d94212..e874ffe 100644
--- a/sources
+++ b/sources
@@ -1,2 +1 @@
-3abd9e2a29f756a0d30c7bfca578cdeb  ruby-1.8.7-p357.tar.bz2
-01b1053cf357459349bf74363756ad41  ruby-revc2dfaa7d40531aef3706bcc16f38178b0c6633ee-ext_tk.tar.gz
+8e2fef56185cfbaf29d0c8329fc77c05  ruby-1.9.3-p0.tar.gz


More information about the scm-commits mailing list