Use upstream patch for correct build of gem extensions.

This commit is contained in:
Vít Ondruch 2022-04-14 11:56:21 +02:00
parent 09d0e79c2b
commit c2061af620
3 changed files with 347 additions and 233 deletions

View File

@ -1,231 +0,0 @@
From 0da0152986f7d1e666aeb1317d18746250423575 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
Date: Thu, 31 Mar 2022 19:12:24 +0200
Subject: [PATCH 1/4] Properly install expanded gem extensions.
The expanded gem location changed from 'gem' to '.bundled/gems'
directory in commit:git|55bf0ef1aa7c936b564b883196de1ace4be4cc7e /
#2922, leaving behind binary extension installation. This should fix
the issues, so the gem binary extensions are buildable as part of Ruby
build process again.
---
ext/extmk.rb | 13 ++++++-------
template/exts.mk.tmpl | 4 ++--
tool/rbinstall.rb | 4 ++--
3 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/ext/extmk.rb b/ext/extmk.rb
index 4a087f294ac9..bc0e4f135d8e 100755
--- a/ext/extmk.rb
+++ b/ext/extmk.rb
@@ -146,7 +146,7 @@ def extmake(target, basedir = 'ext', maybestatic = true)
top_srcdir = $top_srcdir
topdir = $topdir
hdrdir = $hdrdir
- prefix = "../" * (target.count("/")+1)
+ prefix = "../" * (target.count("/") + basedir.count("/"))
$top_srcdir = relative_from(top_srcdir, prefix)
$hdrdir = relative_from(hdrdir, prefix)
$topdir = prefix + $topdir
@@ -461,15 +461,15 @@ def $mflags.defined?(var)
@gemname = nil
if ARGV[0]
- ext_prefix, exts = ARGV.shift.split('/', 2)
+ ext_prefix, exts = File.split(ARGV.shift)
$extension = [exts] if exts
- if ext_prefix == 'gems'
+ if ext_prefix == '.bundle/gems'
@gemname = exts
elsif exts
$static_ext.delete_if {|t, *| !File.fnmatch(t, exts)}
end
end
-ext_prefix = "#{$top_srcdir}/#{ext_prefix || 'ext'}"
+ext_prefix = "#{$top_srcdir}/#{ext_prefix || './ext'}"
exts = $static_ext.sort_by {|t, i| i}.collect {|t, i| t}
default_exclude_exts =
case
@@ -515,7 +515,6 @@ def $mflags.defined?(var)
exts.delete_if {|d| File.fnmatch?("-*", d)}
end
end
-ext_prefix = File.basename(ext_prefix)
extend Module.new {
def timestamp_file(name, target_prefix = nil)
@@ -534,7 +533,7 @@ def create_makefile(*args, &block)
super(*args) do |conf|
conf.find do |s|
s.sub!(/^(TARGET_SO_DIR *= *)\$\(RUBYARCHDIR\)/) {
- "TARGET_GEM_DIR = $(extout)/gems/$(arch)/#{@gemname}\n"\
+ "TARGET_GEM_DIR = $(extout)/.bundle/gems/$(arch)/#{@gemname}\n"\
"#{$1}$(TARGET_GEM_DIR)$(target_prefix)"
}
end
@@ -634,7 +633,7 @@ def initialize(src)
end
}
-Dir.chdir ".."
+Dir.chdir dir
unless $destdir.to_s.empty?
$mflags.defined?("DESTDIR") or $mflags << "DESTDIR=#{$destdir}"
end
diff --git a/template/exts.mk.tmpl b/template/exts.mk.tmpl
index 2f37f4480ac5..401ea9a497f3 100644
--- a/template/exts.mk.tmpl
+++ b/template/exts.mk.tmpl
@@ -19,13 +19,13 @@ opt = OptionParser.new do |o|
o.on('--configure-exts=FILE') {|v| confexts = v}
o.order!(ARGV)
end
-confexts &&= File.read(confexts).scan(/^exts: (.*\.mk)/).flatten rescue nil
+confexts &&= File.read(confexts).scan(/^(exts|gems): (.*\.mk)/).collect {|i| i.last } rescue nil
confexts ||= []
macros["old_extensions"] = []
contpat = /(?>(?>[^\\\n]|\\.)*\\\n)*(?>[^\\\n]|\\.)*/
Dir.glob("{ext,.bundle/gems}/*/exts.mk") do |e|
- gem = /\Agems(?=\/)/ =~ e
+ gem = /\A.bundle\/gems(?=\/)/ =~ e
s = File.read(e)
s.scan(/^(extensions|SUBMAKEOPTS|EXT[A-Z]+|MFLAGS|NOTE_[A-Z]+)[ \t]*=[ \t]*(#{contpat})$/o) do |n, v|
v.gsub!(/\\\n[ \t]*/, ' ')
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
index 9d9b672be472..8c8a14193ec9 100755
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -1047,7 +1047,7 @@ def install_default_gem(dir, srcdir, bindir)
:wrappers => true,
:format_executable => true,
}
- gem_ext_dir = "#$extout/gems/#{CONFIG['arch']}"
+ gem_ext_dir = "#$extout/.bundle/gems/#{CONFIG['arch']}"
extensions_dir = with_destdir(Gem::StubSpecification.gemspec_stub("", gem_dir, gem_dir).extensions_dir)
File.foreach("#{srcdir}/gems/bundled_gems") do |name|
@@ -1080,7 +1080,7 @@ def install_default_gem(dir, srcdir, bindir)
File.chmod($data_mode, File.join(install_dir, "specifications", "#{spec.full_name}.gemspec"))
end
unless spec.extensions.empty?
- install_recursive(ext, spec.extension_dir)
+ install_recursive(ext, without_destdir(spec.extension_dir))
end
installed_gems[spec.full_name] = true
end
From 8c57deb09dbd9005ebc872c3c9147d6c2924e208 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
Date: Thu, 31 Mar 2022 19:22:15 +0200
Subject: [PATCH 2/4] Re-enable building gem extensions.
This reverts commit bac6e8ca5d8f6bc45984d12ddad55d3d876d4324.
---
template/configure-ext.mk.tmpl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/template/configure-ext.mk.tmpl b/template/configure-ext.mk.tmpl
index 6636a7759c54..8ba6b963e3ec 100644
--- a/template/configure-ext.mk.tmpl
+++ b/template/configure-ext.mk.tmpl
@@ -27,7 +27,7 @@ SCRIPT_ARGS = <%=script_args.gsub("#", "\\#")%>
EXTMK_ARGS = $(SCRIPT_ARGS) --gnumake=$(gnumake) --extflags="$(EXTLDFLAGS)" \
--make-flags="MINIRUBY='$(MINIRUBY)'"
-all: exts # gems
+all: exts gems
exts:
gems:
From ee6a16eed10c3ab6e4cc8285ca137e83964e0f5c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
Date: Fri, 1 Apr 2022 16:26:04 +0200
Subject: [PATCH 3/4] Trust that .gemspec correctly declare their extensions.
Do not judge the extension availability by the available extension
build. This is already assumed on other places anyway:
https://github.com/ruby/ruby/blob/d1d48cb690fdad855da94b2a2d11721428bc06ba/tool/rbinstall.rb#L1062
---
tool/rbinstall.rb | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
index 8c8a14193ec9..259792ad878c 100755
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -1069,9 +1069,6 @@ def install_default_gem(dir, srcdir, bindir)
next
end
spec.extension_dir = "#{extensions_dir}/#{spec.full_name}"
- if File.directory?(ext = "#{gem_ext_dir}/#{spec.full_name}")
- spec.extensions[0] ||= "-"
- end
package = RbInstall::DirPackage.new spec
ins = RbInstall::UnpackedInstaller.new(package, options)
puts "#{INDENT}#{spec.name} #{spec.version}"
@@ -1080,6 +1077,7 @@ def install_default_gem(dir, srcdir, bindir)
File.chmod($data_mode, File.join(install_dir, "specifications", "#{spec.full_name}.gemspec"))
end
unless spec.extensions.empty?
+ ext = "#{gem_ext_dir}/#{spec.full_name}"
install_recursive(ext, without_destdir(spec.extension_dir))
end
installed_gems[spec.full_name] = true
From d11bc592494529f8732a4a40defaf18f600c261d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
Date: Mon, 4 Apr 2022 11:18:51 +0200
Subject: [PATCH 4/4] Install the previously build gem extensions.
Install the pre-build gem binary extensions and attempt to build them
during `gem install` phase only when they are not available for whatever
reason.
---
tool/rbinstall.rb | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
index 259792ad878c..4e42133bc1ce 100755
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -901,6 +901,18 @@ def write_default_spec
super unless $dryrun
$installed_list.puts(without_destdir(default_spec_file)) if $installed_list
end
+
+ def build_extensions
+ return if spec.extensions.empty?
+
+ ext = "#$extout/.bundle/gems/#{CONFIG['arch']}/#{spec.full_name}"
+
+ # Call `install_recursive` with global binding, so it correctly use
+ # the global `install`
+ Object.__send__ :install_recursive, ext, without_destdir(spec.extension_dir)
+
+ super unless File.exist? spec.gem_build_complete_path
+ end
end
class GemInstaller
@@ -1047,7 +1059,6 @@ def install_default_gem(dir, srcdir, bindir)
:wrappers => true,
:format_executable => true,
}
- gem_ext_dir = "#$extout/.bundle/gems/#{CONFIG['arch']}"
extensions_dir = with_destdir(Gem::StubSpecification.gemspec_stub("", gem_dir, gem_dir).extensions_dir)
File.foreach("#{srcdir}/gems/bundled_gems") do |name|
@@ -1076,10 +1087,6 @@ def install_default_gem(dir, srcdir, bindir)
unless $dryrun
File.chmod($data_mode, File.join(install_dir, "specifications", "#{spec.full_name}.gemspec"))
end
- unless spec.extensions.empty?
- ext = "#{gem_ext_dir}/#{spec.full_name}"
- install_recursive(ext, without_destdir(spec.extension_dir))
- end
installed_gems[spec.full_name] = true
end
installed_gems, gems = Dir.glob(srcdir+'/gems/*.gem').partition {|gem| installed_gems.key?(File.basename(gem, '.gem'))}

View File

@ -0,0 +1,338 @@
From 111f8422427d78becc9183ae149b2105a16bf327 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@ruby-lang.org>
Date: Tue, 5 Apr 2022 23:24:00 +0900
Subject: [PATCH 1/5] Bundled gems are expanded under `.bundle/gems` now
---
ext/extmk.rb | 13 +++++++------
template/exts.mk.tmpl | 2 +-
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/ext/extmk.rb b/ext/extmk.rb
index 4a087f294ac9..1da9e2704521 100755
--- a/ext/extmk.rb
+++ b/ext/extmk.rb
@@ -146,7 +146,7 @@ def extmake(target, basedir = 'ext', maybestatic = true)
top_srcdir = $top_srcdir
topdir = $topdir
hdrdir = $hdrdir
- prefix = "../" * (target.count("/")+1)
+ prefix = "../" * (basedir.count("/")+target.count("/")+1)
$top_srcdir = relative_from(top_srcdir, prefix)
$hdrdir = relative_from(hdrdir, prefix)
$topdir = prefix + $topdir
@@ -460,10 +460,11 @@ def $mflags.defined?(var)
end unless $extstatic
@gemname = nil
-if ARGV[0]
- ext_prefix, exts = ARGV.shift.split('/', 2)
+if exts = ARGV.shift
+ ext_prefix = exts[%r[\A(?>\.bundle/)?[^/]+(?:/(?=(.+)?)|\z)]]
+ exts = $1
$extension = [exts] if exts
- if ext_prefix == 'gems'
+ if ext_prefix.start_with?('.')
@gemname = exts
elsif exts
$static_ext.delete_if {|t, *| !File.fnmatch(t, exts)}
@@ -515,7 +516,7 @@ def $mflags.defined?(var)
exts.delete_if {|d| File.fnmatch?("-*", d)}
end
end
-ext_prefix = File.basename(ext_prefix)
+ext_prefix = ext_prefix[$top_srcdir.size+1..-2]
extend Module.new {
def timestamp_file(name, target_prefix = nil)
@@ -634,7 +635,7 @@ def initialize(src)
end
}
-Dir.chdir ".."
+Dir.chdir dir
unless $destdir.to_s.empty?
$mflags.defined?("DESTDIR") or $mflags << "DESTDIR=#{$destdir}"
end
diff --git a/template/exts.mk.tmpl b/template/exts.mk.tmpl
index 2f37f4480ac5..964939e365a1 100644
--- a/template/exts.mk.tmpl
+++ b/template/exts.mk.tmpl
@@ -25,7 +25,7 @@ macros["old_extensions"] = []
contpat = /(?>(?>[^\\\n]|\\.)*\\\n)*(?>[^\\\n]|\\.)*/
Dir.glob("{ext,.bundle/gems}/*/exts.mk") do |e|
- gem = /\Agems(?=\/)/ =~ e
+ gem = e.start_with?(".bundle/gems/")
s = File.read(e)
s.scan(/^(extensions|SUBMAKEOPTS|EXT[A-Z]+|MFLAGS|NOTE_[A-Z]+)[ \t]*=[ \t]*(#{contpat})$/o) do |n, v|
v.gsub!(/\\\n[ \t]*/, ' ')
From 6ea34cac22131d28a9cc50e7875e854aed9bdb88 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@ruby-lang.org>
Date: Wed, 6 Apr 2022 20:25:53 +0900
Subject: [PATCH 2/5] Retrieve configured gems info
---
template/configure-ext.mk.tmpl | 2 +-
template/exts.mk.tmpl | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/template/configure-ext.mk.tmpl b/template/configure-ext.mk.tmpl
index 6636a7759c54..8ba6b963e3ec 100644
--- a/template/configure-ext.mk.tmpl
+++ b/template/configure-ext.mk.tmpl
@@ -27,7 +27,7 @@ SCRIPT_ARGS = <%=script_args.gsub("#", "\\#")%>
EXTMK_ARGS = $(SCRIPT_ARGS) --gnumake=$(gnumake) --extflags="$(EXTLDFLAGS)" \
--make-flags="MINIRUBY='$(MINIRUBY)'"
-all: exts # gems
+all: exts gems
exts:
gems:
diff --git a/template/exts.mk.tmpl b/template/exts.mk.tmpl
index 964939e365a1..e544c4c88bd7 100644
--- a/template/exts.mk.tmpl
+++ b/template/exts.mk.tmpl
@@ -19,7 +19,7 @@ opt = OptionParser.new do |o|
o.on('--configure-exts=FILE') {|v| confexts = v}
o.order!(ARGV)
end
-confexts &&= File.read(confexts).scan(/^exts: (.*\.mk)/).flatten rescue nil
+confexts &&= File.read(confexts).scan(/^(?:ext|gem)s: (.*\.mk)/).flatten rescue nil
confexts ||= []
macros["old_extensions"] = []
@@ -30,7 +30,7 @@ Dir.glob("{ext,.bundle/gems}/*/exts.mk") do |e|
s.scan(/^(extensions|SUBMAKEOPTS|EXT[A-Z]+|MFLAGS|NOTE_[A-Z]+)[ \t]*=[ \t]*(#{contpat})$/o) do |n, v|
v.gsub!(/\\\n[ \t]*/, ' ')
next if v.empty?
- next if gem and n != "extensions"
+ next if n != "extensions"
n = "old_extensions" if n == "extensions" and !confexts.include?(e)
v = v.split
m = macros[n] ||= []
From be9d00ee7c72766551ba8c3530f1538034498a6a Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@ruby-lang.org>
Date: Wed, 6 Apr 2022 20:28:00 +0900
Subject: [PATCH 3/5] Move the target directory of bundled gems like as
rubygems
---
ext/extmk.rb | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/ext/extmk.rb b/ext/extmk.rb
index 1da9e2704521..a440af27fc5d 100755
--- a/ext/extmk.rb
+++ b/ext/extmk.rb
@@ -2,6 +2,9 @@
# -*- mode: ruby; coding: us-ascii -*-
# frozen_string_literal: false
+module Gem; end # only needs Gem::Platform
+require 'rubygems/platform'
+
# :stopdoc:
$extension = nil
$extstatic = nil
@@ -535,11 +538,12 @@ def create_makefile(*args, &block)
super(*args) do |conf|
conf.find do |s|
s.sub!(/^(TARGET_SO_DIR *= *)\$\(RUBYARCHDIR\)/) {
- "TARGET_GEM_DIR = $(extout)/gems/$(arch)/#{@gemname}\n"\
+ "TARGET_GEM_DIR = $(topdir)/.bundle/extensions/$(gem_platform)/$(ruby_version)/#{@gemname}\n"\
"#{$1}$(TARGET_GEM_DIR)$(target_prefix)"
}
end
conf.any? {|s| /^TARGET *= *\S/ =~ s} and conf << %{
+gem_platform = #{Gem::Platform.local}
# default target
all:
From c4daf8e445925695c34bab8bf5135dcd1e8575a3 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@ruby-lang.org>
Date: Wed, 6 Apr 2022 22:57:01 +0900
Subject: [PATCH 4/5] Obey spec file locations to rubygems
---
common.mk | 3 ++-
defs/gmake.mk | 2 +-
tool/gem-unpack.rb | 5 +++--
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/common.mk b/common.mk
index 7c552cba1e04..b4adb2729c0e 100644
--- a/common.mk
+++ b/common.mk
@@ -1359,10 +1359,11 @@ extract-gems$(gnumake:yes=-nongnumake): PHONY
$(Q) $(RUNRUBY) -C "$(srcdir)" \
-Itool -rgem-unpack -answ \
-e 'BEGIN {FileUtils.mkdir_p(d = ".bundle/gems")}' \
+ -e 'BEGIN {FileUtils.mkdir_p(s = ".bundle/specifications")}' \
-e 'gem, ver = *$$F' \
-e 'next if !ver or /^#/=~gem' \
-e 'g = "#{gem}-#{ver}"' \
- -e 'File.directory?("#{d}/#{g}") or Gem.unpack("gems/#{g}.gem", d)' \
+ -e 'File.directory?("#{d}/#{g}") or Gem.unpack("gems/#{g}.gem", d, s)' \
gems/bundled_gems
update-bundled_gems: PHONY
diff --git a/defs/gmake.mk b/defs/gmake.mk
index a625379a6804..27e3e21cc4d6 100644
--- a/defs/gmake.mk
+++ b/defs/gmake.mk
@@ -290,7 +290,7 @@ extract-gems: | $(patsubst %,.bundle/gems/%,$(bundled-gems))
$(ECHO) Extracting bundle gem $*...
$(Q) $(BASERUBY) -C "$(srcdir)" \
-Itool -rgem-unpack \
- -e 'Gem.unpack("gems/$(@F).gem", ".bundle/gems")'
+ -e 'Gem.unpack("gems/$(@F).gem", ".bundle/gems", ".bundle/specifications")'
$(srcdir)/.bundle/gems:
$(MAKEDIRS) $@
diff --git a/tool/gem-unpack.rb b/tool/gem-unpack.rb
index cb05719463f2..fe10b0e420fa 100644
--- a/tool/gem-unpack.rb
+++ b/tool/gem-unpack.rb
@@ -5,13 +5,14 @@
# This library is used by "make extract-gems" to
# unpack bundled gem files.
-def Gem.unpack(file, dir = nil)
+def Gem.unpack(file, dir = nil, spec_dir = nil)
pkg = Gem::Package.new(file)
spec = pkg.spec
target = spec.full_name
target = File.join(dir, target) if dir
pkg.extract_files target
- spec_file = File.join(target, "#{spec.name}-#{spec.version}.gemspec")
+ FileUtils.mkdir_p(spec_dir ||= target)
+ spec_file = File.join(spec_dir, "#{spec.name}-#{spec.version}.gemspec")
open(spec_file, 'wb') do |f|
f.print spec.to_ruby
end
From 3de652d8198be9cd2998c095903889a80e738275 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@ruby-lang.org>
Date: Thu, 7 Apr 2022 01:44:43 +0900
Subject: [PATCH 5/5] Install built gem extension binaries
---
tool/rbinstall.rb | 56 ++++++++++++++---------------------------------
1 file changed, 16 insertions(+), 40 deletions(-)
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
index 9d9b672be472..624961b4eee6 100755
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -858,6 +858,9 @@ class UnpackedInstaller < GemInstaller
def write_cache_file
end
+ def build_extensions
+ end
+
def shebang(bin_file_name)
path = File.join(gem_dir, spec.bindir, bin_file_name)
first_line = File.open(path, "rb") {|file| file.gets}
@@ -940,13 +943,12 @@ def ensure_writable_dir(dir)
install_default_gem('ext', srcdir, bindir)
end
-def load_gemspec(file, expanded = false)
+def load_gemspec(file, base = nil)
file = File.realpath(file)
code = File.read(file, encoding: "utf-8:-")
code.gsub!(/(?:`git[^\`]*`|%x\[git[^\]]*\])\.split\([^\)]*\)/m) do
files = []
- if expanded
- base = File.dirname(file)
+ if base
Dir.glob("**/*", File::FNM_DOTMATCH, base: base) do |n|
case File.basename(n); when ".", ".."; next; end
next if File.directory?(File.join(base, n))
@@ -959,7 +961,7 @@ def load_gemspec(file, expanded = false)
unless Gem::Specification === spec
raise TypeError, "[#{file}] isn't a Gem::Specification (#{spec.class} instead)."
end
- spec.loaded_from = file
+ spec.loaded_from = base ? File.join(base, File.basename(file)) : file
spec.files.reject! {|n| n.end_with?(".gemspec") or n.start_with?(".git")}
spec
@@ -1014,20 +1016,6 @@ def install_default_gem(dir, srcdir, bindir)
end
install?(:ext, :comm, :gem, :'bundled-gems') do
- if CONFIG['CROSS_COMPILING'] == 'yes'
- # The following hacky steps set "$ruby = BASERUBY" in tool/fake.rb
- $hdrdir = ''
- $extmk = nil
- $ruby = nil # ...
- ruby_path = $ruby + " -I#{Dir.pwd}" # $baseruby + " -I#{Dir.pwd}"
- else
- # ruby_path = File.expand_path(with_destdir(File.join(bindir, ruby_install_name)))
- ENV['RUBYLIB'] = nil
- ENV['RUBYOPT'] = nil
- ruby_path = File.expand_path(with_destdir(File.join(bindir, ruby_install_name))) + " --disable=gems -I#{with_destdir(archlibdir)}"
- end
- Gem.instance_variable_set(:@ruby, ruby_path) if Gem.ruby != ruby_path
-
gem_dir = Gem.default_dir
install_dir = with_destdir(gem_dir)
prepare "bundled gems", gem_dir
@@ -1047,40 +1035,28 @@ def install_default_gem(dir, srcdir, bindir)
:wrappers => true,
:format_executable => true,
}
- gem_ext_dir = "#$extout/gems/#{CONFIG['arch']}"
- extensions_dir = with_destdir(Gem::StubSpecification.gemspec_stub("", gem_dir, gem_dir).extensions_dir)
+
+ extensions_dir = Gem::StubSpecification.gemspec_stub("", gem_dir, gem_dir).extensions_dir
+ specifications_dir = File.join(gem_dir, "specifications")
+ build_dir = Gem::StubSpecification.gemspec_stub("", ".bundle", ".bundle").extensions_dir
File.foreach("#{srcdir}/gems/bundled_gems") do |name|
next if /^\s*(?:#|$)/ =~ name
next unless /^(\S+)\s+(\S+).*/ =~ name
gem_name = "#$1-#$2"
- path = "#{srcdir}/.bundle/gems/#{gem_name}/#{gem_name}.gemspec"
- if File.exist?(path)
- spec = load_gemspec(path)
- else
- path = "#{srcdir}/.bundle/gems/#{gem_name}/#$1.gemspec"
- next unless File.exist?(path)
- spec = load_gemspec(path, true)
- end
+ path = "#{srcdir}/.bundle/specifications/#{gem_name}.gemspec"
+ next unless File.exist?(path)
+ spec = load_gemspec(path, "#{srcdir}/.bundle/gems/#{gem_name}")
next unless spec.platform == Gem::Platform::RUBY
next unless spec.full_name == gem_name
- if !spec.extensions.empty? && CONFIG["EXTSTATIC"] == "static"
- puts "skip installation of #{spec.name} #{spec.version}; bundled gem with an extension library is not supported on --with-static-linked-ext"
- next
- end
spec.extension_dir = "#{extensions_dir}/#{spec.full_name}"
- if File.directory?(ext = "#{gem_ext_dir}/#{spec.full_name}")
- spec.extensions[0] ||= "-"
- end
package = RbInstall::DirPackage.new spec
ins = RbInstall::UnpackedInstaller.new(package, options)
puts "#{INDENT}#{spec.name} #{spec.version}"
ins.install
- unless $dryrun
- File.chmod($data_mode, File.join(install_dir, "specifications", "#{spec.full_name}.gemspec"))
- end
- unless spec.extensions.empty?
- install_recursive(ext, spec.extension_dir)
+ install_recursive("#{build_dir}/#{gem_name}", "#{extensions_dir}/#{gem_name}") do |src, dest|
+ # puts "#{INDENT} #{dest[extensions_dir.size+gem_name.size+2..-1]}"
+ install src, dest, :mode => (File.executable?(src) ? $prog_mode : $data_mode)
end
installed_gems[spec.full_name] = true
end

View File

@ -169,8 +169,8 @@ Patch19: ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch
Patch20: ruby-bundler-2.4.0-bundle-update-bundler-test-in-ruby.patch
# Workaround gem binary extensions build and installation issues.
# https://bugs.ruby-lang.org/issues/18373
# https://github.com/ruby/ruby/pull/5743
Patch21: ruby-3.1.1-Properly-build-binary-gem-extensions.patch
# https://github.com/ruby/ruby/pull/5774
Patch21: ruby-3.2.0-Build-extension-libraries-in-bundled-gems.patch
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
Suggests: rubypick
@ -636,6 +636,12 @@ rm -rf ext/fiddle/libffi*
%patch7 -p1
%patch19 -p1
%patch20 -p1
# Once the upstream tarball contains the files on the right place, this code
# won't be necessary. This should happen at the same moment when the patch21
# is not needed anymore.
mkdir .bundle/specifications
find .bundle/gems -name '*-[0-9]*.gemspec' -exec cp -t .bundle/specifications/ {} +
%patch21 -p1
# Provide an example of usage of the tapset:
@ -1495,6 +1501,7 @@ mv test/fiddle/test_import.rb{,.disable}
%changelog
* Thu Apr 14 2022 Vít Ondruch <vondruch@redhat.com> - 3.1.2-164
- Upgrade to Ruby 3.1.2.
- Use upstream patch for correct build of gem extensions.
* Mon Apr 04 2022 Vít Ondruch <vondruch@redhat.com> - 3.1.1-163
- Properly build binary gem extensions.