From 282f91790a5bbd0d9b3223c4bfd45b66e418c200 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 17 Jan 2020 13:48:23 +0100 Subject: import: opam: Avoid uses of '@@' in tests. * guix/import/opam.scm (string-pat, multiline-string, list-pat) (dict, condition): Export. (opam-fetch): Add optional 'repository' parameter. (opam->guix-package): Add #:repository parameter and pass it to 'opam-fetch'. * tests/opam.scm ("opam->guix-package"): Remove use of 'mock' and pass TEST-REPO to 'opam->guix-package' instead. ("parse-strings", "parse-multiline-strings") ("parse-lists", "parse-dicts", "parse-conditions"): Remove uses of '@@', which are no longer needed. --- guix/import/opam.scm | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'guix/import/opam.scm') diff --git a/guix/import/opam.scm b/guix/import/opam.scm index e258c4197f..394415fdd4 100644 --- a/guix/import/opam.scm +++ b/guix/import/opam.scm @@ -1,3 +1,4 @@ +;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018 Julien Lepiller ;;; ;;; This file is part of GNU Guix. @@ -38,7 +39,14 @@ #:use-module ((guix licenses) #:prefix license:) #:export (opam->guix-package opam-recursive-import - %opam-updater)) + %opam-updater + + ;; The following patterns are exported for testing purposes. + string-pat + multiline-string + list-pat + dict + condition)) ;; Define a PEG parser for the opam format (define-peg-pattern comment none (and "#" (* STRCHR) "\n")) @@ -233,8 +241,8 @@ path to the repository." (list dependency (list 'unquote (string->symbol dependency)))) (ocaml-names->guix-names lst))) -(define (opam-fetch name) - (and-let* ((repository (get-opam-repository)) +(define* (opam-fetch name #:optional (repository (get-opam-repository))) + (and-let* ((repository repository) (version (find-latest-version name repository)) (file (string-append repository "/packages/" name "/" name "." version "/opam"))) `(("metadata" ,@(get-metadata file)) @@ -242,8 +250,11 @@ path to the repository." (substring version 1) version))))) -(define (opam->guix-package name) - (and-let* ((opam-file (opam-fetch name)) +(define* (opam->guix-package name #:key repository) + "Import OPAM package NAME from REPOSITORY (a directory name) or, if +REPOSITORY is #f, from the official OPAM repository. Return a 'package' sexp +or #f on failure." + (and-let* ((opam-file (opam-fetch name repository)) (version (assoc-ref opam-file "version")) (opam-content (assoc-ref opam-file "metadata")) (url-dict (metadata-ref opam-content "url")) -- cgit v1.2.3