[bug#34040,2/2] import: cran: Suggest input changes.

Message ID 20190111094208.28327-2-rekado@elephly.net
State Accepted
Commit 91e05559bdf21b49686cc2629c44a6d0a6db0a61
Headers show
Series [bug#34040,1/2] refresh: Suggest input changes when updating. | expand

Checks

Context Check Description
cbaines/applying patch fail Apply failed
cbaines/applying patch fail Apply failed

Commit Message

Ricardo Wurmus Jan. 11, 2019, 9:42 a.m. UTC
* guix/import/cran.scm (latest-cran-release, latest-bioconductor-release):
Return input-changes.
---
 guix/import/cran.scm | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

Comments

Ludovic Courtès Jan. 12, 2019, 1:42 p.m. UTC | #1
Ricardo Wurmus <rekado@elephly.net> skribis:

> * guix/import/cran.scm (latest-cran-release, latest-bioconductor-release):
> Return input-changes.

LGTM!

> -(define (latest-cran-release package)
> -  "Return an <upstream-source> for the latest release of PACKAGE."
> +(define (latest-cran-release pkg)

Unless there’s a name clash I think it’s OK to keep ‘package’.

Thanks!

Ludo’.
Ricardo Wurmus Jan. 12, 2019, 9:11 p.m. UTC | #2
Hi,

Ludovic Courtès <ludo@gnu.org> writes:

> Ricardo Wurmus <rekado@elephly.net> skribis:
>
>> * guix/import/cran.scm (latest-cran-release, latest-bioconductor-release):
>> Return input-changes.
>
> LGTM!

Thank you for taking the time to review this!

>> -(define (latest-cran-release package)
>> -  "Return an <upstream-source> for the latest release of PACKAGE."
>> +(define (latest-cran-release pkg)
>
> Unless there’s a name clash I think it’s OK to keep ‘package’.

There is a name clash, which I found very surprising.  Take this procedure:

--8<---------------cut here---------------start------------->8---
(define (latest-cran-release package)
  "Return an <upstream-source> for the latest release of the package PKG."

  (define upstream-name
    (package->upstream-name package))

  (define meta
    (fetch-description 'cran upstream-name))

  (and meta
       (let ((version (assoc-ref meta "Version")))
         ;; CRAN does not provide signatures.
         (upstream-source
          (package (package-name package))
          (version version)
          (urls (cran-uri upstream-name version))
          (input-changes
           (changed-inputs
            package ; <– this is the value of the “package” field,
                    ;    not the value of the procedure argument.
            (description->package 'cran meta)))))))
--8<---------------cut here---------------end--------------->8---

That’s why I renamed the argument to “pkg”.

Patch

diff --git a/guix/import/cran.scm b/guix/import/cran.scm
index 15163bd16..b287be694 100644
--- a/guix/import/cran.scm
+++ b/guix/import/cran.scm
@@ -1,5 +1,5 @@ 
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2015, 2016, 2017, 2018 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
@@ -390,11 +390,11 @@  s-expression corresponding to that package, or #f on failure."
              (_ #f)))
           (_ #f)))))
 
-(define (latest-cran-release package)
-  "Return an <upstream-source> for the latest release of PACKAGE."
+(define (latest-cran-release pkg)
+  "Return an <upstream-source> for the latest release of the package PKG."
 
   (define upstream-name
-    (package->upstream-name package))
+    (package->upstream-name pkg))
 
   (define meta
     (fetch-description 'cran upstream-name))
@@ -403,15 +403,18 @@  s-expression corresponding to that package, or #f on failure."
        (let ((version (assoc-ref meta "Version")))
          ;; CRAN does not provide signatures.
          (upstream-source
-          (package (package-name package))
+          (package (package-name pkg))
           (version version)
-          (urls (cran-uri upstream-name version))))))
+          (urls (cran-uri upstream-name version))
+          (input-changes
+           (changed-inputs pkg
+                           (description->package 'cran meta)))))))
 
-(define (latest-bioconductor-release package)
-  "Return an <upstream-source> for the latest release of PACKAGE."
+(define (latest-bioconductor-release pkg)
+  "Return an <upstream-source> for the latest release of the package PKG."
 
   (define upstream-name
-    (package->upstream-name package))
+    (package->upstream-name pkg))
 
   (define version
     (latest-bioconductor-package-version upstream-name))
@@ -419,9 +422,13 @@  s-expression corresponding to that package, or #f on failure."
   (and version
        ;; Bioconductor does not provide signatures.
        (upstream-source
-        (package (package-name package))
+        (package (package-name pkg))
         (version version)
-        (urls (bioconductor-uri upstream-name version)))))
+        (urls (bioconductor-uri upstream-name version))
+        (input-changes
+         (changed-inputs
+          pkg
+          (cran->guix-package upstream-name 'bioconductor))))))
 
 (define (cran-package? package)
   "Return true if PACKAGE is an R package from CRAN."