GNU bug report logs - #68358
[PATCH] guix: import: cpan: add recursive

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: "zero@fedora" <shinyzero0@HIDDEN>; Keywords: patch; dated Wed, 10 Jan 2024 00:44:02 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 68358 <at> debbugs.gnu.org:


Received: (at 68358) by debbugs.gnu.org; 10 Jan 2024 01:30:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 09 20:30:23 2024
Received: from localhost ([127.0.0.1]:41408 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rNNQF-0000yO-3b
	for submit <at> debbugs.gnu.org; Tue, 09 Jan 2024 20:30:23 -0500
Received: from tilde.club ([142.44.150.184]:49406 ident=postfix)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <shinyzero0@HIDDEN>) id 1rNNQD-0000sf-5c
 for 68358 <at> debbugs.gnu.org; Tue, 09 Jan 2024 20:30:22 -0500
Received: from fedora.. (unknown [87.117.56.99])
 by tilde.club (Postfix) with ESMTPA id F35B022559F04;
 Wed, 10 Jan 2024 01:30:11 +0000 (UTC)
DKIM-Filter: OpenDKIM Filter v2.11.0 tilde.club F35B022559F04
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tilde.club; s=mail;
 t=1704850212; bh=/bABb7eOMTNKiWwIePSkKmV0p4NXfZyx1vRNfBT2TuQ=;
 h=From:To:Cc:Subject:Date:From;
 b=vIF5zPZrEVTjf3Zww+Rh/L2raAvrLfbSufGfASBTHRvm/4EoQvuIoob+lPpe5JH04
 X7clTPQoM5Y1pxFDb334C/qt9bKxk9TnZG62GqdxZ1TaIMmCxp/sXrvKYczL+hJ/m8
 F+Vyw9BwDjwUe5JonR/Z1/9X5Hj0GHC70urIusy4=
From: "zero@fedora" <shinyzero0@HIDDEN>
To: 68358 <at> debbugs.gnu.org
Subject: [PATCH] guix: import: cpan: add recursive
Date: Wed, 10 Jan 2024 04:29:56 +0300
Message-ID: <7a6b50a5af6f276034ffffcd24ad824fd52df35c.1704850195.git.shinyzero0@HIDDEN>
X-Mailer: git-send-email 2.43.0
MIME-Version: 1.0
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 68358
Cc: "zero@fedora" <shinyzero0@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/import/cpan.scm: new function, some changes to make recursive import possible
* guix/scripts/import/cpan.scm: add recursive import

Change-Id: Id167c7ddd079f4e04650ce7cc1692a9de36cd8fe
---
 guix/import/cpan.scm         | 63 ++++++++++++++++++++++--------------
 guix/scripts/import/cpan.scm | 25 +++++++++++---
 2 files changed, 58 insertions(+), 30 deletions(-)

diff --git a/guix/import/cpan.scm b/guix/import/cpan.scm
index b87736eef6..2090da275d 100644
--- a/guix/import/cpan.scm
+++ b/guix/import/cpan.scm
@@ -37,12 +37,13 @@ (define-module (guix import cpan)
   #:use-module (guix utils)
   #:use-module (guix base32)
   #:use-module ((guix download) #:select (download-to-store url-fetch))
-  #:use-module ((guix import utils) #:select (factorize-uri))
+  #:use-module (guix import utils)
   #:use-module (guix import json)
   #:use-module (guix packages)
   #:use-module (guix upstream)
   #:use-module (guix derivations)
   #:export (cpan->guix-package
+            cpan-recursive-import
             metacpan-url->mirror-url
             %cpan-updater
 
@@ -284,35 +285,42 @@ (define (cpan-module->sexp release)
                                             upstream-input-downstream-name)
                                    inputs)))))))
 
-  (let ((tarball (with-store store
+  (let* ((tarball (with-store store
                    (download-to-store store source-url)))
-        (inputs (cpan-module-inputs release)))
-    `(package
-       (name ,(cpan-name->downstream-name name))
-       (version ,version)
-       (source (origin
-                 (method url-fetch)
-                 (uri (string-append ,@(factorize-uri source-url version)))
-                 (sha256
-                  (base32
-                   ,(bytevector->nix-base32-string (file-sha256 tarball))))))
-       (build-system perl-build-system)
-       ,@(maybe-inputs 'native-inputs
-                       (filter (upstream-input-type-predicate 'native)
-                               inputs))
-       ,@(maybe-inputs 'propagated-inputs
-                       (filter (upstream-input-type-predicate 'propagated)
-                               inputs))
-       (home-page ,(cpan-home name))
-       (synopsis ,(cpan-release-abstract release))
-       (description fill-in-yourself!)
-       (license ,(string->license (cpan-release-license release))))))
+         (inputs (cpan-module-inputs release))
+         (sexp
+           `(package
+              (name ,(cpan-name->downstream-name name))
+              (version ,version)
+              (source (origin
+                        (method url-fetch)
+                        (uri (string-append ,@(factorize-uri source-url version)))
+                        (sha256
+                          (base32
+                            ,(bytevector->nix-base32-string (file-sha256 tarball))))))
+              (build-system perl-build-system)
+              ,@(maybe-inputs 'native-inputs
+                              (filter (upstream-input-type-predicate 'native)
+                                      inputs))
+              ,@(maybe-inputs 'propagated-inputs
+                              (filter (upstream-input-type-predicate 'propagated)
+                                      inputs))
+              (home-page ,(cpan-home name))
+              (synopsis ,(cpan-release-abstract release))
+              (description fill-in-yourself!)
+              (license ,(string->license (cpan-release-license release))))))
+    (values
+      sexp
+      (map upstream-input-name inputs))
+    ))
 
-(define (cpan->guix-package module-name)
+(define* (cpan->guix-package module-name #:key version #:allow-other-keys)
   "Fetch the metadata for PACKAGE-NAME from metacpan.org, and return the
 `package' s-expression corresponding to that package, or #f on failure."
   (let ((release (cpan-fetch (module->name module-name))))
-    (and=> release cpan-module->sexp)))
+    (if release
+      (cpan-module->sexp release)
+      (values #f '()))))
 
 (define cpan-package?
   (let ((cpan-rx (make-regexp (string-append "("
@@ -357,6 +365,11 @@ (define* (latest-release package #:key (version #f))
         (urls (list url))
         (inputs (cpan-module-inputs release)))))))
 
+(define* (cpan-recursive-import package-name)
+  (recursive-import package-name
+                    #:repo->guix-package cpan->guix-package
+                    #:guix-name (compose cpan-name->downstream-name module->name)))
+
 (define %cpan-updater
   (upstream-updater
    (name 'cpan)
diff --git a/guix/scripts/import/cpan.scm b/guix/scripts/import/cpan.scm
index bdf5a1e423..cab6424068 100644
--- a/guix/scripts/import/cpan.scm
+++ b/guix/scripts/import/cpan.scm
@@ -43,6 +43,9 @@ (define (show-help)
 Import and convert the CPAN package for PACKAGE-NAME.\n"))
   (display (G_ "
   -h, --help             display this help and exit"))
+  (display (G_ "
+  -r, --recursive        generate package expressions for all Gem packages\
+ that are not yet in Guix"))
   (display (G_ "
   -V, --version          display version information and exit"))
   (newline)
@@ -54,6 +57,9 @@ (define %options
                  (lambda args
                    (show-help)
                    (exit 0)))
+         (option '(#\r "recursive") #f #f
+                 (lambda (opt name arg result)
+                   (alist-cons 'recursive #t result)))
          (option '(#\V "version") #f #f
                  (lambda args
                    (show-version-and-exit "guix import cpan")))
@@ -78,11 +84,20 @@ (define (guix-import-cpan . args)
                            (reverse opts))))
     (match args
       ((package-name)
-       (let ((sexp (cpan->guix-package package-name)))
-         (unless sexp
-           (leave (G_ "failed to download meta-data for package '~a'~%")
-                  package-name))
-         sexp))
+       (let ((sexp
+               (if (assoc-ref opts 'recursive)
+                 (map (match-lambda
+                        ((and ('package ('name name) . rest) pkg)
+                         `(define-public ,(string->symbol name)
+                                         ,pkg))
+                        (_ #f))
+                      (cpan-recursive-import package-name))
+                 (let ((sexp (cpan->guix-package package-name)))
+                   sexp))))
+             (unless sexp
+               (leave (G_ "failed to download meta-data for package '~a'~%")
+                      package-name))
+             sexp))
       (()
        (leave (G_ "too few arguments~%")))
       ((many ...)

base-commit: 931d893c550128591018587c90d2491fd66a11a4
-- 
2.43.0





Information forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#68358; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 10 Jan 2024 00:43:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 09 19:43:18 2024
Received: from localhost ([127.0.0.1]:41369 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rNMgg-0007dG-5C
	for submit <at> debbugs.gnu.org; Tue, 09 Jan 2024 19:43:18 -0500
Received: from lists.gnu.org ([2001:470:142::17]:57368)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <shinyzero0@HIDDEN>) id 1rNMgd-0007d0-Rr
 for submit <at> debbugs.gnu.org; Tue, 09 Jan 2024 19:43:16 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <shinyzero0@HIDDEN>)
 id 1rNMgP-0001tC-Px
 for guix-patches@HIDDEN; Tue, 09 Jan 2024 19:43:02 -0500
Received: from tilde.club ([142.44.150.184])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <shinyzero0@HIDDEN>)
 id 1rNMgN-0005Cb-5L
 for guix-patches@HIDDEN; Tue, 09 Jan 2024 19:43:00 -0500
Received: from fedora.. (unknown [87.117.56.99])
 by tilde.club (Postfix) with ESMTPA id 976472266734F;
 Wed, 10 Jan 2024 00:42:57 +0000 (UTC)
DKIM-Filter: OpenDKIM Filter v2.11.0 tilde.club 976472266734F
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tilde.club; s=mail;
 t=1704847378; bh=hNicNdtsaUvFYFliWsocLebv6t5eyptM0pRyOnuHOpY=;
 h=From:To:Cc:Subject:Date:From;
 b=BfgKABsDI2DFMmlpylysxwA+XcQ8GdQ4BFl68sybnNp3YOLev2oZDclLuioY7inBW
 9bpPBp5IRFBmqpiObxHhYr+Xio31DXi58j7wKwYdiQhw8HCayBh7Pd5RtLBwgZybuL
 +0Bn0UTIQEY0cQGopcKx3UMAJaq9shEBFOf7Fuos=
From: "zero@fedora" <shinyzero0@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH] guix: import: cpan: add recursive
Date: Wed, 10 Jan 2024 03:41:53 +0300
Message-ID: <1607241d782b7dc97cc5775903c50a81ef3b39ec.1704847312.git.shinyzero0@HIDDEN>
X-Mailer: git-send-email 2.43.0
MIME-Version: 1.0
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=142.44.150.184;
 envelope-from=shinyzero0@HIDDEN; helo=tilde.club
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
X-Debbugs-Envelope-To: submit
Cc: "zero@fedora" <shinyzero0@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.1 (/)

Change-Id: Id167c7ddd079f4e04650ce7cc1692a9de36cd8fe
---
 guix/import/cpan.scm         | 63 ++++++++++++++++++++++--------------
 guix/scripts/import/cpan.scm | 25 +++++++++++---
 2 files changed, 58 insertions(+), 30 deletions(-)

diff --git a/guix/import/cpan.scm b/guix/import/cpan.scm
index b87736eef6..2090da275d 100644
--- a/guix/import/cpan.scm
+++ b/guix/import/cpan.scm
@@ -37,12 +37,13 @@ (define-module (guix import cpan)
   #:use-module (guix utils)
   #:use-module (guix base32)
   #:use-module ((guix download) #:select (download-to-store url-fetch))
-  #:use-module ((guix import utils) #:select (factorize-uri))
+  #:use-module (guix import utils)
   #:use-module (guix import json)
   #:use-module (guix packages)
   #:use-module (guix upstream)
   #:use-module (guix derivations)
   #:export (cpan->guix-package
+            cpan-recursive-import
             metacpan-url->mirror-url
             %cpan-updater
 
@@ -284,35 +285,42 @@ (define (cpan-module->sexp release)
                                             upstream-input-downstream-name)
                                    inputs)))))))
 
-  (let ((tarball (with-store store
+  (let* ((tarball (with-store store
                    (download-to-store store source-url)))
-        (inputs (cpan-module-inputs release)))
-    `(package
-       (name ,(cpan-name->downstream-name name))
-       (version ,version)
-       (source (origin
-                 (method url-fetch)
-                 (uri (string-append ,@(factorize-uri source-url version)))
-                 (sha256
-                  (base32
-                   ,(bytevector->nix-base32-string (file-sha256 tarball))))))
-       (build-system perl-build-system)
-       ,@(maybe-inputs 'native-inputs
-                       (filter (upstream-input-type-predicate 'native)
-                               inputs))
-       ,@(maybe-inputs 'propagated-inputs
-                       (filter (upstream-input-type-predicate 'propagated)
-                               inputs))
-       (home-page ,(cpan-home name))
-       (synopsis ,(cpan-release-abstract release))
-       (description fill-in-yourself!)
-       (license ,(string->license (cpan-release-license release))))))
+         (inputs (cpan-module-inputs release))
+         (sexp
+           `(package
+              (name ,(cpan-name->downstream-name name))
+              (version ,version)
+              (source (origin
+                        (method url-fetch)
+                        (uri (string-append ,@(factorize-uri source-url version)))
+                        (sha256
+                          (base32
+                            ,(bytevector->nix-base32-string (file-sha256 tarball))))))
+              (build-system perl-build-system)
+              ,@(maybe-inputs 'native-inputs
+                              (filter (upstream-input-type-predicate 'native)
+                                      inputs))
+              ,@(maybe-inputs 'propagated-inputs
+                              (filter (upstream-input-type-predicate 'propagated)
+                                      inputs))
+              (home-page ,(cpan-home name))
+              (synopsis ,(cpan-release-abstract release))
+              (description fill-in-yourself!)
+              (license ,(string->license (cpan-release-license release))))))
+    (values
+      sexp
+      (map upstream-input-name inputs))
+    ))
 
-(define (cpan->guix-package module-name)
+(define* (cpan->guix-package module-name #:key version #:allow-other-keys)
   "Fetch the metadata for PACKAGE-NAME from metacpan.org, and return the
 `package' s-expression corresponding to that package, or #f on failure."
   (let ((release (cpan-fetch (module->name module-name))))
-    (and=> release cpan-module->sexp)))
+    (if release
+      (cpan-module->sexp release)
+      (values #f '()))))
 
 (define cpan-package?
   (let ((cpan-rx (make-regexp (string-append "("
@@ -357,6 +365,11 @@ (define* (latest-release package #:key (version #f))
         (urls (list url))
         (inputs (cpan-module-inputs release)))))))
 
+(define* (cpan-recursive-import package-name)
+  (recursive-import package-name
+                    #:repo->guix-package cpan->guix-package
+                    #:guix-name (compose cpan-name->downstream-name module->name)))
+
 (define %cpan-updater
   (upstream-updater
    (name 'cpan)
diff --git a/guix/scripts/import/cpan.scm b/guix/scripts/import/cpan.scm
index bdf5a1e423..cab6424068 100644
--- a/guix/scripts/import/cpan.scm
+++ b/guix/scripts/import/cpan.scm
@@ -43,6 +43,9 @@ (define (show-help)
 Import and convert the CPAN package for PACKAGE-NAME.\n"))
   (display (G_ "
   -h, --help             display this help and exit"))
+  (display (G_ "
+  -r, --recursive        generate package expressions for all Gem packages\
+ that are not yet in Guix"))
   (display (G_ "
   -V, --version          display version information and exit"))
   (newline)
@@ -54,6 +57,9 @@ (define %options
                  (lambda args
                    (show-help)
                    (exit 0)))
+         (option '(#\r "recursive") #f #f
+                 (lambda (opt name arg result)
+                   (alist-cons 'recursive #t result)))
          (option '(#\V "version") #f #f
                  (lambda args
                    (show-version-and-exit "guix import cpan")))
@@ -78,11 +84,20 @@ (define (guix-import-cpan . args)
                            (reverse opts))))
     (match args
       ((package-name)
-       (let ((sexp (cpan->guix-package package-name)))
-         (unless sexp
-           (leave (G_ "failed to download meta-data for package '~a'~%")
-                  package-name))
-         sexp))
+       (let ((sexp
+               (if (assoc-ref opts 'recursive)
+                 (map (match-lambda
+                        ((and ('package ('name name) . rest) pkg)
+                         `(define-public ,(string->symbol name)
+                                         ,pkg))
+                        (_ #f))
+                      (cpan-recursive-import package-name))
+                 (let ((sexp (cpan->guix-package package-name)))
+                   sexp))))
+             (unless sexp
+               (leave (G_ "failed to download meta-data for package '~a'~%")
+                      package-name))
+             sexp))
       (()
        (leave (G_ "too few arguments~%")))
       ((many ...)

base-commit: 931d893c550128591018587c90d2491fd66a11a4
-- 
2.43.0





Acknowledgement sent to "zero@fedora" <shinyzero0@HIDDEN>:
New bug report received and forwarded. Copy sent to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN. Full text available.
Report forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#68358; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 20 Jan 2024 12:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.