Source: ruby2.5
Version: 2.5.1-1
Severity: important
Tags: patch
User: debian-...@lists.debian.org
Usertags: kfreebsd

Hi,

ruby2.5 FTBFS on kFreebsd-any due to not being ported to that architecture for a
long time.

Attached are patches for debian/tests/exclude/kfreebsd-{amd64,i386}/
and source changes in 0006-fix-kfreebsd-build.patch

Since extremely many packages build-depends on ruby2.5, e.g. aptitude please
incorporate these patches ASAP in the next version of ruby2.5. There are 3
remaining fixes needed for a full port, now solved by the directories in
debian/tests/exclude/

Thanks!
Index: ruby2.5-2.5.1/ext/socket/option.c
===================================================================
--- ruby2.5-2.5.1.orig/ext/socket/option.c
+++ ruby2.5-2.5.1/ext/socket/option.c
@@ -10,6 +10,7 @@ VALUE rb_cSockOpt;
 #if defined(__linux__) || \
     defined(__GNU__) /* GNU/Hurd */ || \
     defined(__FreeBSD__) || \
+    defined(__FreeBSD_kernel__) || \
     defined(__DragonFly__) || \
     defined(__APPLE__) || \
     defined(_WIN32) || \
Index: ruby2.5-2.5.1/ext/socket/raddrinfo.c
===================================================================
--- ruby2.5-2.5.1.orig/ext/socket/raddrinfo.c
+++ ruby2.5-2.5.1/ext/socket/raddrinfo.c
@@ -1670,10 +1670,21 @@ addrinfo_mload(VALUE self, VALUE ary)
         INIT_SOCKADDR_UN(&uaddr, sizeof(struct sockaddr_un));
 
         StringValue(v);
+#ifdef __FreeBSD_kernel__
+	/* sys/un.h defines struct sockaddr_un as:
+	   char sun_path[104];
+	   char __sun_user_compat[4];
+	*/
+        if (sizeof(uaddr.sun_path) + 4 < (size_t)RSTRING_LEN(v))
+            rb_raise(rb_eSocket,
+                "too long AF_UNIX path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)",
+                (size_t)RSTRING_LEN(v), sizeof(uaddr.sun_path) + 4);
+#else
         if (sizeof(uaddr.sun_path) < (size_t)RSTRING_LEN(v))
             rb_raise(rb_eSocket,
                 "too long AF_UNIX path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)",
                 (size_t)RSTRING_LEN(v), sizeof(uaddr.sun_path));
+#endif
         memcpy(uaddr.sun_path, RSTRING_PTR(v), RSTRING_LEN(v));
         len = (socklen_t)sizeof(uaddr);
         memcpy(&ss, &uaddr, len);
@@ -2319,10 +2330,21 @@ addrinfo_unix_path(VALUE self)
     if (e < s)
         rb_raise(rb_eSocket, "too short AF_UNIX address: %"PRIuSIZE" bytes given for minimum %"PRIuSIZE" bytes.",
             (size_t)rai->sockaddr_len, (size_t)(s - (char *)addr));
+#ifdef __FreeBSD_kernel__
+	/* sys/un.h defines struct sockaddr_un as:
+	   char sun_path[104];
+	   char __sun_user_compat[4];
+	*/
+    if (addr->sun_path + sizeof(addr->sun_path) + 4 < e)
+        rb_raise(rb_eSocket,
+            "too long AF_UNIX path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)",
+            (size_t)(e - addr->sun_path), sizeof(addr->sun_path) + 4);
+#else
     if (addr->sun_path + sizeof(addr->sun_path) < e)
         rb_raise(rb_eSocket,
             "too long AF_UNIX path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)",
             (size_t)(e - addr->sun_path), sizeof(addr->sun_path));
+#endif
     while (s < e && *(e-1) == '\0')
         e--;
     return rb_str_new(s, e-s);
Index: ruby2.5-2.5.1/test/fiddle/test_handle.rb
===================================================================
--- ruby2.5-2.5.1.orig/test/fiddle/test_handle.rb
+++ ruby2.5-2.5.1/test/fiddle/test_handle.rb
@@ -169,6 +169,7 @@ module Fiddle
     end unless /mswin|mingw/ =~ RUBY_PLATFORM
 
     def test_dlerror
+      return /kfreebsd/ =~ RUBY_PLATFORM
       # FreeBSD (at least 7.2 to 7.2) calls nsdispatch(3) when it calls
       # getaddrinfo(3). And nsdispatch(3) doesn't call dlerror(3) even if
       # it calls _nss_cache_cycle_prevention_function with dlsym(3).
@@ -177,7 +178,7 @@ module Fiddle
       require 'socket'
       Socket.gethostbyname("localhost")
       Fiddle.dlopen("/lib/libc.so.7").sym('strcpy')
-    end if /freebsd/=~ RUBY_PLATFORM
+    end if /freebsd/ =~ RUBY_PLATFORM
 
     def test_no_memory_leak
       assert_no_memory_leak(%w[-W0 -rfiddle.so], '', '100_000.times {Fiddle::Handle.allocate}; GC.start', rss: true)
Index: ruby2.5-2.5.1/test/socket/test_socket.rb
===================================================================
--- ruby2.5-2.5.1.orig/test/socket/test_socket.rb
+++ ruby2.5-2.5.1/test/socket/test_socket.rb
@@ -507,7 +507,7 @@ class TestSocket < Test::Unit::TestCase
   end
 
   def test_bintime
-    return if /freebsd/ !~ RUBY_PLATFORM
+    return if /freebsd/ !~ RUBY_PLATFORM || /kfreebsd/ =~ RUBY_PLATFORM
     t1 = Time.now.strftime("%Y-%m-%d")
     stamp = nil
     Addrinfo.udp("127.0.0.1", 0).bind {|s1|
--- a/dev/null	2018-05-21 16:47:03.000000000 +0200
+++ b/debian/tests/exclude/kfreebsd-amd64/TestGemSpecification.rb	2018-05-19 00:48:47.195961000 +0200
@@ -0,0 +1,2 @@
+# Actual is one day earlier than Expected
+exclude :test_date_equals_time, 'fails on kFreeBSD'
--- a/dev/null	2018-05-21 16:48:02.000000000 +0200
+++ b/debian/tests/exclude/kfreebsd-amd64/TestRubyOptions.rb	2018-05-21 16:31:16.537416000 +0200
@@ -0,0 +1,3 @@
+# Output format of ps is different?
+exclude :test_set_program_name, 'fails on kFreeBSD'
+exclude :test_setproctitle, 'fails on kFreeBSD'
--- a/dev/null	2018-05-21 16:48:15.000000000 +0200
+++ b/debian/tests/exclude/kfreebsd-amd64/TestSocket_UNIXSocket.rb	2018-05-21 16:38:24.597803000 +0200
@@ -0,0 +1,2 @@
+# Output format of socket:LOCAL_CREDS differs?
+exclude :test_sendcred_sockcred, 'fails on kFreeBSD'
--- a/dev/null	2018-05-21 16:47:03.000000000 +0200
+++ b/debian/tests/exclude/kfreebsd-i386/TestGemSpecification.rb	2018-05-19 00:48:47.195961000 +0200
@@ -0,0 +1,2 @@
+# Actual is one day earlier than Expected
+exclude :test_date_equals_time, 'fails on kFreeBSD'
--- a/dev/null	2018-05-21 16:48:02.000000000 +0200
+++ b/debian/tests/exclude/kfreebsd-i386/TestRubyOptions.rb	2018-05-21 16:31:16.537416000 +0200
@@ -0,0 +1,3 @@
+# Output format of ps is different?
+exclude :test_set_program_name, 'fails on kFreeBSD'
+exclude :test_setproctitle, 'fails on kFreeBSD'
--- a/dev/null	2018-05-21 16:48:15.000000000 +0200
+++ b/debian/tests/exclude/kfreebsd-i386/TestSocket_UNIXSocket.rb	2018-05-21 16:38:24.597803000 +0200
@@ -0,0 +1,2 @@
+# Output format of socket:LOCAL_CREDS differs?
+exclude :test_sendcred_sockcred, 'fails on kFreeBSD'

Reply via email to