Subject: bug#50677: [PATCH] Minetest basic_materials really depends on moreores

From: Vivien Kraus <[email-masked]>
Date: Sun, 19 Sep 2021 20:54:02 +0200

Hello,

Le dimanche 19 septembre 2021 à 19:40 +0200, Maxime Devos a écrit :
> > + (version "v2.1.0")
> 
> Versions in guix don't use any leading "v" prefix.  If I'm not
> mistaken,
> Ludovic applied the patched to remove them automatically.
Right, I just had not guix pulled lately, I confirm it works with a
more recent guix version.

> > /share/minetest/mods/moreores/_config.txt
> 
> Is this "_config.txt" file moreores-specific?  If not, maybe
> minetest-mod-build-system
> could be modified to install these files by default?
I don’t know, but a quick web search for:

   minetest mod "_config.txt"

gave me 2 hits, one for moreores, and one for moreblocks, by the same
author. I supposed it is an author preference.

I forgot to say, I could not figure out why the package did not build,
because the check phase in the minetest build system stops after the
first error line of output, which only stated that there was a problem
with init.lua. I had to disable the error line detection in the build
system implementation to know it was a problem with this file. So, I
figured out that what we need to do is gather all error lines, until
either the server stops or starts despite the error, and fail only
then.

I prefer the exceptions API because it can handle multiple lines of
errors while displaying them cleanly (unlike the error function, that
displays an ugly ~a and prints the arguments on 1 line). But, it’s only
for the "new" guile 3.0.

What do you think?

Vivien
From eeb9c3a599aa07b36bd8b8ca8000ad6ef594dd99 Mon Sep 17 00:00:00 2001
From: Vivien Kraus <[email-masked]>
Date: Sun, 19 Sep 2021 17:00:45 +0200
Subject: [PATCH 3/3] gnu: minetest-basic-materials: Depend on
 minetest-moreores.

* minetest.scm (minetest-basic-materials): Add minetest-moreores as a propagated input.
---
 gnu/packages/minetest.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gnu/packages/minetest.scm b/gnu/packages/minetest.scm
index de1415097d..666f78c6ba 100644
--- a/gnu/packages/minetest.scm
+++ b/gnu/packages/minetest.scm
@@ -230,6 +230,10 @@ numeric identifier TOPIC-ID on the official Minetest forums."
         (base32 "0v6l3lrjgshy4sccjhfhmfxc3gk0cdy73qb02i9wd2vw506v5asx"))
        (file-name (git-file-name name version))))
     (build-system minetest-mod-build-system)
+    (propagated-inputs
+     ;; basic_materials:silver_wire cannot be crafted without
+     ;; moreores:silver_ingot.
+     `(("minetest-moreores" ,minetest-moreores)))
     (home-page (minetest-topic 21000))
     (synopsis "Some \"basic\" materials and items for other Minetest mods to use")
     (description
-- 
2.33.0

From d19f2812f8b77fc2896ff1b8b42b9d99efb42a0c Mon Sep 17 00:00:00 2001
From: Vivien Kraus <[email-masked]>
Date: Sun, 19 Sep 2021 16:58:53 +0200
Subject: [PATCH 2/3] gnu: Add minetest-moreores.

* gnu/packages/minetest.scm (minetest-moreores): New variable.
---
 gnu/packages/minetest.scm | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/gnu/packages/minetest.scm b/gnu/packages/minetest.scm
index fd1439d4d2..de1415097d 100644
--- a/gnu/packages/minetest.scm
+++ b/gnu/packages/minetest.scm
@@ -187,6 +187,34 @@ numeric identifier TOPIC-ID on the official Minetest forums."
   (string-append "https://forum.minetest.net/viewtopic.php?t="
                  (number->string topic-id)))
 
+(define-public minetest-moreores
+  (package
+    (name "minetest-moreores")
+    (version "2.1.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/minetest-mods/moreores")
+             (commit "0b6f669df4c9b7771c03e0e6ba8effb471cdfcae")))
+       (sha256 (base32 "1chfqbc6bb27aacjc67j5l5wcdvmcsvk2rfmangipd7nwini3y34"))
+       (file-name (git-file-name name version))))
+    (build-system minetest-mod-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'install 'install-_config.txt
+           (lambda* _
+             (copy-file
+              "_config.txt"
+              (string-append %output "/share/minetest/mods/moreores/_config.txt"))
+             #t)))))
+    (home-page (minetest-topic 549))
+    (synopsis "Adds new ore types")
+    (description "More ores for Minetest.")
+    (license license:zlib)
+    (properties `((upstream-name . "Calinou/moreores")))))
+
 (define-public minetest-basic-materials
   (package
     (name "minetest-basic-materials")
-- 
2.33.0

From 48095aa751cef4202e280c2d0ffa35a8d1cb5c12 Mon Sep 17 00:00:00 2001
From: Vivien Kraus <[email-masked]>
Date: Sun, 19 Sep 2021 20:03:10 +0200
Subject: [PATCH 1/3] guix: minetest-build-system: Report all error lines
 before failing

* minetest-build-system.scm (check): Report all error lines before failing.
---
 guix/build/minetest-build-system.scm | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/guix/build/minetest-build-system.scm b/guix/build/minetest-build-system.scm
index 477cc3d1d0..badc45112b 100644
--- a/guix/build/minetest-build-system.scm
+++ b/guix/build/minetest-build-system.scm
@@ -23,6 +23,7 @@
   #:use-module (ice-9 rdelim)
   #:use-module (ice-9 receive)
   #:use-module (ice-9 regex)
+  #:use-module (ice-9 exceptions)
   #:use-module ((guix build gnu-build-system) #:prefix gnu:)
   #:use-module ((guix build copy-build-system) #:prefix copy:)
   #:export (%standard-phases
@@ -199,20 +200,25 @@ auth_backend = sqlite3
         (define (stop? line)
           (and (string? line)
                (string-contains line "ACTION[Server]: singleplayer [127.0.0.1] joins game.")))
-        (let loop ()
-          (match (read-line port)
-            ((? error? line)
-             (error "minetest raised an error: ~a" line))
-            ((? stop?)
+        (let loop ((errors '()))
+          (match `(,(read-line port) ,errors)
+            (((? error? line) errors)
+             (loop `(,line ,@errors)))
+            (((? string? line) errors)
+             (display line)
+             (newline)
+             (loop errors))
+            (((? stop?) ())
              (kill pid SIGINT)
              (close-port port)
              (waitpid pid))
-            ((? string? line)
-             (display line)
-             (newline)
-             (loop))
-            ((? eof-object?)
-             (error "minetest didn't start"))))))))
+            (((? eof-object?) ())
+             (error "minetest didn't start"))
+            (((or (? stop?) (? eof-object?)) errors)
+             (raise-exception
+              (apply make-exception
+                     (map make-exception-with-message
+                          (reverse errors)))))))))))
 
 (define %standard-phases
   (modify-phases gnu:%standard-phases
-- 
2.33.0