From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:56966) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3dG1-0002ra-7t for guix-patches@gnu.org; Mon, 17 Feb 2020 05:04:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3dFy-0001AM-PN for guix-patches@gnu.org; Mon, 17 Feb 2020 05:04:05 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:60263) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j3dFy-00019m-6V for guix-patches@gnu.org; Mon, 17 Feb 2020 05:04:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j3dFy-0003TA-1K for guix-patches@gnu.org; Mon, 17 Feb 2020 05:04:02 -0500 Subject: [bug#38408] [PATCH v9 1/8] guix: import: (recursive-import) Allow for version numbers Resent-Message-ID: Date: Mon, 17 Feb 2020 12:03:09 +0200 From: Efraim Flashner Message-ID: <20200217100309.GH1968@E5400> References: <4b0a9afd6559ee87734ef06d1d8adc0e60e63ee2.1580817140.git.mjbecze@riseup.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="NyChO5MpGs3JHJbz" Content-Disposition: inline In-Reply-To: <4b0a9afd6559ee87734ef06d1d8adc0e60e63ee2.1580817140.git.mjbecze@riseup.net> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Martin Becze Cc: 38408@debbugs.gnu.org, ludo@gnu.org, jsoo1@asu.edu --NyChO5MpGs3JHJbz Content-Type: multipart/mixed; boundary="D6IIOQQv2Iwyp54J" Content-Disposition: inline --D6IIOQQv2Iwyp54J Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable The tree has moved a bit since you sent the patch, here's a copy I made that applies. --=20 Efraim Flashner =D7=90=D7=A4=D7=A8=D7=99=D7=9D = =D7=A4=D7=9C=D7=A9=D7=A0=D7=A8 GPG key =3D A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted --D6IIOQQv2Iwyp54J Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="0001-guix-import-recursive-import-Allow-for-version-numbe.patch" Content-Transfer-Encoding: quoted-printable =46rom 72be956188ead1aa11a1e9df972ad803323041cc Mon Sep 17 00:00:00 2001 =46rom: Martin Becze Date: Tue, 4 Feb 2020 07:18:18 -0500 Subject: [PATCH 1/8] guix: import: (recursive-import) Allow for version numbers This adds a key VERSION to (recursive-import) and move the paramter REPO to= a key. This also changes all the things that rely on (recursive-import) * guix/import/utils.scm (package->definition): added optional `append-versi= on?` * guix/import/utils.scm (recursive-import): added key `version` and moved `repo` to be a key * guix/import/cran.scm (cran->guix-package): change `repo` to a key * guix/import/cran.scm (cran-recursive-import): change `repo` to a key * guix/scripts/import/cran.scm: change `repo` to a key * guix/import/elpa.scm (elpa->guix-pakcage): change `repo` to a key * guix/import/elpa.scm (elpa-recursive-import): change `repo` to a key * guix/scripts/import/elpa.scm: change `repo` to a key * guix/import/gem.scm (gem->guix-package): change `repo` to a key * guix/import/gem.scm (recursive-import): change `repo` to a key * guix/import/opam.scm (opam-recurive-import): change `repo` to a key * guix/import/pypi.scm (pypi-recursive-import): change `repo` to a key * guix/import/stackage.scm (stackage-recursive-import): change `repo` to a = key --- guix/import/cran.scm | 8 +++-- guix/import/elpa.scm | 6 ++-- guix/import/gem.scm | 4 ++- guix/import/opam.scm | 5 +-- guix/import/pypi.scm | 5 +-- guix/import/stackage.scm | 5 +-- guix/import/utils.scm | 59 ++++++++++++++++++++++-------------- guix/scripts/import/cran.scm | 5 +-- guix/scripts/import/elpa.scm | 4 ++- tests/elpa.scm | 3 +- tests/import-utils.scm | 8 +++-- 11 files changed, 71 insertions(+), 41 deletions(-) diff --git a/guix/import/cran.scm b/guix/import/cran.scm index bcb37ed250..9e05dfcba8 100644 --- a/guix/import/cran.scm +++ b/guix/import/cran.scm @@ -2,6 +2,7 @@ ;;; Copyright =C2=A9 2015, 2016, 2017, 2018, 2019 Ricardo Wurmus ;;; Copyright =C2=A9 2015, 2016, 2017, 2019, 2020 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2017 Mathieu Othacehe +;;; Copyright =C2=A9 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -506,7 +507,7 @@ from the alist META, which was derived from the R packa= ge's DESCRIPTION file." =20 (define cran->guix-package (memoize - (lambda* (package-name #:optional (repo 'cran)) + (lambda* (package-name #:key (repo 'cran) #:allow-other-keys) "Fetch the metadata for PACKAGE-NAME from REPO and return the `packag= e' s-expression corresponding to that package, or #f on failure." (let ((description (fetch-description repo package-name))) @@ -521,8 +522,9 @@ s-expression corresponding to that package, or #f on fa= ilure." (cran->guix-package package-name 'cran)) (else (values #f '())))))))) =20 -(define* (cran-recursive-import package-name #:optional (repo 'cran)) - (recursive-import package-name repo +(define* (cran-recursive-import package-name #:key (repo 'cran)) + (recursive-import package-name + #:repo repo #:repo->guix-package cran->guix-package #:guix-name cran-guix-name)) =20 diff --git a/guix/import/elpa.scm b/guix/import/elpa.scm index 2d4487dba0..9140bcdc34 100644 --- a/guix/import/elpa.scm +++ b/guix/import/elpa.scm @@ -2,6 +2,7 @@ ;;; Copyright =C2=A9 2015 Federico Beffa ;;; Copyright =C2=A9 2015, 2016, 2017, 2018, 2020 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2018 Oleg Pykhalov +;;; Copyright =C2=A9 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -245,7 +246,7 @@ type ''." (license ,license)) dependencies-names))) =20 -(define* (elpa->guix-package name #:optional (repo 'gnu)) +(define* (elpa->guix-package name #:key (repo 'gnu) #:allow-other-keys) "Fetch the package NAME from REPO and produce a Guix package S-expressio= n." (match (fetch-elpa-package name repo) (#f #f) @@ -301,7 +302,8 @@ type ''." (define elpa-guix-name (cut guix-name "emacs-" <>)) =20 (define* (elpa-recursive-import package-name #:optional (repo 'gnu)) - (recursive-import package-name repo + (recursive-import package-name + #:repo repo #:repo->guix-package elpa->guix-package #:guix-name elpa-guix-name)) =20 diff --git a/guix/import/gem.scm b/guix/import/gem.scm index bd5d5b3569..54f158fa65 100644 --- a/guix/import/gem.scm +++ b/guix/import/gem.scm @@ -3,6 +3,7 @@ ;;; Copyright =C2=A9 2016 Ben Woodcroft ;;; Copyright =C2=A9 2018 Oleg Pykhalov ;;; Copyright =C2=A9 2020 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -200,6 +201,7 @@ package on RubyGems." (latest latest-release))) =20 (define* (gem-recursive-import package-name #:optional version) - (recursive-import package-name '() + (recursive-import package-name + #:repo '() #:repo->guix-package gem->guix-package #:guix-name ruby-package-name)) diff --git a/guix/import/opam.scm b/guix/import/opam.scm index 394415fdd4..87c823a98c 100644 --- a/guix/import/opam.scm +++ b/guix/import/opam.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2018 Julien Lepiller +;;; Copyright =C2=A9 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -311,8 +312,8 @@ or #f on failure." dependencies)))))))) =20 (define (opam-recursive-import package-name) - (recursive-import package-name #f - #:repo->guix-package (lambda (name repo) + (recursive-import package-name + #:repo->guix-package (lambda (name . _) (opam->guix-package name)) #:guix-name ocaml-name->guix-name)) =20 diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm index 6897f42be3..abd933e2e1 100644 --- a/guix/import/pypi.scm +++ b/guix/import/pypi.scm @@ -6,6 +6,7 @@ ;;; Copyright =C2=A9 2018 Ricardo Wurmus ;;; Copyright =C2=A9 2019 Maxim Cournoyer ;;; Copyright =C2=A9 2020 Jakub K=C4=85dzio=C5=82ka +;;; Copyright =C2=A9 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -429,8 +430,8 @@ VERSION, SOURCE-URL, HOME-PAGE, SYNOPSIS, DESCRIPTION, = and LICENSE." description license)))))))) =20 (define (pypi-recursive-import package-name) - (recursive-import package-name #f - #:repo->guix-package (lambda (name repo) + (recursive-import package-name + #:repo->guix-package (lambda (name . _) (pypi->guix-package name)) #:guix-name python->package-name)) =20 diff --git a/guix/import/stackage.scm b/guix/import/stackage.scm index 14150201b5..6091cf2c64 100644 --- a/guix/import/stackage.scm +++ b/guix/import/stackage.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2017 Federico Beffa ;;; Copyright =C2=A9 2018 Ricardo Wurmus +;;; Copyright =C2=A9 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -108,8 +109,8 @@ included in the Stackage LTS release." (leave-with-message "~a: Stackage package not found" package-na= me)))))) =20 (define (stackage-recursive-import package-name . args) - (recursive-import package-name #f - #:repo->guix-package (lambda (name repo) + (recursive-import package-name + #:repo->guix-package (lambda (name . _) (apply stackage->guix-package (= cons name args))) #:guix-name hackage-name->package-name)) =20 diff --git a/guix/import/utils.scm b/guix/import/utils.scm index d17d400ddf..8c434a3eea 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -5,6 +5,7 @@ ;;; Copyright =C2=A9 2017, 2019 Ricardo Wurmus ;;; Copyright =C2=A9 2018 Oleg Pykhalov ;;; Copyright =C2=A9 2019 Robert Vollmert +;;; Copyright =C2=A9 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -44,6 +45,7 @@ #:use-module (srfi srfi-9) #:use-module (srfi srfi-11) #:use-module (srfi srfi-26) + #:use-module (srfi srfi-71) #:export (factorize-uri =20 flatten @@ -258,13 +260,15 @@ package definition." ((package-inputs ...) `((native-inputs (,'quasiquote ,package-inputs)))))) =20 -(define (package->definition guix-package) +(define* (package->definition guix-package #:optional append-version?) (match guix-package - (('package ('name (? string? name)) _ ...) - `(define-public ,(string->symbol name) - ,guix-package)) - (('let anything ('package ('name (? string? name)) _ ...)) - `(define-public ,(string->symbol name) + ((or + ('package ('name name) ('version version) . rest) + ('let _ ('package ('name name) ('version version) . rest))) + + `(define-public ,(string->symbol (if append-version? + (string-append name "-" version) + version)) ,guix-package)))) =20 (define (build-system-modules) @@ -399,32 +403,43 @@ obtain a node's uniquely identifying \"key\"." (cons head result) (set-insert (node-name head) visited)))))))) =20 -(define* (recursive-import package-name repo - #:key repo->guix-package guix-name +(define* (recursive-import package-name + #:key repo->guix-package guix-name version repo #:allow-other-keys) "Return a list of package expressions for PACKAGE-NAME and all its dependencies, sorted in topological order. For each package, -call (REPO->GUIX-PACKAGE NAME REPO), which should return a package express= ion -and a list of dependencies; call (GUIX-NAME NAME) to obtain the Guix packa= ge -name corresponding to the upstream name." +call (REPO->GUIX-PACKAGE NAME :KEYS version repo), which should return a +package expression and a list of dependencies; call (GUIX-NAME NAME) to +obtain the Guix package name corresponding to the upstream name." (define-record-type - (make-node name package dependencies) + (make-node name version package dependencies) node? (name node-name) + (version node-version) (package node-package) (dependencies node-dependencies)) =20 - (define (exists? name) - (not (null? (find-packages-by-name (guix-name name))))) + (define (exists? name version) + (not (null? (find-packages-by-name (guix-name name) version)))) =20 - (define (lookup-node name) - (receive (package dependencies) (repo->guix-package name repo) - (make-node name package dependencies))) + (define (lookup-node name version) + (let* ((package dependencies (repo->guix-package name + #:version version + #:repo repo)) + (normilizied-deps (map (match-lambda + ((name version) (list name version)) + (name (list name #f))) dependencies))) + (make-node name version package normilizied-deps))) =20 (map node-package - (topological-sort (list (lookup-node package-name)) + (topological-sort (list (lookup-node package-name version)) (lambda (node) - (map lookup-node - (remove exists? - (node-dependencies node)))) - node-name))) + (map (lambda (name-version) + (apply lookup-node name-version)) + (remove (lambda (name-version) + (apply exists? name-version)) + (node-dependencies node)))) + (lambda (node) + (string-append + (node-name node) + (or (node-version node) "")))))) diff --git a/guix/scripts/import/cran.scm b/guix/scripts/import/cran.scm index d6f371ef3a..bc266ad9da 100644 --- a/guix/scripts/import/cran.scm +++ b/guix/scripts/import/cran.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2014 Eric Bavier ;;; Copyright =C2=A9 2015, 2017, 2019 Ricardo Wurmus +;;; Copyright =C2=A9 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -98,10 +99,10 @@ Import and convert the CRAN package for PACKAGE-NAME.\n= ")) ;; Recursive import (map package->definition (cran-recursive-import package-name - (or (assoc-ref opts 'repo) 'cran))) + #:repo (or (assoc-ref opts 'repo) '= cran))) ;; Single import (let ((sexp (cran->guix-package package-name - (or (assoc-ref opts 'repo) 'cra= n)))) + #:repo (or (assoc-ref opts 'rep= o) 'cran)))) (unless sexp (leave (G_ "failed to download description for package '~a'= ~%") package-name)) diff --git a/guix/scripts/import/elpa.scm b/guix/scripts/import/elpa.scm index d270d2b4bc..07ac07a3d5 100644 --- a/guix/scripts/import/elpa.scm +++ b/guix/scripts/import/elpa.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2015 Federico Beffa ;;; Copyright =C2=A9 2018 Oleg Pykhalov +;;; Copyright =C2=A9 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -102,7 +103,8 @@ Import the latest package named PACKAGE-NAME from an EL= PA repository.\n")) (_ #f)) (elpa-recursive-import package-name (or (assoc-ref opts 'repo) 'gnu))) - (let ((sexp (elpa->guix-package package-name (assoc-ref opts 'r= epo)))) + (let ((sexp (elpa->guix-package package-name + #:repo (assoc-ref opts 'repo)))) (unless sexp (leave (G_ "failed to download package '~a'~%") package-nam= e)) sexp))) diff --git a/tests/elpa.scm b/tests/elpa.scm index b70539bda6..a008cf993c 100644 --- a/tests/elpa.scm +++ b/tests/elpa.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2015 Federico Beffa ;;; Copyright =C2=A9 2020 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -51,7 +52,7 @@ (200 "This is the description.") (200 "fake tarball contents")) (parameterize ((current-http-proxy (%local-url))) - (match (elpa->guix-package pkg 'gnu/http) + (match (elpa->guix-package pkg #:repo 'gnu/http) (('package ('name "emacs-auctex") ('version "11.88.6") diff --git a/tests/import-utils.scm b/tests/import-utils.scm index 87dda3238f..2357ea5c40 100644 --- a/tests/import-utils.scm +++ b/tests/import-utils.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2015, 2017 Ricardo Wurmus ;;; Copyright =C2=A9 2016 Ben Woodcroft +;;; Copyright =C2=A9 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -48,15 +49,16 @@ (package (name "foo") (inputs `(("bar" ,bar))))) - (recursive-import "foo" 'repo + (recursive-import "foo" + #:repo 'repo #:repo->guix-package (match-lambda* - (("foo" 'repo) + (("foo" #:version #f #:repo 'repo) (values '(package (name "foo") (inputs `(("bar" ,bar)))) '("bar"))) - (("bar" 'repo) + (("bar" #:version #f #:repo 'repo) (values '(package (name "bar")) '()))) --=20 2.25.0 --D6IIOQQv2Iwyp54J-- --NyChO5MpGs3JHJbz Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAl5KZN0ACgkQQarn3Mo9 g1HpEA/9FCvCEmDejdFsSyQg+OfqUc5ODs9IOq1AFAsNlLMKcEH6a1ZsBTPPgqWz boXzb2BxLcSuiTMbMqpvJSW+ZmNBGRVRFkrvV/kf8hc7CXizRSmqEL9OVSQ3gda7 Yh1L/V4hB3dZ0BgnhT4YI318NZMx8MixcNaQJ6uOUr9dJHJpOYPUGwHBkJpKwQVw Z9cI41pos12kJ9BceEv8TA3OV1qtY6gNw3Co8TLKsGY+IG/jhyGQufLPFyPJFebf xFabXbsk5nua2HvH4N4Yck3t3BGmh7T28WXImAOAKonsRgXtpO9PYNlw91II3AqQ suESG2Aar971p96N0UfchgHraxBeTZuONBGnfQoZ1nj/pLMIuI9cu0hdDOl9CfaB Y/jNDc39FkZDlP3FdKILgMoTrKhqNZSW3VavtBoH/14qqT6K0f9Fxwt+ymH4klqn wAF5ZoulAvJdLAxesJJ8HHrVE9EBKK9zKDaEeH0+kprwAUMpWpN4PQolyHovNqUy 47iglyRa4DIOFmENO3TPpAL12PwZ/yA1bRu8FpoFBsPUd7m/Eko2lK45I7XGuKXW 0GRrYQ3a7T0cXrOPSpNUuLhclaroCKWdblcH+idj4jvELLmJq1RXZ5SROd8pu+KB ucuvmJvRuWuhAE9CqiUi7Yq1LI4wa7AnKX/jLJNtq6HI5tgt5+M= =Enae -----END PGP SIGNATURE----- --NyChO5MpGs3JHJbz--