GNU bug report logs -
#37322
[PATCH 1/2] adds the capability of importing a specified version to the crate importer
Previous Next
Reported by: Martin Becze <mjbecze <at> riseup.net>
Date: Fri, 6 Sep 2019 15:33:02 UTC
Severity: normal
Tags: patch
Merged with 37323
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 37322 <at> debbugs.gnu.org (full text, mbox):
Hello Martin,
So the goal is to allow users to run “guix import rust-foo <at> 1.2.3”,
right? That’s a good idea.
Martin Becze <mjbecze <at> riseup.net> skribis:
> diff --git a/guix/import/crate.scm b/guix/import/crate.scm
> index f6057dbf8b..3266ebdfec 100644
> --- a/guix/import/crate.scm
> +++ b/guix/import/crate.scm
> @@ -1,6 +1,7 @@
> ;;; GNU Guix --- Functional package management for GNU
> ;;; Copyright © 2016 David Craven <david <at> craven.ch>
> ;;; Copyright © 2019 Ludovic Courtès <ludo <at> gnu.org>
> +;;; Copyright © 2019 Martin Becze <mjbecze <at> riseup.net>
> ;;;
> ;;; This file is part of GNU Guix.
> ;;;
> @@ -181,8 +182,8 @@ and LICENSE."
> ;; This regexp matches that.
> (make-regexp "^(.*) OR (.*)$"))
>
> -(define (crate->guix-package crate-name)
> - "Fetch the metadata for CRATE-NAME from crates.io, and return the
> +(define (crate->guix-package crate-name <at> version)
> + "Fetch the metadata for CRATE-NAME <at> VERSION from crates.io, and return the
The idea is that the (guix import …) modules do not contain UI-related
stuff, and that UI-related stuff is instead isolated in (guix scripts
import …).
Thus, splitting the “crate <at> version” string should happen in (guix
scripts import crate) rather than in this module.
Instead, you could simply change ‘crate->guix-package’ so that it takes
an optional ‘version’ field:
(define* (crate->guix-package crate-name #:optional version)
…)
In a second step, you’d change (guix scripts import crate) so that it
passes that version string to ‘crate->guix-package’.
How does that sound?
> + (define crate-name-version-list
> + (let ((lnv (string-split crate-name <at> version #\@)))
> + (if (= 1 (length lnv))
> + (append lnv '(#f))
> + lnv)))
> +
> + (define crate-name
> + (car crate-name-version-list))
> +
> +
> (define crate
> (lookup-crate crate-name))
>
> + (define crate-version-string
> + (let ((version (cadr crate-name-version-list)))
> + (if version
> + version
> + (crate-latest-version crate))))
We have a policy of not using ‘cadr’ and friends:
https://guix.gnu.org/manual/en/html_node/Data-Types-and-Pattern-Matching.html
So the code above would typically look like:
(define-values (name version)
(match (string-split crate-spec #\@)
((name version) (values name version))
((name) (values name #f))))
Could you send an updated patch (actually two patches)?
Thanks for working on the importer!
Ludo’.
This bug report was last modified 5 years and 335 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.