Subject: [bug#74609] [PATCH 06/21] gnu: Add mono-2.4.2.

From: Efraim Flashner <[email-masked]>
Date: Mon, 16 Dec 2024 19:26:29 +0200

From: unmush <[email-masked]>

* gnu/packages/dotnet.scm (mono-2.4.2): New variable.
* gnu/packages/patches/mono-2.4.2.3-fixes.patch: New patch.
* gnu/local.mk (dist_patch_DATA): Register it.

Change-Id: I14ff01d5fb3c3f23c83f8518990a79329490d3b9
---
 gnu/local.mk                                  |  1 +
 gnu/packages/dotnet.scm                       | 53 +++++++++++++++++
 gnu/packages/patches/mono-2.4.2.3-fixes.patch | 59 +++++++++++++++++++
 3 files changed, 113 insertions(+)
 create mode 100644 gnu/packages/patches/mono-2.4.2.3-fixes.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 38e98386d20..a46dd1d1999 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1821,6 +1821,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/mono-1.2.6-bootstrap.patch		\
   %D%/packages/patches/mono-1.9.1-add-MONO_CREATE_IMAGE_VERSION.patch		\
   %D%/packages/patches/mono-1.9.1-fixes.patch			\
+  %D%/packages/patches/mono-2.4.2.3-fixes.patch			\
   %D%/packages/patches/mosaicatcher-unbundle-htslib.patch	\
   %D%/packages/patches/mrrescue-support-love-11.patch		\
   %D%/packages/patches/mtools-mformat-uninitialized.patch	\
diff --git a/gnu/packages/dotnet.scm b/gnu/packages/dotnet.scm
index 3a3bcb3c940..ab91f590992 100644
--- a/gnu/packages/dotnet.scm
+++ b/gnu/packages/dotnet.scm
@@ -421,3 +421,56 @@ (define-public mono-1.9.1
                 (patch-shebang "mono/tests/test-driver")))))
        ((#:tests? _ #f) #f)
        ((#:parallel-tests? _ #f) #f)))))
+
+(define-public mono-2.4.2
+  (package
+    (inherit mono-1.9.1)
+    (version "2.4.2.3")
+    (name "mono")
+    (source (origin
+              (method git-fetch)
+              (uri
+               (git-reference
+                (url "https://gitlab.winehq.org/mono/mono.git")
+                (commit (string-append "mono-" "2-4-2-3"))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0mnrk17rd9c5rh30dh82a39c9ak1ns998b41ivprvy7m068skpda"))
+              (modules '((guix build utils)
+                         (ice-9 string-fun)))
+              (snippet prepare-mono-source)
+              (patches
+               (search-patches "mono-2.4.2.3-fixes.patch"))))
+    (native-inputs (modify-inputs (package-native-inputs mono-1.9.1)
+                     (replace "mono" mono-1.9.1)))
+    (inputs (modify-inputs (package-inputs mono-1.9.1)
+              (append gettext-minimal)))
+    (arguments
+     (substitute-keyword-arguments (package-arguments mono-1.9.1)
+       ((#:tests? _ #f)
+        ;; When it tries building iltests.il in mono/mini, it gets: error
+        ;; CS0006: cannot find metadata file `TestDriver.dll'.  It builds fine
+        ;; outside of the build environment, but later tests fail, and I can't
+        ;; be bothered to figure out what's causing ilasm to not find
+        ;; TestDriver.dll.
+        #f)
+       ((#:parallel-build? _) #t)
+       ((#:phases phases #~%standard-phases)
+        #~(modify-phases #$phases
+            (add-before 'bootstrap 'patch-sub-autogen.sh-shebang
+              (lambda _
+                (patch-shebang "./eglib/autogen.sh")))))))
+    (license (list
+              ;; most of mcs/tools, mono/man, most of mcs/class, tests by
+              ;; default, mono/eglib
+              ;; mcs/mcs, mcs/gmcs (dual-licensed GPL)
+              ;; samples
+              license:x11
+              ;; mcs/mcs, mcs/gmcs (dual-licensed X11)
+              ;; some of mcs/tools
+              license:gpl1+ ;; note: ./mcs/LICENSE.GPL specifies no version
+              ;; mono/mono (the mono VM, I think they meant mono/mini)
+              license:lgpl2.0+ ;; note: ./mcs/LICENSE.LGPL specifies no version
+              ;; mcs/jay
+              license:bsd-4))))
diff --git a/gnu/packages/patches/mono-2.4.2.3-fixes.patch b/gnu/packages/patches/mono-2.4.2.3-fixes.patch
new file mode 100644
index 00000000000..13cff774506
--- /dev/null
+++ b/gnu/packages/patches/mono-2.4.2.3-fixes.patch
@@ -0,0 +1,59 @@
+diff --git a/data/mono.pc.in b/data/mono.pc.in
+index 6da0960db2d..d43bb187218 100644
+--- a/data/mono.pc.in
++++ b/data/mono.pc.in
+@@ -7,6 +7,6 @@ sysconfdir=@sysconfdir@
+ Name: Mono
+ Description: Mono Runtime
+ Version: @VERSION@
+-Requires: glib-2.0 gthread-2.0
++Requires: glib-2.0 gthread-2.0 bdw-gc
+ Libs: -L${libdir} @export_ldflags@ -lmono @libmono_ldflags@
+ Cflags: -I${includedir} @libmono_cflags@
+diff --git a/mono-uninstalled.pc.in b/mono-uninstalled.pc.in
+index 7fa3f12dc91..2a0734362fd 100644
+--- a/mono-uninstalled.pc.in
++++ b/mono-uninstalled.pc.in
+@@ -1,6 +1,6 @@
+ Name: Mono
+ Description: Mono Runtime
+ Version: @VERSION@
+-Requires: glib-2.0 gthread-2.0
++Requires: glib-2.0 gthread-2.0 bdw-gc
+ Libs: -L@mono_build_root@/mono/mini/.libs @export_ldflags@ -lmono @libmono_ldflags@
+ Cflags: -I@abs_top_srcdir@ -I@abs_top_srcdir@/mono @libmono_cflags@
+diff --git a/mono/metadata/Makefile.am b/mono/metadata/Makefile.am
+index 83f8532369b..3fca7fc13b9 100644
+--- a/mono/metadata/Makefile.am
++++ b/mono/metadata/Makefile.am
+@@ -171,7 +171,6 @@ libmonoruntimeinclude_HEADERS = \
+ 	object.h	\
+ 	exception.h	\
+ 	profiler.h	\
+-	appdomain.h	\
+ 	mono-config.h	\
+ 	debug-helpers.h	\
+ 	mempool.h
+diff --git a/mono/mini/driver.c b/mono/mini/driver.c
+index 48ca2d96899..9fb3512200b 100644
+--- a/mono/mini/driver.c
++++ b/mono/mini/driver.c
+@@ -1236,6 +1236,7 @@ mono_main (int argc, char* argv[])
+ #endif
+ 	if (!g_thread_supported ())
+ 		g_thread_init (NULL);
++        GC_allow_register_threads();
+ 
+ 	if (mono_running_on_valgrind () && getenv ("MONO_VALGRIND_LEAK_CHECK")) {
+ 		GMemVTable mem_vtable;
+diff --git a/runtime/Makefile.am b/runtime/Makefile.am
+index 0e876e2a491..b9cd0a99d9e 100644
+--- a/runtime/Makefile.am
++++ b/runtime/Makefile.am
+@@ -1,6 +1,3 @@
+-# hack to prevent 'check' from depending on 'all'
+-AUTOMAKE_OPTIONS = cygnus
+-
+ tmpinst = _tmpinst
+ 
+ noinst_SCRIPTS = mono-wrapper monodis-wrapper
-- 
Efraim Flashner   <[email-masked]>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted