From mboxrd@z Thu Jan 1 00:00:00 1970 From: Efraim Flashner Subject: [PATCH] WIP patches for the rust importer Date: Tue, 26 Nov 2019 14:04:08 +0200 Message-ID: <20191126120408.GL1124@E5400> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="qcTtWMBd/uZDG7+Y" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:48654) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZZaI-00032j-P2 for guix-devel@gnu.org; Tue, 26 Nov 2019 07:04:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZZaG-0004aI-Oo for guix-devel@gnu.org; Tue, 26 Nov 2019 07:04:46 -0500 Received: from flashner.co.il ([178.62.234.194]:42182) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iZZaG-0004Rq-F6 for guix-devel@gnu.org; Tue, 26 Nov 2019 07:04:44 -0500 Received: from localhost (unknown [141.226.13.108]) by flashner.co.il (Postfix) with ESMTPSA id 498544030A for ; Tue, 26 Nov 2019 12:04:40 +0000 (UTC) Content-Disposition: inline List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org --qcTtWMBd/uZDG7+Y Content-Type: multipart/mixed; boundary="rQ7Ovc9/RBrrr0/1" Content-Disposition: inline --rQ7Ovc9/RBrrr0/1 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Attached are two patches. The first one searches through the listed dependencies and removes the ones that are marked as optional. This (potentially) decreases the size of each crate and the number of dependencies. Before: (package (name "rust-serde") (version "1.0.103") (source (origin (method url-fetch) (uri (crate-uri "serde" version)) (file-name (string-append name "-" version ".tar.gz")) (sha256 (base32 "00ip3xy09nk6c2b47ky1m5379yjmwk6n3sr2vmblp478p1xgj5qj")))) (build-system cargo-build-system) (arguments `(#:cargo-inputs (("rust-serde-derive" ,rust-serde-derive)) #:cargo-development-inputs (("rust-serde-derive" ,rust-serde-derive)))) (home-page "https://serde.rs") (synopsis "A generic serialization/deserialization framework") (description "This package provides a generic serialization/deserialization framewor= k") (license (list license:expat license:asl2.0))) After: <--snip..> (arguments `(#:cargo-development-inputs (("rust-serde-derive" ,rust-serde-derive)))) <--snip--> The second patch takes the version information from the dependencies and adds it to the cargo-inputs and cargo-development-inputs, matching how we now have the crates packaged: Before: (package (name "rust-serde-derive") (version "1.0.103") (source (origin (method url-fetch) (uri (crate-uri "serde-derive" version)) (file-name (string-append name "-" version ".tar.gz")) (sha256 (base32 "1l2icqq548dmq5bn278zb2vj725znj4h4ms89w3b0r1fkbpzmim8")))) (build-system cargo-build-system) (arguments `(#:cargo-inputs (("rust-proc-macro2" ,rust-proc-macro2) ("rust-quote" ,rust-quote) ("rust-syn" ,rust-syn)) #:cargo-development-inputs (("rust-serde" ,rust-serde)))) (home-page "https://serde.rs") (synopsis "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]") (description "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]") (license (list license:expat license:asl2.0))) After: <--snip--> (arguments `(#:cargo-inputs (("rust-proc-macro2-1.0" ,rust-proc-macro2-1.0) ("rust-quote-1.0" ,rust-quote-1.0) ("rust-syn-1.0" ,rust-syn-1.0)) #:cargo-development-inputs (("rust-serde-1.0" ,rust-serde-1.0)))) <--snip--> Unfortunately, this also breaks the recursive crate importer. I'm going to continue working on it, but I could use some help getting the recursive aspect of it working. --=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 --rQ7Ovc9/RBrrr0/1 Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="0001-import-crate-Don-t-include-optional-dependencies.patch" Content-Transfer-Encoding: quoted-printable =46rom ef54ba410edd25fcda7f0dc326346a7e4b366d0e Mon Sep 17 00:00:00 2001 =46rom: Efraim Flashner Date: Mon, 25 Nov 2019 17:58:05 +0200 Subject: [PATCH 1/3] import: crate: Don't include optional dependencies. * guix/import/crate.scm (define-json-mapping): Match 'optional' keyword. (crate->guix-package): Remove optional dependencies from listed dependencies. --- guix/import/crate.scm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/guix/import/crate.scm b/guix/import/crate.scm index 8dc014d232..9eca176b08 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -2,6 +2,7 @@ ;;; Copyright =C2=A9 2016 David Craven ;;; Copyright =C2=A9 2019 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2019 Martin Becze +;;; Copyright =C2=A9 2019 Efraim Flashner ;;; ;;; This file is part of GNU Guix. ;;; @@ -87,6 +88,7 @@ (id crate-dependency-id "crate_id") ;string (kind crate-dependency-kind "kind" ;'normal | 'dev string->symbol) + (optional crate-dependency-optional "optional") ; 'true | 'false (requirement crate-dependency-requirement "req")) ;string =20 (define (lookup-crate name) @@ -197,6 +199,9 @@ latest version of CRATE-NAME." (define (normal-dependency? dependency) (eq? (crate-dependency-kind dependency) 'normal)) =20 + (define (optional-dependency? dependency) + (eq? (crate-dependency-optional dependency) #t)) + (define crate (lookup-crate crate-name)) =20 @@ -211,7 +216,8 @@ latest version of CRATE-NAME." (crate-versions crate))) =20 (and crate version* - (let* ((dependencies (crate-version-dependencies version*)) + (let* ((all-deps (crate-version-dependencies version*)) + (dependencies (remove optional-dependency? all-deps)) (dep-crates (filter normal-dependency? dependencies)) (dev-dep-crates (remove normal-dependency? dependencies)) (cargo-inputs (sort (map crate-dependency-id dep-crates) --=20 2.24.0 --rQ7Ovc9/RBrrr0/1 Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="0003-import-crate-Honor-versioned-dependencies-when-impor.patch" Content-Transfer-Encoding: quoted-printable =46rom c9c78e0f1e6a88d53770ae94ada473cd9851552d Mon Sep 17 00:00:00 2001 =46rom: Efraim Flashner Date: Tue, 26 Nov 2019 11:46:34 +0200 Subject: [PATCH 3/3] import: crate: Honor versioned dependencies when importing crates. * guix/import.crate.scm (crate-name->package-name+version, cleaned-version, crate-name+version): New variables. (crate->guix-package): Use crate-name+version for cargo-inputs and cargo-development-inputs. --- guix/import/crate.scm | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/guix/import/crate.scm b/guix/import/crate.scm index 9eca176b08..7be622cf24 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -220,10 +220,10 @@ latest version of CRATE-NAME." (dependencies (remove optional-dependency? all-deps)) (dep-crates (filter normal-dependency? dependencies)) (dev-dep-crates (remove normal-dependency? dependencies)) - (cargo-inputs (sort (map crate-dependency-id dep-crates) + (cargo-inputs (sort (map crate-name+version dep-crates) string-cipackage-name name) (string-append "rust-" (string-join (string-split name #\_) "-"))) =20 +(define (crate-name+version->package-name+version name version) + (string-append "rust-" (string-join (string-split name #\_) "-") + "-" (version-major+minor version))) + +(define (cleaned-version version) + (match (string-ref version 0) + ((or #\^ #\=3D) + (cleaned-version (substring version 1))) + (#\ ; an actual space + (cleaned-version (substring version 1))) + (char-set-contains? char-set:digit + (if (string-contains version ".") + (version-major+minor version) + version)) + (_ + (cleaned-version (substring version 1))) + )) + +(define (crate-name+version crate) + (string-append (crate-dependency-id crate) "-" + (cleaned-version (crate-dependency-requirement crate)))) + =0C ;;; ;;; Updater --=20 2.24.0 --rQ7Ovc9/RBrrr0/1-- --qcTtWMBd/uZDG7+Y Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAl3dFLgACgkQQarn3Mo9 g1EptA//QAtFB7Z8xA9Ytri61Tq0KdAFAseswDlK3OiUuaCk18OkvK+qBeId/ZmV YD5ensr2+e4wNl6hodNbbdNID4Zrsqysc+ajTRyUO/TTWnGSSsFCPQ2LaOcY8nP8 JMaPI8GPFisjWtLT1hBCo16aQuqYSgGLamp0h+3eniGIkJbsKtPgGcWhafpA/+mb dYr7fIo+zn1RPMAYuh0IfMNngpS1YE6l0M7NC1++8BFNCFS2lYMehshWVEGQSC1P YlKNjtVs5amu3YoICAweKBDwf0aILDkcjPKLSQXqv7XdZA1YielDg5nrRxbQAAK0 7B07vNkXXjVry+CjXUtY30LjjbA9K4LRd7Ss8Y8E1yhE+OPCpE/dd9RdXmDc4q9t uFyMmM0/fiD3jXTBuNXbSFZfqulUK2j8VO+aA2jfJoIXyh5EGQ7SolW7Pm6T46Xp IyM39n952q9iuqcGnBKQGGO/heHpp/2Lu65KY8RiyI+iW/wt+pPm+C+/HV5fifqL 6jUBoSuOHN59kB/Rxt2C/8MyqocvdnezhrJTFmmlQ/tjaKrEW6HCFS8XpfX8synG pVMucZKIMIriF4afYUDk4gKBJbHM6sqEt/yf5SoezP2AyjRgLhqHfJSGUero8+ie u8aO5i8mHSYnEGQP5t2LK7aS2ZgJkNV/y97vZcGaiM2opPHgJNA= =48xb -----END PGP SIGNATURE----- --qcTtWMBd/uZDG7+Y--