[bug#78683,v2,7/7] gnu: ruby-chunky-png: Fix build with ruby@3.2.

Message ID 20250605011335.4842-7-ngraves@ngraves.fr
State New
Headers
Series [bug#78683,v2,1/7] gnu: Add ruby-sqlite3-1.4. |

Commit Message

Nicolas Graves June 5, 2025, 1:13 a.m. UTC
  * gnu/packages/ruby-xyz.scm (ruby-chunky-png)[source]: Record patch.
* gnu/local.mk: Record patch.
* gnu/packages/patches/ruby-chunky-png-ruby-3-2-support.patch: Record
patch.
---
 gnu/local.mk                                  |  1 +
 .../ruby-chunky-png-ruby-3-2-support.patch    | 29 +++++++++++++++++++
 gnu/packages/ruby-xyz.scm                     |  5 ++--
 3 files changed, 33 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/patches/ruby-chunky-png-ruby-3-2-support.patch
  

Comments

Andreas Enge June 10, 2025, 8:19 p.m. UTC | #1
Hello,

I have no particular knowledge about ruby packages and am rather cc-ing
the ruby team (aka Chris Baines) for advice.

But since you asked my opinion at
   https://issues.guix.gnu.org/78676
I am not convinced by renaming ruby-2.7 to ruby/pinned, which is much
less explicit.

Andreas
  
Nicolas Graves June 17, 2025, 8:53 a.m. UTC | #2
Is Ruby still the next branch to merge?

Could you apply the series? I removed the ruby/pinned patch.

I rebased it locally, I probably have to send a v3.

Nicolas

On 2025-06-10 22:19, Andreas Enge wrote:

> Hello,
>
> I have no particular knowledge about ruby packages and am rather cc-ing
> the ruby team (aka Chris Baines) for advice.
>
> But since you asked my opinion at
>    https://issues.guix.gnu.org/78676
> I am not convinced by renaming ruby-2.7 to ruby/pinned, which is much
> less explicit.
>
> Andreas
>
>
>
>
>
  
Andreas Enge June 17, 2025, 3:59 p.m. UTC | #3
Hello,

Am Tue, Jun 17, 2025 at 10:53:55AM +0200 schrieb Nicolas Graves:
> Is Ruby still the next branch to merge?

yes, ruby is being built now.

> Could you apply the series? I removed the ruby/pinned patch.
> I rebased it locally, I probably have to send a v3.

Okay, I have applied the 7 patches of the v2 (which is actually the
third version...), and for good measure rebased on
   9aad3c4873b98ab7e55b982a057709e43f89b49d

Closing the issue.

Andreas
  

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index f6d5af3e93..36a9fefa1f 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2214,6 +2214,7 @@  dist_patch_DATA =						\
   %D%/packages/patches/rottlog-direntry.patch 			\
   %D%/packages/patches/ruby-actionpack-remove-browser-tests.patch	\
   %D%/packages/patches/ruby-asciidoctor-pdf-support-prawn-svg-0_36.patch	\
+  %D%/packages/patches/ruby-chunky-png-ruby-3-2-support.patch	\
   %D%/packages/patches/ruby-hiredis-use-system-hiredis.patch	\
   %D%/packages/patches/ruby-hydra-minimal-no-byebug.patch	\
   %D%/packages/patches/ruby-anystyle-data-immutable-install.patch	\
diff --git a/gnu/packages/patches/ruby-chunky-png-ruby-3-2-support.patch b/gnu/packages/patches/ruby-chunky-png-ruby-3-2-support.patch
new file mode 100644
index 0000000000..75d08c9fc8
--- /dev/null
+++ b/gnu/packages/patches/ruby-chunky-png-ruby-3-2-support.patch
@@ -0,0 +1,29 @@ 
+From 8e6f5934541833f15664398f90331f3724e40933 Mon Sep 17 00:00:00 2001
+From: Mamoru TASAKA <mtasaka@fedoraproject.org>
+Date: Tue, 15 Nov 2022 23:22:20 +0900
+Subject: [PATCH] ruby3_2 fix: check if object responds to regex_match op
+
+Object#=~ is already deprecated since ruby2.6 and will be
+removed from ruby3.2. As the result, Array no longer
+respond to =~ from ruby3.2, for example.
+
+Check if the target object really respond to =~ .
+
+Closes #168
+---
+ lib/chunky_png/vector.rb | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/lib/chunky_png/vector.rb b/lib/chunky_png/vector.rb
+index 4ef965f..034104c 100644
+--- a/lib/chunky_png/vector.rb
++++ b/lib/chunky_png/vector.rb
+@@ -166,7 +166,7 @@ def dimension
+     # @return [Array<ChunkyPNG::Point>] The list of points interpreted from the input array.
+     def self.multiple_from_array(source)
+       return [] if source.empty?
+-      if source.first.is_a?(Numeric) || source.first =~ /^\d+$/
++      if source.first.is_a?(Numeric) || ( source.first.respond_to?(:=~) && source.first =~ /^\d+$/ )
+         raise ArgumentError, "The points array is expected to have an even number of items!" if source.length % 2 != 0
+ 
+         points = []
diff --git a/gnu/packages/ruby-xyz.scm b/gnu/packages/ruby-xyz.scm
index db81f7ef4d..7697a55858 100644
--- a/gnu/packages/ruby-xyz.scm
+++ b/gnu/packages/ruby-xyz.scm
@@ -1852,11 +1852,12 @@  (define-public ruby-chunky-png
              (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "05qwj72dy2fcy0n2jnf3bfriybfj36m7s6pv9xash6295dbcp901"))))
+        (base32 "05qwj72dy2fcy0n2jnf3bfriybfj36m7s6pv9xash6295dbcp901"))
+       (patches
+        (search-patches "ruby-chunky-png-ruby-3-2-support.patch"))))
     (build-system ruby-build-system)
     (arguments
      (list
-      #:ruby ruby-3.1
       #:test-target "spec"
       #:phases
       #~(modify-phases %standard-phases