ruby: clean-up after ruby_2_7 removal

This commit is contained in:
ajs124 2023-12-03 14:09:56 +01:00
parent 12f45e5dc9
commit ac0d3ce9ac
2 changed files with 2 additions and 109 deletions

View File

@ -20,7 +20,6 @@ let
generic = { version, hash, cargoHash ? null }: let
ver = version;
atLeast30 = lib.versionAtLeast ver.majMin "3.0";
atLeast31 = lib.versionAtLeast ver.majMin "3.1";
atLeast32 = lib.versionAtLeast ver.majMin "3.2";
# https://github.com/ruby/ruby/blob/v3_2_2/yjit.h#L21
@ -84,7 +83,7 @@ let
++ (op fiddleSupport libffi)
++ (ops cursesSupport [ ncurses readline ])
++ (op zlibSupport zlib)
++ (op (atLeast30 && opensslSupport) openssl)
++ (op opensslSupport openssl)
++ (op gdbmSupport gdbm)
++ (op yamlSupport libyaml)
# Looks like ruby fails to build on darwin without readline even if curses
@ -102,7 +101,7 @@ let
enableParallelInstalling = false;
patches = op (lib.versionOlder ver.majMin "3.1") ./do-not-regenerate-revision.h.patch
++ op (atLeast30 && useBaseRuby) (
++ op useBaseRuby (
if atLeast32 then ./do-not-update-gems-baseruby-3.2.patch
else ./do-not-update-gems-baseruby.patch
)
@ -113,21 +112,6 @@ let
hash = "sha256-43hI9L6bXfeujgmgKFVmiWhg7OXvshPCCtQ4TxqK1zk=";
})
]
++ ops (!atLeast30 && rubygemsSupport) [
# We upgrade rubygems to a version that isn't compatible with the
# ruby 2.7 installer. Backport the upstream fix.
./rbinstall-new-rubygems-compat.patch
# Ruby prior to 3.0 has a bug the installer (tools/rbinstall.rb) but
# the resulting error was swallowed. Newer rubygems no longer swallows
# this error. We upgrade rubygems when rubygemsSupport is enabled, so
# we have to fix this bug to prevent the install step from failing.
# See https://github.com/ruby/ruby/pull/2930
(fetchpatch {
url = "https://github.com/ruby/ruby/commit/261d8dd20afd26feb05f00a560abd99227269c1c.patch";
hash = "sha256-HqfaevMYuIVOsdEr+CnjnUqr2IrH5fkW2uKzzoqIMXM=";
})
]
++ ops atLeast31 [
# When using a baseruby, ruby always sets "libdir" to the build
# directory, which nix rejects due to a reference in to /build/ in
@ -154,10 +138,6 @@ let
sed -i configure.ac -e '/config.guess/d'
cp --remove-destination ${config}/config.guess tool/
cp --remove-destination ${config}/config.sub tool/
'' + opString (!atLeast30) ''
# Make the build reproducible for ruby <= 2.7
# See https://github.com/ruby/io-console/commit/679a941d05d869f5e575730f6581c027203b7b26#diff-d8422f096931c58d4463e2489f62a228b0f24f0492950ba88c8c89a0d741cfe6
sed -i ext/io/console/io-console.gemspec -e '/s\.date/d'
'';
configureFlags = [

View File

@ -1,87 +0,0 @@
From 8e85d27f9ccfe152fc1b891c19f125915a907493 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
Date: Tue, 1 Oct 2019 12:03:33 +0200
Subject: [PATCH] Use `Gem::Package` like object instead of monkey patching.
1. This is similar to what RubyGems does and it is less magic [[1]].
2. It avoids deprecated code paths in RubyGems [[2]].
[1]: https://github.com/rubygems/rubygems/blob/92892bbc3adba86a90756c385433835f6761b8da/lib/rubygems/installer.rb#L151
[2]: https://github.com/rubygems/rubygems/blob/92892bbc3adba86a90756c385433835f6761b8da/lib/rubygems/installer.rb#L187
(cherry picked from commit e960ef6f18a25c637c54f00c75bb6c24f8ab55d0)
---
tool/rbinstall.rb | 47 +++++++++++++++++++++++++++--------------------
1 file changed, 27 insertions(+), 20 deletions(-)
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
index 060390626f..28ae8c409a 100755
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -710,28 +710,34 @@ def remove_prefix(prefix, string)
end
end
- class UnpackedInstaller < Gem::Installer
- module DirPackage
- def extract_files(destination_dir, pattern = "*")
- path = File.dirname(@gem.path)
- return if path == destination_dir
- File.chmod(0700, destination_dir)
- mode = pattern == "bin/*" ? $script_mode : $data_mode
- spec.files.each do |f|
- src = File.join(path, f)
- dest = File.join(without_destdir(destination_dir), f)
- makedirs(dest[/.*(?=\/)/m])
- install src, dest, :mode => mode
- end
- File.chmod($dir_mode, destination_dir)
+ class DirPackage
+ attr_reader :spec
+
+ attr_accessor :dir_mode
+ attr_accessor :prog_mode
+ attr_accessor :data_mode
+
+ def initialize(spec)
+ @spec = spec
+ @src_dir = File.dirname(@spec.loaded_from)
+ end
+
+ def extract_files(destination_dir, pattern = "*")
+ path = @src_dir
+ return if path == destination_dir
+ File.chmod(0700, destination_dir)
+ mode = pattern == "bin/*" ? $script_mode : $data_mode
+ spec.files.each do |f|
+ src = File.join(path, f)
+ dest = File.join(without_destdir(destination_dir), f)
+ makedirs(dest[/.*(?=\/)/m])
+ install src, dest, :mode => mode
end
+ File.chmod($dir_mode, destination_dir)
end
+ end
- def initialize(spec, *options)
- super(spec.loaded_from, *options)
- @package.extend(DirPackage).spec = spec
- end
-
+ class UnpackedInstaller < Gem::Installer
def write_cache_file
end
@@ -890,7 +896,8 @@ def install_default_gem(dir, srcdir)
if File.directory?(ext = "#{gem_ext_dir}/#{spec.full_name}")
spec.extensions[0] ||= "-"
end
- ins = RbInstall::UnpackedInstaller.new(spec, options)
+ package = RbInstall::DirPackage.new spec
+ ins = RbInstall::UnpackedInstaller.new(package, options)
puts "#{INDENT}#{spec.name} #{spec.version}"
ins.install
File.chmod($data_mode, File.join(install_dir, "specifications", "#{spec.full_name}.gemspec"))
--
2.35.1