unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: 50451@debbugs.gnu.org
Cc: vivien kraus <vivien@planete-kraus.eu>
Subject: [bug#50451] [PATCH] Fix two issues in the minetest importer
Date: Tue, 07 Sep 2021 13:36:36 +0200	[thread overview]
Message-ID: <bde55702705876ac90d8646d3945cc498de730af.camel@telenet.be> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 200 bytes --]

X-Debbugs-CC: Vivien Kraus <vivien@planete-kraus.eu>

Hi guix,

These patches fix a few issues noted at <https://issues.guix.gnu.org/50425#4>
and add corresponding tests.

Greetings,
Maxime.

[-- Attachment #1.2: 0001-tests-minetest-Fix-test-package-indenting.patch --]
[-- Type: text/x-patch, Size: 782 bytes --]

From 2c376bc8fcdc690a8d3b71e818085fa25f547d59 Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos@telenet.be>
Date: Tue, 7 Sep 2021 13:03:12 +0200
Subject: [PATCH 1/3] tests/minetest: Fix 'test-package*' indenting.

* tests/minetest.scm (Local Variables)[test-package*]: Set
  scheme-indent-function property to 1.
---
 tests/minetest.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/minetest.scm b/tests/minetest.scm
index 6ae476fe5f..c6e872e918 100644
--- a/tests/minetest.scm
+++ b/tests/minetest.scm
@@ -353,3 +353,7 @@ during a dynamic extent where that package is available on ContentDB."
     (sort-packages (list x y z))))
 
 (test-end "minetest")
+
+;;; Local Variables:
+;;; eval: (put 'test-package* 'scheme-indent-function 1)
+;;; End:
-- 
2.33.0


[-- Attachment #1.3: 0002-import-minetest-Delete-duplicate-dependencies.patch --]
[-- Type: text/x-patch, Size: 2232 bytes --]

From 2855ab8880b9200ec0eb18a9dfb802a516828312 Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos@telenet.be>
Date: Tue, 7 Sep 2021 13:05:56 +0200
Subject: [PATCH 2/3] import/minetest: Delete duplicate dependencies.

This fixes one of the issues noted in <https://issues.guix.gnu.org/50425#4>.

* guix/import/minetest.scm
  (import-dependencies): Call 'delete-duplicates' on the resulting list.
* tests/minetest.scm
  ("minetest->guix-package, multiple dependencies implemented by one mod"):
  New test.
---
 guix/import/minetest.scm |  6 +++++-
 tests/minetest.scm       | 10 ++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/guix/import/minetest.scm b/guix/import/minetest.scm
index e1f8487b75..c8209aba79 100644
--- a/guix/import/minetest.scm
+++ b/guix/import/minetest.scm
@@ -371,7 +371,11 @@ official Minetest forum and the Git repository (if any)."
 DEPENDENCIES as a list of AUTHOR/NAME strings."
   (define dependency-list
     (assoc-ref dependencies author/name))
-  (filter-map
+  ;; A mod can have multiple dependencies implemented by the same mod,
+  ;; so remove duplicate mod names.
+  (define (filter-deduplicate-map f list)
+    (delete-duplicates (filter-map f list)))
+  (filter-deduplicate-map
    (lambda (dependency)
      (and (not (dependency-optional? dependency))
           (not (builtin-mod? (dependency-name dependency)))
diff --git a/tests/minetest.scm b/tests/minetest.scm
index c6e872e918..80e2697a3d 100644
--- a/tests/minetest.scm
+++ b/tests/minetest.scm
@@ -331,6 +331,16 @@ during a dynamic extent where that package is available on ContentDB."
                                  "some-modpack/containing-mese")))
               #:inputs '())
 
+;; See e.g. 'orwell/basic_trains'
+(test-package* "minetest->guix-package, multiple dependencies implemented by one mod"
+  (list #:name "frobnicate"
+        #:guix-name "minetest-frobnicate"
+        #:upstream-name "Author/frobnicate"
+        #:requirements '(("frob" #f ("Author/frob"))
+                         ("frob_x" #f ("Author/frob")))
+        #:inputs '("minetest-frob"))
+  (list #:author "Author" #:name "frob"))
+
 \f
 ;; License
 (test-package "minetest->guix-package, identical licenses"
-- 
2.33.0


[-- Attachment #1.4: 0003-import-minetest-Strip-v-prefixes-from-the-version-nu.patch --]
[-- Type: text/x-patch, Size: 4422 bytes --]

From 91cbb7e68f3df8601fd91a2247ca971f7e011406 Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos@telenet.be>
Date: Tue, 7 Sep 2021 13:24:24 +0200
Subject: [PATCH 3/3] import/minetest: Strip "v" prefixes from the version
 number.

This fixes one of the issues noted at <https://issues.guix.gnu.org/50425#4>.

* guix/import/minetest.scm
  (release-version): New procedure.
  (%minetest->guix-package): Call new procedure instead of release-title.
* tests/minetest.scm
  (make-package-sexp): Allow overriding the version number.
  (make-releases-json): Allow overriding the release title.
  ("conventional version number")
  ("v-prefixed version number")
  ("dates as version number"): New tests.
---
 guix/import/minetest.scm | 10 +++++++++-
 tests/minetest.scm       | 23 ++++++++++++++++++-----
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/guix/import/minetest.scm b/guix/import/minetest.scm
index c8209aba79..29bf12d123 100644
--- a/guix/import/minetest.scm
+++ b/guix/import/minetest.scm
@@ -337,6 +337,14 @@ official Minetest forum and the Git repository (if any)."
       (and=> (package-forums package) topic->url-sexp)
       (package-repository package)))
 
+(define (release-version release)
+  "Guess the version of RELEASE from the release title."
+  (define title (release-title release))
+  (if (string-prefix? "v" title)
+      ;; Remove "v" prefix from release titles like ‘v1.0.1’.
+      (substring title 1)
+      title))
+
 ;; If the default sort key is changed, make sure to modify 'show-help'
 ;; in (guix scripts import minetest) appropriately as well.
 (define %default-sort-key "score")
@@ -436,7 +444,7 @@ list of AUTHOR/NAME strings."
   (define important-upstream-dependencies
     (important-dependencies dependencies author/name #:sort sort))
   (values (make-minetest-sexp author/name
-                              (release-title release) ; version
+                              (release-version release)
                               (package-repository package)
                               (release-commit release)
                               important-upstream-dependencies
diff --git a/tests/minetest.scm b/tests/minetest.scm
index 80e2697a3d..6998c9a70b 100644
--- a/tests/minetest.scm
+++ b/tests/minetest.scm
@@ -33,6 +33,10 @@
 
 (define* (make-package-sexp #:key
                             (guix-name "minetest-foo")
+                            ;; This is not a proper version number but
+                            ;; ContentDB often does not include version
+                            ;; numbers.
+                            (version "2021-07-25")
                             (home-page "https://example.org/foo")
                             (repo "https://example.org/foo.git")
                             (synopsis "synopsis")
@@ -44,9 +48,7 @@
                             #:allow-other-keys)
   `(package
      (name ,guix-name)
-     ;; This is not a proper version number but ContentDB does not include
-     ;; version numbers.
-     (version "2021-07-25")
+     (version ,version)
      (source
       (origin
         (method git-fetch)
@@ -106,14 +108,14 @@
                              author "/" name "/download/"))
     ("website" . ,website)))
 
-(define* (make-releases-json #:key (commit #f) (title "") #:allow-other-keys)
+(define* (make-releases-json #:key (commit #f) (title "2021-07-25") #:allow-other-keys)
   `#((("commit" . ,commit)
       ("downloads" . 469)
       ("id" . 8614)
       ("max_minetest_version" . null)
       ("min_minetest_version" . null)
       ("release_date" . "2021-07-25T01:10:23.207584")
-      ("title" . "2021-07-25"))))
+      ("title" . ,title))))
 
 (define* (make-dependencies-json #:key (author "Author")
                                  (name "foo")
@@ -292,6 +294,17 @@ during a dynamic extent where that package is available on ContentDB."
               #:website 'null
               #:repo 'null)
 
+\f
+;; Determining the version number
+
+(test-package "conventional version number" #:version "1.2.3" #:title "1.2.3")
+;; See e.g. orwell/basic_trains
+(test-package "v-prefixed version number" #:version "1.2.3" #:title "v1.2.3")
+;; Many mods on ContentDB use dates as release titles.  In that case, the date
+;; will have to do.
+(test-package "dates as version number"
+              #:version "2021-01-01" #:title "2021-01-01")
+
 \f
 
 ;; Dependencies
-- 
2.33.0


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

             reply	other threads:[~2021-09-07 11:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-07 11:36 Maxime Devos [this message]
2021-09-18 17:42 ` bug#50451: [PATCH] Fix two issues in the minetest importer Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bde55702705876ac90d8646d3945cc498de730af.camel@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=50451@debbugs.gnu.org \
    --cc=vivien@planete-kraus.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).