* [PATCH 01/12] import: Move json-fetch to (guix import utils).
@ 2016-09-22 13:18 David Craven
2016-09-22 13:18 ` [PATCH 02/12] import: Reorder imports in " David Craven
` (11 more replies)
0 siblings, 12 replies; 32+ messages in thread
From: David Craven @ 2016-09-22 13:18 UTC (permalink / raw)
To: guix-devel
* guix/import/utils.scm (json-fetch): Move json-fetch from
(guix import json).
---
guix/import/cpan.scm | 1 -
guix/import/gem.scm | 1 -
guix/import/json.scm | 32 --------------------------------
guix/import/pypi.scm | 1 -
guix/import/utils.scm | 12 ++++++++++++
5 files changed, 12 insertions(+), 35 deletions(-)
delete mode 100644 guix/import/json.scm
diff --git a/guix/import/cpan.scm b/guix/import/cpan.scm
index 5b7c475..0769064 100644
--- a/guix/import/cpan.scm
+++ b/guix/import/cpan.scm
@@ -31,7 +31,6 @@
#:use-module (guix base32)
#:use-module ((guix download) #:select (download-to-store))
#:use-module (guix import utils)
- #:use-module (guix import json)
#:use-module (guix packages)
#:use-module (guix derivations)
#:use-module (gnu packages perl)
diff --git a/guix/import/gem.scm b/guix/import/gem.scm
index fc06b0d..b3a50ac 100644
--- a/guix/import/gem.scm
+++ b/guix/import/gem.scm
@@ -26,7 +26,6 @@
#:use-module (web uri)
#:use-module ((guix download) #:prefix download:)
#:use-module (guix import utils)
- #:use-module (guix import json)
#:use-module (guix packages)
#:use-module (guix upstream)
#:use-module (guix licenses)
diff --git a/guix/import/json.scm b/guix/import/json.scm
deleted file mode 100644
index c3092a5..0000000
--- a/guix/import/json.scm
+++ /dev/null
@@ -1,32 +0,0 @@
-;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014 David Thompson <davet@gnu.org>
-;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org>
-;;;
-;;; This file is part of GNU Guix.
-;;;
-;;; GNU Guix is free software; you can redistribute it and/or modify it
-;;; under the terms of the GNU General Public License as published by
-;;; the Free Software Foundation; either version 3 of the License, or (at
-;;; your option) any later version.
-;;;
-;;; GNU Guix is distributed in the hope that it will be useful, but
-;;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;;; GNU General Public License for more details.
-;;;
-;;; You should have received a copy of the GNU General Public License
-;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
-
-(define-module (guix import json)
- #:use-module (json)
- #:use-module (guix utils)
- #:use-module (guix import utils)
- #:export (json-fetch))
-
-(define (json-fetch url)
- "Return an alist representation of the JSON resource URL, or #f on failure."
- (call-with-temporary-output-file
- (lambda (temp port)
- (and (url-fetch url temp)
- (hash-table->alist
- (call-with-input-file temp json->scm))))))
diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm
index 343445a..3f24014 100644
--- a/guix/import/pypi.scm
+++ b/guix/import/pypi.scm
@@ -38,7 +38,6 @@
. hyphen-package-name->name+version)))
#:use-module (guix import utils)
#:use-module ((guix download) #:prefix download:)
- #:use-module (guix import json)
#:use-module (guix packages)
#:use-module (guix upstream)
#:use-module (guix licenses)
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 93cd0f0..d19a6df 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -1,5 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014 David Thompson <davet@gnu.org>
+;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -25,6 +27,7 @@
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix utils)
#:use-module ((guix build download) #:prefix build:)
+ #:use-module (json)
#:export (factorize-uri
hash-table->alist
@@ -32,6 +35,7 @@
assoc-ref*
url-fetch
+ json-fetch
guix-hash-url
string->license
@@ -148,3 +152,11 @@ into a proper sentence and by using two spaces between sentences."
;; Use double spacing between sentences
(regexp-substitute/global #f "\\. \\b"
cleaned 'pre ". " 'post)))
+
+(define (json-fetch url)
+ "Return an alist representation of the JSON resource URL, or #f on failure."
+ (call-with-temporary-output-file
+ (lambda (temp port)
+ (and (url-fetch url temp)
+ (hash-table->alist
+ (call-with-input-file temp json->scm))))))
--
2.9.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 02/12] import: Reorder imports in (guix import utils).
2016-09-22 13:18 [PATCH 01/12] import: Move json-fetch to (guix import utils) David Craven
@ 2016-09-22 13:18 ` David Craven
2016-09-26 9:31 ` Ludovic Courtès
2016-09-22 13:18 ` [PATCH 03/12] import: Move string->license to importers David Craven
` (10 subsequent siblings)
11 siblings, 1 reply; 32+ messages in thread
From: David Craven @ 2016-09-22 13:18 UTC (permalink / raw)
To: guix-devel
* guix/import/utils.scm (define-module): Reorder imports alphabetically.
---
guix/import/utils.scm | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index d19a6df..8535841 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -19,15 +19,15 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (guix import utils)
- #:use-module (ice-9 match)
- #:use-module (ice-9 regex)
- #:use-module (srfi srfi-1)
- #:use-module (guix hash)
#:use-module (guix base32)
+ #:use-module ((guix build download) #:prefix build:)
+ #:use-module (guix hash)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix utils)
- #:use-module ((guix build download) #:prefix build:)
+ #:use-module (ice-9 match)
+ #:use-module (ice-9 regex)
#:use-module (json)
+ #:use-module (srfi srfi-1)
#:export (factorize-uri
hash-table->alist
--
2.9.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 03/12] import: Move string->license to importers.
2016-09-22 13:18 [PATCH 01/12] import: Move json-fetch to (guix import utils) David Craven
2016-09-22 13:18 ` [PATCH 02/12] import: Reorder imports in " David Craven
@ 2016-09-22 13:18 ` David Craven
2016-09-26 9:32 ` Ludovic Courtès
2016-09-22 13:18 ` [PATCH 04/12] import: utils: Add spdx-string->license David Craven
` (9 subsequent siblings)
11 siblings, 1 reply; 32+ messages in thread
From: David Craven @ 2016-09-22 13:18 UTC (permalink / raw)
To: guix-devel
* guix/import/gem.scm (string->license): Move from (guix import utils).
* guix/import/pypi.scm (string->license): Move from (guix import utils).
---
guix/import/gem.scm | 13 ++++++++++++-
guix/import/pypi.scm | 13 ++++++++++++-
guix/import/utils.scm | 9 ---------
3 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/guix/import/gem.scm b/guix/import/gem.scm
index b3a50ac..df6b498 100644
--- a/guix/import/gem.scm
+++ b/guix/import/gem.scm
@@ -28,7 +28,7 @@
#:use-module (guix import utils)
#:use-module (guix packages)
#:use-module (guix upstream)
- #:use-module (guix licenses)
+ #:use-module ((guix licenses) #:prefix license:)
#:use-module (guix base32)
#:use-module (guix build-system ruby)
#:export (gem->guix-package
@@ -154,6 +154,17 @@ package on RubyGems."
;; e.g. "https://rubygems.org/downloads/hashery-2.1.1.gem"
(substring source-url 31 (string-rindex source-url #\-))))
+(define (string->license str)
+ "Convert the string STR into a license object."
+ (match str
+ ("GNU LGPL" license:lgpl2.0)
+ ("GPL" license:gpl3)
+ ((or "BSD" "BSD License") license:bsd-3)
+ ((or "MIT" "MIT license" "Expat license") license:expat)
+ ("Public domain" license:public-domain)
+ ((or "Apache License, Version 2.0" "Apache 2.0") license:asl2.0)
+ (_ #f)))
+
(define (gem-package? package)
"Return true if PACKAGE is a gem package from RubyGems."
diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm
index 3f24014..60067db 100644
--- a/guix/import/pypi.scm
+++ b/guix/import/pypi.scm
@@ -40,7 +40,7 @@
#:use-module ((guix download) #:prefix download:)
#:use-module (guix packages)
#:use-module (guix upstream)
- #:use-module (guix licenses)
+ #:use-module ((guix licenses) #:prefix license:)
#:use-module (guix build-system python)
#:use-module (gnu packages python)
#:export (guix-package->pypi-name
@@ -293,6 +293,17 @@ VERSION, SOURCE-URL, HOME-PAGE, SYNOPSIS, DESCRIPTION, and LICENSE."
(make-pypi-sexp name version release wheel home-page synopsis
description license))))))
+(define (string->license str)
+ "Convert the string STR into a license object."
+ (match str
+ ("GNU LGPL" license:lgpl2.0)
+ ("GPL" license:gpl3)
+ ((or "BSD" "BSD License") license:bsd-3)
+ ((or "MIT" "MIT license" "Expat license") license:expat)
+ ("Public domain" license:public-domain)
+ ((or "Apache License, Version 2.0" "Apache 2.0") license:asl2.0)
+ (_ #f)))
+
(define (pypi-package? package)
"Return true if PACKAGE is a Python package from PyPI."
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 8535841..b5dcc17 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -38,7 +38,6 @@
json-fetch
guix-hash-url
- string->license
license->symbol
snake-case
@@ -113,15 +112,7 @@ recursively apply the procedure to the sub-list."
"Return the hash of FILENAME in nix-base32 format."
(bytevector->nix-base32-string (file-sha256 filename)))
-(define (string->license str)
- "Convert the string STR into a license object."
(match str
- ("GNU LGPL" license:lgpl2.0)
- ("GPL" license:gpl3)
- ((or "BSD" "BSD License") license:bsd-3)
- ((or "MIT" "MIT license" "Expat license") license:expat)
- ("Public domain" license:public-domain)
- ((or "Apache License, Version 2.0" "Apache 2.0") license:asl2.0)
(_ #f)))
(define (license->symbol license)
--
2.9.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 04/12] import: utils: Add spdx-string->license.
2016-09-22 13:18 [PATCH 01/12] import: Move json-fetch to (guix import utils) David Craven
2016-09-22 13:18 ` [PATCH 02/12] import: Reorder imports in " David Craven
2016-09-22 13:18 ` [PATCH 03/12] import: Move string->license to importers David Craven
@ 2016-09-22 13:18 ` David Craven
2016-09-22 14:56 ` Eric Bavier
2016-09-26 9:33 ` Ludovic Courtès
2016-09-22 13:18 ` [PATCH 05/12] import: utils: Refactor license->symbol David Craven
` (8 subsequent siblings)
11 siblings, 2 replies; 32+ messages in thread
From: David Craven @ 2016-09-22 13:18 UTC (permalink / raw)
To: guix-devel
* guix/import/utils.scm (spdx-string->license): New variable.
---
guix/import/utils.scm | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index b5dcc17..ca00baf 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014 David Thompson <davet@gnu.org>
;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org>
+;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -38,6 +39,7 @@
json-fetch
guix-hash-url
+ spdx-string->license
license->symbol
snake-case
@@ -112,7 +114,65 @@ recursively apply the procedure to the sub-list."
"Return the hash of FILENAME in nix-base32 format."
(bytevector->nix-base32-string (file-sha256 filename)))
+(define (spdx-string->license str)
+ "Convert STR, a SPDX formatted license identifier, to a license object.
+ Return #f if STR does not match any known identifiers."
(match str
+ ("AGPL-1.0" 'license:AGPL-1.0)
+ ("AGPL-3.0" 'license:AGPL-3.0)
+ ("Apache-1.1" 'license:asl1.1)
+ ("Apache-2.0" 'license:asl2.0)
+ ("BSL-1.0" 'license:boost1.0)
+ ("BSD-2-Clause-FreeBSD" 'license:bsd-2)
+ ("BSD-3-Clause" 'license:bsd-3)
+ ("BSD-4-Clause" 'license:bsd-4)
+ ("CC0-1.0" 'license:cc0)
+ ("CC-BY-SA-4.0" 'license:cc-by-sa4.0)
+ ("CC-BY-SA-3.0" 'license:cc-by-sa3.0)
+ ("CC-BY-3.0" 'license:cc-by3.0)
+ ("CC-BY-2.0" 'license:cc-by2.0)
+ ("CDDL-1.0" 'license:cddl1.0)
+ ("CECILL-C" 'license:cecill-c)
+ ("Artistic-2.0" 'license:artistic2.0)
+ ("ClArtistic" 'license:clarified-artistic)
+ ("CPL-1.0" 'license:cpl1.0)
+ ("EPL-1.0" 'license:epl1.0)
+ ("MIT" 'license:expat)
+ ("FTL" 'license:freetype)
+ ("Giftware" 'license:giftware)
+ ("GPL-1.0" 'license:gpl1)
+ ("GPL-1.0+" 'license:gpl1+)
+ ("GPL-2.0" 'license:gpl2)
+ ("GPL-2.0+" 'license:gpl2+)
+ ("GPL-3.0" 'license:gpl3)
+ ("GPL-3.0+" 'license:gpl3+)
+ ("ISC" 'license:isc)
+ ("IJG" 'license:ijg)
+ ("Imlib2" 'license:imlib2)
+ ("IPA" 'license:ipa)
+ ("LGPL-2.0" 'license:lgpl2.0)
+ ("LGPL-2.0+" 'license:lgpl2.0+)
+ ("LGPL-2.1" 'license:lgpl2.1)
+ ("LGPL-2.1+" 'license:lgpl2.1+)
+ ("LGPL-3.0" 'license:lgpl3.0)
+ ("MPL-1.0" 'license:mpl1.0)
+ ("MPL-1.1" 'license:mpl1.1)
+ ("MPL-2.0" 'license:mpl2.0)
+ ("MS-PL" 'license:ms-pl)
+ ("NCSA" 'license:ncsa)
+ ("OpenSSL" 'license:openssl)
+ ("OLDAP-2.8" 'license:openldap2.8)
+ ("QPL-1.0" 'license:qpl)
+ ("Ruby" 'license:ruby)
+ ("SGI-B-2.0" 'license:sgifreeb2.0)
+ ("OFL-1.1" 'license:silofl1.1)
+ ("Sleepycat" 'license:sleepycat)
+ ("TCL" 'license:tcl/tk)
+ ("Vim" 'license:vim)
+ ("Unlicense" 'license:unlicense)
+ ("X11" 'license:x11)
+ ("ZPL-2.1" 'license:zpl2.1)
+ ("Zlib" 'license:zlib)
(_ #f)))
(define (license->symbol license)
--
2.9.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 05/12] import: utils: Refactor license->symbol.
2016-09-22 13:18 [PATCH 01/12] import: Move json-fetch to (guix import utils) David Craven
` (2 preceding siblings ...)
2016-09-22 13:18 ` [PATCH 04/12] import: utils: Add spdx-string->license David Craven
@ 2016-09-22 13:18 ` David Craven
2016-09-26 9:39 ` Ludovic Courtès
2016-09-22 13:18 ` [PATCH 06/12] import: Add importer for rust crates David Craven
` (7 subsequent siblings)
11 siblings, 1 reply; 32+ messages in thread
From: David Craven @ 2016-09-22 13:18 UTC (permalink / raw)
To: guix-devel
* guix/import/utils.scm (license->symbol): Work for all licenses.
* tests/import-utils.scm (license->symbol): Add test.
---
guix/import/utils.scm | 14 +++++---------
tests/import-utils.scm | 5 +++++
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index ca00baf..8dab72a 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2014 David Thompson <davet@gnu.org>
;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
+;;; Copyright © 2016 David Craven <david@craven.ch>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -178,15 +179,10 @@ recursively apply the procedure to the sub-list."
(define (license->symbol license)
"Convert license to a symbol representing the variable the object is bound
to in the (guix licenses) module, or #f if there is no such known license."
- ;; TODO: Traverse list public variables in (guix licenses) instead so we
- ;; don't have to maintain a list manualy.
- (assoc-ref `((,license:lgpl2.0 . license:lgpl2.0)
- (,license:gpl3 . license:gpl3)
- (,license:bsd-3 . license:bsd-3)
- (,license:expat . license:expat)
- (,license:public-domain . license:public-domain)
- (,license:asl2.0 . license:asl2.0))
- license))
+ (define licenses
+ (module-map (lambda (sym var) `(,(variable-ref var) . ,sym))
+ (resolve-interface '(guix licenses) #:prefix 'license:)))
+ (assoc-ref licenses license))
(define (snake-case str)
"Return a downcased version of the string STR where underscores are replaced
diff --git a/tests/import-utils.scm b/tests/import-utils.scm
index 3b11875..8d44b9e 100644
--- a/tests/import-utils.scm
+++ b/tests/import-utils.scm
@@ -20,6 +20,7 @@
(define-module (test-import-utils)
#:use-module (guix tests)
#:use-module (guix import utils)
+ #:use-module ((guix licenses) #:prefix license:)
#:use-module (srfi srfi-64))
(test-begin "import-utils")
@@ -33,4 +34,8 @@
"This package provides a function to establish world peace"
(beautify-description "A function to establish world peace"))
+(test-equal "license->symbol"
+ 'license:lgpl2.0
+ (license->symbol license:lgpl2.0))
+
(test-end "import-utils")
--
2.9.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 06/12] import: Add importer for rust crates.
2016-09-22 13:18 [PATCH 01/12] import: Move json-fetch to (guix import utils) David Craven
` (3 preceding siblings ...)
2016-09-22 13:18 ` [PATCH 05/12] import: utils: Refactor license->symbol David Craven
@ 2016-09-22 13:18 ` David Craven
2016-09-26 10:02 ` Ludovic Courtès
2016-09-22 13:18 ` [PATCH 07/12] import: crate: Add crate updater David Craven
` (6 subsequent siblings)
11 siblings, 1 reply; 32+ messages in thread
From: David Craven @ 2016-09-22 13:18 UTC (permalink / raw)
To: guix-devel
* guix/import/crate.scm (crate-fetch, make-crate-sexp,
crate->guix-package, guix-package->crate-name, string->license,
crate-name->package-name): New variables.
* guix/scripts/import/crate.scm (%default-options, show-help, %options,
guix-import-crate): New variables.
* guix/scripts/import.scm (importers): Add crate to list of importers.
* tests/crate.scm (test-json, test-source-hash,
guix-package->crate-name, crate->guix-package): New variables.
---
guix/import/crate.scm | 91 +++++++++++++++++++++++++++++++++++++++++
guix/scripts/import.scm | 2 +-
guix/scripts/import/crate.scm | 94 +++++++++++++++++++++++++++++++++++++++++++
tests/crate.scm | 87 +++++++++++++++++++++++++++++++++++++++
4 files changed, 273 insertions(+), 1 deletion(-)
create mode 100644 guix/import/crate.scm
create mode 100644 guix/scripts/import/crate.scm
create mode 100644 tests/crate.scm
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
new file mode 100644
index 0000000..3cc17f2
--- /dev/null
+++ b/guix/import/crate.scm
@@ -0,0 +1,91 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 David Craven <david@craven.ch>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix import crate)
+ #:use-module (gnu packages rust)
+ #:use-module ((guix download) #:prefix download:)
+ #:use-module (guix import utils)
+ #:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix packages)
+ #:use-module (guix upstream)
+ #:use-module (guix utils)
+ #:use-module (ice-9 match)
+ #:use-module (json)
+ #:use-module (srfi srfi-1)
+ #:export (crate->guix-package
+ guix-package->crate-name))
+
+(define (crate-fetch name)
+ "Return an alist representation of the crates.io metadata for the package NAME,
+or #f on failure."
+ ;; XXX: We want to silence the download progress report, which is especially
+ ;; annoying for 'guix refresh', but we have to use a file port.
+ (call-with-output-file "/dev/null"
+ (lambda (null)
+ (with-error-to-port null
+ (lambda ()
+ (json-fetch (string-append "https://crates.io/api/v1/crates/"
+ name)))))))
+
+;; TODO: Import inputs and native-inputs
+(define (make-crate-sexp name version home-page synopsis description license)
+ "Return the `package' s-expression for a rust package with the given NAME,
+VERSION, SOURCE-URL, HOME-PAGE, SYNOPSIS, DESCRIPTION, and LICENSE."
+ (call-with-temporary-output-file
+ (lambda (temp port)
+ (and (url-fetch (crate-uri name version) temp)
+ `(package
+ (name ,(crate-name->package-name name))
+ (version ,version)
+ (source (origin
+ (method url-fetch)
+ (uri (crate-uri ,name version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ ,(guix-hash-url temp)))))
+ (build-system cargo-build-system)
+ (home-page ,home-page)
+ (synopsis ,synopsis)
+ (description ,(beautify-description description))
+ (license ,(match license
+ (() #f)
+ ((license) license)
+ (_ `(list ,@license)))))))))
+
+(define (crate->guix-package crate-name)
+ "Fetch the metadata for CRATE-NAME from crates.io, and return the
+`package' s-expression corresponding to that package, or #f on failure."
+ (let ((crate (crate-fetch crate-name)))
+ (let ((name (assoc-ref* crate "crate" "name"))
+ (version (assoc-ref* crate "crate" "max_version"))
+ (home-page (assoc-ref* crate "crate" "homepage"))
+ (synopsis (assoc-ref* crate "crate" "description"))
+ (description (assoc-ref* crate "crate" "description"))
+ (license (string->license (assoc-ref* crate "crate" "license"))))
+ (make-crate-sexp name version home-page synopsis description license))))
+
+(define (guix-package->crate-name package)
+ "Return the crate NAME of a PACKAGE."
+ (string-join (cdr (string-split (package-name package) #\-)) "-"))
+
+(define (string->license string)
+ (map spdx-string->license (string-split string #\/)))
+
+(define (crate-name->package-name name)
+ (string-append "rust-" name))
diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index e54744f..c671686 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -73,7 +73,7 @@ rather than \\n."
;;; Entry point.
;;;
-(define importers '("gnu" "nix" "pypi" "cpan" "hackage" "elpa" "gem" "cran"))
+(define importers '("gnu" "nix" "pypi" "cpan" "hackage" "elpa" "gem" "cran" "crate"))
(define (resolve-importer name)
(let ((module (resolve-interface
diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm
new file mode 100644
index 0000000..4337a0b
--- /dev/null
+++ b/guix/scripts/import/crate.scm
@@ -0,0 +1,94 @@
+
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2014 David Thompson <davet@gnu.org>
+;;; Copyright © 2016 David Craven <david@craven.ch>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix scripts import crate)
+ #:use-module (guix ui)
+ #:use-module (guix utils)
+ #:use-module (guix scripts)
+ #:use-module (guix import crate)
+ #:use-module (guix scripts import)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-11)
+ #:use-module (srfi srfi-37)
+ #:use-module (ice-9 match)
+ #:use-module (ice-9 format)
+ #:export (guix-import-crate))
+
+\f
+;;;
+;;; Command-line options.
+;;;
+
+(define %default-options
+ '())
+
+(define (show-help)
+ (display (_ "Usage: guix import crate PACKAGE-NAME
+Import and convert the crate.io package for PACKAGE-NAME.\n"))
+ (display (_ "
+ -h, --help display this help and exit"))
+ (display (_ "
+ -V, --version display version information and exit"))
+ (newline)
+ (show-bug-report-information))
+
+(define %options
+ ;; Specification of the command-line options.
+ (cons* (option '(#\h "help") #f #f
+ (lambda args
+ (show-help)
+ (exit 0)))
+ (option '(#\V "version") #f #f
+ (lambda args
+ (show-version-and-exit "guix import crate")))
+ %standard-import-options))
+
+\f
+;;;
+;;; Entry point.
+;;;
+
+(define (guix-import-crate . args)
+ (define (parse-options)
+ ;; Return the alist of option values.
+ (args-fold* args %options
+ (lambda (opt name arg result)
+ (leave (_ "~A: unrecognized option~%") name))
+ (lambda (arg result)
+ (alist-cons 'argument arg result))
+ %default-options))
+
+ (let* ((opts (parse-options))
+ (args (filter-map (match-lambda
+ (('argument . value)
+ value)
+ (_ #f))
+ (reverse opts))))
+ (match args
+ ((package-name)
+ (let ((sexp (crate->guix-package package-name)))
+ (unless sexp
+ (leave (_ "failed to download meta-data for package '~a'~%")
+ package-name))
+ sexp))
+ (()
+ (leave (_ "too few arguments~%")))
+ ((many ...)
+ (leave (_ "too many arguments~%"))))))
diff --git a/tests/crate.scm b/tests/crate.scm
new file mode 100644
index 0000000..71b3567
--- /dev/null
+++ b/tests/crate.scm
@@ -0,0 +1,87 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2014 David Thompson <davet@gnu.org>
+;;; Copyright © 2016 David Craven <david@craven.ch>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (test-crate)
+ #:use-module (guix import crate)
+ #:use-module (guix base32)
+ #:use-module (guix hash)
+ #:use-module (guix tests)
+ #:use-module (ice-9 match)
+ #:use-module (srfi srfi-64))
+
+(define test-json
+ "{
+ \"crate\": {
+ \"max_version\": \"1.0.0\",
+ \"name\": \"foo\",
+ \"license\": \"MIT/Apache-2.0\",
+ \"description\": \"summary\",
+ \"homepage\": \"http://example.com\",
+ }
+}")
+
+(define test-source-hash
+ "")
+
+(test-begin "crate")
+
+(test-equal "guix-package->crate-name"
+ "rustc-serialize"
+ (guix-package->crate-name
+ (dummy-package "rust-rustc-serialize")))
+
+(test-assert "crate->guix-package"
+ ;; Replace network resources with sample data.
+ (mock ((guix import utils) url-fetch
+ (lambda (url file-name)
+ (match url
+ ("https://crates.io/api/v1/crates/foo"
+ (with-output-to-file file-name
+ (lambda ()
+ (display test-json))))
+ ("https://crates.io/api/v1/crates/foo/1.0.0/download"
+ (with-output-to-file file-name
+ (lambda ()
+ (display "empty file\n")))
+ (set! test-source-hash
+ (call-with-input-file file-name port-sha256)))
+ (_ (error "Unexpected URL: " url)))))
+ (match (crate->guix-package "foo")
+ (('package
+ ('name "rust-foo")
+ ('version "1.0.0")
+ ('source ('origin
+ ('method 'url-fetch)
+ ('uri ('crate-uri "foo" 'version))
+ ('file-name ('string-append 'name "-" 'version ".tar.gz"))
+ ('sha256
+ ('base32
+ (? string? hash)))))
+ ('build-system 'cargo-build-system)
+ ('home-page "http://example.com")
+ ('synopsis "summary")
+ ('description "summary")
+ ('license ('list 'license:expat 'license:asl2.0)))
+ (string=? (bytevector->nix-base32-string
+ test-source-hash)
+ hash))
+ (x
+ (pk 'fail x #f)))))
+
+(test-end "crate")
--
2.9.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 07/12] import: crate: Add crate updater.
2016-09-22 13:18 [PATCH 01/12] import: Move json-fetch to (guix import utils) David Craven
` (4 preceding siblings ...)
2016-09-22 13:18 ` [PATCH 06/12] import: Add importer for rust crates David Craven
@ 2016-09-22 13:18 ` David Craven
2016-09-26 10:09 ` Ludovic Courtès
2016-09-22 13:18 ` [PATCH 08/12] build-system: Add cargo build system David Craven
` (5 subsequent siblings)
11 siblings, 1 reply; 32+ messages in thread
From: David Craven @ 2016-09-22 13:18 UTC (permalink / raw)
To: guix-devel
* guix/import/crate.scm (crate-package?, latest-release,
%crate-updater): New variables.
* guix/scripts/refresh.scm (%updaters): Add %crate-updater to list of
updaters.
* guix/upstream.scm (package-update): Use a url from the list when the
find2 procedure doesn't find a url sig-url pair.
---
guix/import/crate.scm | 36 +++++++++++++++++++++++++++++++++++-
guix/scripts/refresh.scm | 4 +++-
guix/upstream.scm | 2 +-
3 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 3cc17f2..5b34330 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -28,7 +28,8 @@
#:use-module (json)
#:use-module (srfi srfi-1)
#:export (crate->guix-package
- guix-package->crate-name))
+ guix-package->crate-name
+ %crate-updater))
(define (crate-fetch name)
"Return an alist representation of the crates.io metadata for the package NAME,
@@ -89,3 +90,36 @@ VERSION, SOURCE-URL, HOME-PAGE, SYNOPSIS, DESCRIPTION, and LICENSE."
(define (crate-name->package-name name)
(string-append "rust-" name))
+
+(define (crate-package? package)
+ "Return true if PACKAGE is a Rust crate from crates.io."
+
+ (define (crate-url? url)
+ (string-prefix? "https://crates.io/" url))
+
+ (let ((source-url (and=> (package-source package) origin-uri))
+ (fetch-method (and=> (package-source package) origin-method)))
+ (and (eq? fetch-method download:url-fetch)
+ (match source-url
+ ((? string?)
+ (crate-url? source-url))
+ ((source-url ...)
+ (any crate-url? source-url))))))
+
+(define (latest-release package)
+ "Return an <upstream-source> for the latest release of PACKAGE."
+ (let* ((crate-name (guix-package->crate-name package))
+ (metadata (crate-fetch crate-name))
+ (version (assoc-ref* metadata "crate" "max_version"))
+ (url (crate-uri crate-name version)))
+ (upstream-source
+ (package (package-name package))
+ (version version)
+ (urls (list url)))))
+
+(define %crate-updater
+ (upstream-updater
+ (name 'crates)
+ (description "Updater for crates.io packages")
+ (pred crate-package?)
+ (latest latest-release)))
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index b00ac98..3cd5223 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -38,6 +38,7 @@
%xorg-updater))
#:use-module (guix import elpa)
#:use-module (guix import cran)
+ #:use-module (guix import crate)
#:use-module (guix import hackage)
#:use-module (guix gnupg)
#:use-module (gnu packages)
@@ -206,7 +207,8 @@ unavailable optional dependencies such as Guile-JSON."
%hackage-updater
((guix import pypi) => %pypi-updater)
((guix import gem) => %gem-updater)
- ((guix import github) => %github-updater)))
+ ((guix import github) => %github-updater)
+ ((guix import crate) => %crate-updater)))
(define (lookup-updater name)
"Return the updater called NAME."
diff --git a/guix/upstream.scm b/guix/upstream.scm
index 1815737..ac3f72f 100644
--- a/guix/upstream.scm
+++ b/guix/upstream.scm
@@ -194,7 +194,7 @@ and 'interactive' (default)."
(string-suffix? archive-type url))
urls
(or signature-urls (circular-list #f)))))
- (let ((tarball (download-tarball store url signature-url
+ (let ((tarball (download-tarball store (if url url (car urls)) signature-url
#:key-download key-download)))
(values version tarball))))
(#f
--
2.9.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 08/12] build-system: Add cargo build system.
2016-09-22 13:18 [PATCH 01/12] import: Move json-fetch to (guix import utils) David Craven
` (5 preceding siblings ...)
2016-09-22 13:18 ` [PATCH 07/12] import: crate: Add crate updater David Craven
@ 2016-09-22 13:18 ` David Craven
2016-09-26 10:17 ` Ludovic Courtès
2016-09-22 13:19 ` [PATCH 09/12] gnu: Add rust-bootstrap-x86_64-1.12.0 David Craven
` (4 subsequent siblings)
11 siblings, 1 reply; 32+ messages in thread
From: David Craven @ 2016-09-22 13:18 UTC (permalink / raw)
To: guix-devel
* guix/build-system/cargo.scm (default-cargo, default-rustc,
%cargo-build-system-modules, cargo-build, lower, cargo-build-system):
New variables.
* guix/build/cargo-build-system.scm (configure, build, check, install,
%standard-phases, cargo-build): New variables.
---
guix/build-system/cargo.scm | 135 ++++++++++++++++++++++++++++++++++++++
guix/build/cargo-build-system.scm | 74 +++++++++++++++++++++
2 files changed, 209 insertions(+)
create mode 100644 guix/build-system/cargo.scm
create mode 100644 guix/build/cargo-build-system.scm
diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
new file mode 100644
index 0000000..795d3b2
--- /dev/null
+++ b/guix/build-system/cargo.scm
@@ -0,0 +1,135 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 David Craven <david@craven.ch>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build-system cargo)
+ #:use-module (guix search-paths)
+ #:use-module (guix store)
+ #:use-module (guix utils)
+ #:use-module (guix derivations)
+ #:use-module (guix packages)
+ #:use-module (guix build-system)
+ #:use-module (guix build-system gnu)
+ #:use-module (ice-9 match)
+ #:export (cargo-build-system))
+
+(define (default-cargo)
+ "Return the default Cargo package."
+ ;; Lazily resolve the binding to avoid a circular dependency.
+ (let ((rust (resolve-interface '(gnu packages rust))))
+ (module-ref rust 'cargo-bootstrap)))
+
+(define (default-rustc)
+ "Return the default Rustc package."
+ ;; Lazily resolve the binding to avoid a circular dependency.
+ (let ((rust (resolve-interface '(gnu packages rust))))
+ (module-ref rust 'rustc-bootstrap)))
+
+(define %cargo-build-system-modules
+ ;; Build-side modules imported by default.
+ `((guix build cargo-build-system)
+ ,@%gnu-build-system-modules))
+
+(define* (cargo-build store name inputs
+ #:key
+ (tests? #t)
+ (test-target "test")
+ (configure-flags ''())
+ (phases '(@ (guix build cargo-build-system)
+ %standard-phases))
+ (outputs '("out"))
+ (search-paths '())
+ (system (%current-system))
+ (guile #f)
+ (imported-modules %cargo-build-system-modules)
+ (modules '((guix build cargo-build-system)
+ (guix build utils))))
+ "Build SOURCE using CARGO, and with INPUTS."
+
+ (define builder
+ `(begin
+ (use-modules ,@modules)
+ (cargo-build #:name ,name
+ #:source ,(match (assoc-ref inputs "source")
+ (((? derivation? source))
+ (derivation->output-path source))
+ ((source)
+ source)
+ (source
+ source))
+ #:configure-flags ,configure-flags
+ #:system ,system
+ #:test-target ,test-target
+ #:tests? ,tests?
+ #:phases ,phases
+ #:outputs %outputs
+ #:search-paths ',(map search-path-specification->sexp
+ search-paths)
+ #:inputs %build-inputs)))
+
+ (define guile-for-build
+ (match guile
+ ((? package?)
+ (package-derivation store guile system #:graft? #f))
+ (#f ; the default
+ (let* ((distro (resolve-interface '(gnu packages commencement)))
+ (guile (module-ref distro 'guile-final)))
+ (package-derivation store guile system #:graft? #f)))))
+
+ (build-expression->derivation store name builder
+ #:inputs inputs
+ #:system system
+ #:modules imported-modules
+ #:outputs outputs
+ #:guile-for-build guile-for-build))
+
+(define* (lower name
+ #:key source inputs native-inputs outputs system target
+ (cargo (default-cargo))
+ (rustc (default-rustc))
+ #:allow-other-keys
+ #:rest arguments)
+ "Return a bag for NAME."
+
+ (define private-keywords
+ '(#:source #:target #:cargo #:rustc #:inputs #:native-inputs))
+
+ (and (not target) ;; TODO: support cross-compilation
+ (bag
+ (name name)
+ (system system)
+ (target target)
+ (host-inputs `(,@(if source
+ `(("source" ,source))
+ '())
+ ,@inputs
+
+ ;; Keep the standard inputs of 'gnu-build-system'
+ ,@(standard-packages)))
+ (build-inputs `(("cargo" ,cargo)
+ ("rustc" ,rustc)
+ ,@native-inputs))
+ (outputs outputs)
+ (build (if target cargo-cross-build cargo-build))
+ (arguments (strip-keyword-arguments private-keywords arguments)))))
+
+(define cargo-build-system
+ (build-system
+ (name 'cargo)
+ (description
+ "Cargo build system, to build Rust crates")
+ (lower lower)))
diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
new file mode 100644
index 0000000..ea70257
--- /dev/null
+++ b/guix/build/cargo-build-system.scm
@@ -0,0 +1,74 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 David Craven <david@craven.ch>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build cargo-build-system)
+ #:use-module ((guix build gnu-build-system) #:prefix gnu:)
+ #:use-module (guix build utils)
+ #:use-module (ice-9 match)
+ #:use-module (ice-9 ftw)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-26)
+ #:export (%standard-phases
+ cargo-build))
+
+;; Commentary:
+;;
+;; Builder-side code of the standard Python package build procedure.
+;;
+;; Code:
+
+(define* (configure #:rest empty)
+ "Replace Cargo.toml [dependencies] section with guix inputs."
+ ;;TODO
+ #t)
+
+(define* (build #:rest empty)
+ "Build a given Cargo package."
+ (zero? (system* "cargo" "build" "--release")))
+
+(define* (check #:rest empty)
+ "Run tests for a given Cargo package."
+ (zero? (system* "cargo" "test")))
+
+(define* (install #:key inputs outputs #:allow-other-keys)
+ "Install a given Cargo package."
+ (let* ((out (assoc-ref outputs "out"))
+ (src (assoc-ref inputs "source"))
+ (bin (string-append out "/bin"))
+ (rsrc (string-append out "/rustsrc")))
+ (mkdir-p rsrc)
+ (copy-recursively "src" (string-append rsrc "/src"))
+ (install-file "Cargo.toml" rsrc)
+ ;; Will fail if crate doesn't contain an executable
+ (system* "cargo" "install" "--root" bin)
+ #t))
+
+(define %standard-phases
+ ;; 'configure' phase is not needed.
+ (modify-phases gnu:%standard-phases
+ (replace 'configure configure)
+ (replace 'build build)
+ (replace 'check check)
+ (replace 'install install)))
+
+(define* (cargo-build #:key inputs (phases %standard-phases)
+ #:allow-other-keys #:rest args)
+ "Build the given Cargo package, applying all of PHASES in order."
+ (apply gnu:gnu-build #:inputs inputs #:phases phases args))
+
+;;; cargo-build-system.scm ends here
--
2.9.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 09/12] gnu: Add rust-bootstrap-x86_64-1.12.0.
2016-09-22 13:18 [PATCH 01/12] import: Move json-fetch to (guix import utils) David Craven
` (6 preceding siblings ...)
2016-09-22 13:18 ` [PATCH 08/12] build-system: Add cargo build system David Craven
@ 2016-09-22 13:19 ` David Craven
2016-09-26 10:18 ` Ludovic Courtès
2016-09-22 13:19 ` [PATCH 10/12] gnu: Add rustc-bootstrap David Craven
` (3 subsequent siblings)
11 siblings, 1 reply; 32+ messages in thread
From: David Craven @ 2016-09-22 13:19 UTC (permalink / raw)
To: guix-devel
* gnu/packages/rust.scm (rust-bootstrap-x86_64-1.12.0): New variable.
---
gnu/packages/rust.scm | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
create mode 100644 gnu/packages/rust.scm
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
new file mode 100644
index 0000000..1831aa7
--- /dev/null
+++ b/gnu/packages/rust.scm
@@ -0,0 +1,30 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 Eric Le Bihan <address@hidden>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages rust)
+ #:use-module (guix download))
+
+(define rust-bootstrap-x86_64-1.12.0
+ (origin
+ (method url-fetch)
+ (uri (string-append
+ "https://static.rust-lang.org/dist/"
+ "rust-beta-x86_64-unknown-linux-gnu.tar.gz"))
+ (sha256
+ (base32
+ "1is1k93zarvxx0h7b57ga8vr9gj34b36l9la6zkph41x33gfgpvl"))))
--
2.9.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 10/12] gnu: Add rustc-bootstrap.
2016-09-22 13:18 [PATCH 01/12] import: Move json-fetch to (guix import utils) David Craven
` (7 preceding siblings ...)
2016-09-22 13:19 ` [PATCH 09/12] gnu: Add rust-bootstrap-x86_64-1.12.0 David Craven
@ 2016-09-22 13:19 ` David Craven
2016-09-26 10:24 ` Ludovic Courtès
2016-09-22 13:19 ` [PATCH 11/12] gnu: Add cargo-bootstrap David Craven
` (2 subsequent siblings)
11 siblings, 1 reply; 32+ messages in thread
From: David Craven @ 2016-09-22 13:19 UTC (permalink / raw)
To: guix-devel
* gnu/packages/rust.scm (rustc-bootstrap): New variable.
---
gnu/packages/rust.scm | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 66 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 1831aa7..4030d18 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -17,7 +17,16 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu packages rust)
- #:use-module (guix download))
+ #:use-module (gnu packages base)
+ #:use-module (gnu packages bootstrap)
+ #:use-module (gnu packages commencement)
+ #:use-module (gnu packages compression)
+ #:use-module (gnu packages elf)
+ #:use-module (gnu packages gcc)
+ #:use-module (guix build-system trivial)
+ #:use-module (guix download)
+ #:use-module (guix packages)
+ #:use-module ((guix licenses) #:prefix license:))
(define rust-bootstrap-x86_64-1.12.0
(origin
@@ -28,3 +37,59 @@
(sha256
(base32
"1is1k93zarvxx0h7b57ga8vr9gj34b36l9la6zkph41x33gfgpvl"))))
+
+(define-public rustc-bootstrap
+ (package
+ (name "rustc-bootstrap")
+ (version "1.12.0")
+ (source rust-bootstrap-x86_64-1.12.0)
+ (build-system gnu-build-system)
+ (native-inputs
+ `(("patchelf" ,patchelf)))
+ (inputs
+ `(("gcc-lib" ,gcc "lib")
+ ("gcc-toolchain-6" ,gcc-toolchain-6)
+ ("zlib" ,zlib)))
+ (arguments
+ `(#:tests? #f
+ #:strip-binaries? #f
+ #:phases
+ (modify-phases %standard-phases
+ (delete 'configure)
+ (delete 'build)
+ (replace 'install
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out"))
+ (gcc-lib (assoc-ref inputs "gcc-lib"))
+ (toolchain (assoc-ref inputs "gcc-toolchain-6"))
+ (zlib (assoc-ref inputs "zlib"))
+ (platform ,(system->rust-platform (%current-system)))
+ (ld-so (string-append (assoc-ref inputs "libc")
+ ,(glibc-dynamic-linker))))
+ (system* "bash" "install.sh"
+ (string-append "--prefix=" out)
+ (string-append "--components=rustc,"
+ "rust-std-" platform))
+ (for-each
+ (lambda (file)
+ (system* "patchelf"
+ "--set-rpath"
+ (string-append out "/lib:" zlib "/lib:"
+ gcc-lib "/lib:" toolchain "/lib")
+ file))
+ (cons* (string-append out "/bin/rustc")
+ (string-append out "/bin/rustdoc")
+ (find-files out "\\.so$")))
+ (for-each
+ (lambda (file)
+ (system* "patchelf"
+ "--set-interpreter" ld-so
+ file))
+ (list (string-append out "/bin/rustc")
+ (string-append out "/bin/rustdoc")))
+ (symlink (string-append toolchain "/bin/gcc")
+ (string-append out "/bin/cc"))))))))
+ (home-page "https://www.rust-lang.org")
+ (synopsis "Rustc bootstrap")
+ (description "Rustc bootstrap.")
+ (license license:asl2.0)))
--
2.9.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 11/12] gnu: Add cargo-bootstrap.
2016-09-22 13:18 [PATCH 01/12] import: Move json-fetch to (guix import utils) David Craven
` (8 preceding siblings ...)
2016-09-22 13:19 ` [PATCH 10/12] gnu: Add rustc-bootstrap David Craven
@ 2016-09-22 13:19 ` David Craven
2016-09-26 10:28 ` Ludovic Courtès
2016-09-22 13:19 ` [PATCH 12/12] gnu: Add rust helper functions David Craven
2016-09-22 14:58 ` [PATCH 01/12] import: Move json-fetch to (guix import utils) Eric Bavier
11 siblings, 1 reply; 32+ messages in thread
From: David Craven @ 2016-09-22 13:19 UTC (permalink / raw)
To: guix-devel
* gnu/packages/rust.scm (cargo-bootstrap): New variable.
---
gnu/packages/rust.scm | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 4030d18..33c1d5c 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -93,3 +93,43 @@
(synopsis "Rustc bootstrap")
(description "Rustc bootstrap.")
(license license:asl2.0)))
+
+(define-public cargo-bootstrap
+ (package
+ (name "cargo-bootstrap")
+ (version "1.12.0")
+ (source rust-bootstrap-x86_64-1.12.0)
+ (build-system gnu-build-system)
+ (native-inputs
+ `(("patchelf" ,patchelf)))
+ (inputs
+ `(("gcc-lib" ,gcc "lib")
+ ("gcc-toolchain-6" ,gcc-toolchain-6)))
+ (arguments
+ `(#:tests? #f
+ #:strip-binaries? #f
+ #:phases
+ (modify-phases %standard-phases
+ (delete 'configure)
+ (delete 'build)
+ (replace 'install
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out"))
+ (platform ,(system->rust-platform (%current-system)))
+ (ld-so (string-append (assoc-ref inputs "libc")
+ ,(glibc-dynamic-linker))))
+ (system* "bash" "install.sh"
+ (string-append "--prefix=" out)
+ "--components=cargo")
+ (zero? (system* "patchelf"
+ "--set-interpreter" ld-so
+ "--set-rpath"
+ (string-append
+ out "/lib:"
+ (assoc-ref inputs "gcc-lib") "/lib:"
+ (assoc-ref inputs "gcc-toolchain-6") "/lib")
+ (string-append out "/bin/cargo")))))))))
+ (home-page "https://www.rust-lang.org")
+ (synopsis "Cargo bootstrap")
+ (description "Cargo bootstrap.")
+ (license license:asl2.0)))
--
2.9.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 12/12] gnu: Add rust helper functions.
2016-09-22 13:18 [PATCH 01/12] import: Move json-fetch to (guix import utils) David Craven
` (9 preceding siblings ...)
2016-09-22 13:19 ` [PATCH 11/12] gnu: Add cargo-bootstrap David Craven
@ 2016-09-22 13:19 ` David Craven
2016-09-26 10:29 ` Ludovic Courtès
2016-09-22 14:58 ` [PATCH 01/12] import: Move json-fetch to (guix import utils) Eric Bavier
11 siblings, 1 reply; 32+ messages in thread
From: David Craven @ 2016-09-22 13:19 UTC (permalink / raw)
To: guix-devel
* gnu/packages/rust.scm (crate-uri, system->rust-platform): New
variables.
---
gnu/packages/rust.scm | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 33c1d5c..ebb9727 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -26,7 +26,18 @@
#:use-module (guix build-system trivial)
#:use-module (guix download)
#:use-module (guix packages)
- #:use-module ((guix licenses) #:prefix license:))
+ #:use-module ((guix licenses) #:prefix license:)
+ #:export (crate-uri))
+
+(define (crate-uri name version)
+ "Return a URI string for the crate package hosted at crates.io corresponding
+to NAME and VERSION."
+ (string-append "https://crates.io/api/v1/crates/" name "/" version "/download"))
+
+(define (system->rust-platform system)
+ (cond
+ ((string-prefix? "x86_64" system) "x86_64-unknown-linux-gnu")
+ ((string-prefix? "i686" system) "i686-unknown-linux-gnu")))
(define rust-bootstrap-x86_64-1.12.0
(origin
--
2.9.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH 04/12] import: utils: Add spdx-string->license.
2016-09-22 13:18 ` [PATCH 04/12] import: utils: Add spdx-string->license David Craven
@ 2016-09-22 14:56 ` Eric Bavier
2016-09-22 15:15 ` David Craven
2016-09-26 9:33 ` Ludovic Courtès
1 sibling, 1 reply; 32+ messages in thread
From: Eric Bavier @ 2016-09-22 14:56 UTC (permalink / raw)
To: David Craven; +Cc: guix-devel, Guix-devel
Hello,
SPDX seems to be a more general specification for licenses, but I still
wonder whether its appropriate for (guix import utils), since its used
only by the crate importer.
On 2016-09-22 08:18, David Craven wrote:
> * guix/import/utils.scm (spdx-string->license): New variable.
> ---
> guix/import/utils.scm | 60
> +++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 60 insertions(+)
>
> diff --git a/guix/import/utils.scm b/guix/import/utils.scm
> index b5dcc17..ca00baf 100644
> --- a/guix/import/utils.scm
> +++ b/guix/import/utils.scm
> @@ -2,6 +2,7 @@
> ;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
> ;;; Copyright © 2014 David Thompson <davet@gnu.org>
> ;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org>
> +;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
> ;;;
> ;;; This file is part of GNU Guix.
> ;;;
> @@ -38,6 +39,7 @@
> json-fetch
> guix-hash-url
>
> + spdx-string->license
> license->symbol
>
> snake-case
> @@ -112,7 +114,65 @@ recursively apply the procedure to the sub-list."
> "Return the hash of FILENAME in nix-base32 format."
> (bytevector->nix-base32-string (file-sha256 filename)))
>
> +(define (spdx-string->license str)
> + "Convert STR, a SPDX formatted license identifier, to a license
> object.
> + Return #f if STR does not match any known identifiers."
> (match str
> + ("AGPL-1.0" 'license:AGPL-1.0)
> + ("AGPL-3.0" 'license:AGPL-3.0)
These two don't exist in (guix licenses)
> + ("Apache-1.1" 'license:asl1.1)
> + ("Apache-2.0" 'license:asl2.0)
> + ("BSL-1.0" 'license:boost1.0)
> + ("BSD-2-Clause-FreeBSD" 'license:bsd-2)
> + ("BSD-3-Clause" 'license:bsd-3)
> + ("BSD-4-Clause" 'license:bsd-4)
> + ("CC0-1.0" 'license:cc0)
> + ("CC-BY-SA-4.0" 'license:cc-by-sa4.0)
> + ("CC-BY-SA-3.0" 'license:cc-by-sa3.0)
Maybe also "cc-by-sa2.0"?
> + ("CC-BY-3.0" 'license:cc-by3.0)
> + ("CC-BY-2.0" 'license:cc-by2.0)
Maybe numerically sort the cc licenses, like the others?
> + ("CDDL-1.0" 'license:cddl1.0)
> + ("CECILL-C" 'license:cecill-c)
> + ("Artistic-2.0" 'license:artistic2.0)
> + ("ClArtistic" 'license:clarified-artistic)
> + ("CPL-1.0" 'license:cpl1.0)
> + ("EPL-1.0" 'license:epl1.0)
> + ("MIT" 'license:expat)
> + ("FTL" 'license:freetype)
> + ("Giftware" 'license:giftware)
> + ("GPL-1.0" 'license:gpl1)
> + ("GPL-1.0+" 'license:gpl1+)
> + ("GPL-2.0" 'license:gpl2)
> + ("GPL-2.0+" 'license:gpl2+)
> + ("GPL-3.0" 'license:gpl3)
> + ("GPL-3.0+" 'license:gpl3+)
> + ("ISC" 'license:isc)
> + ("IJG" 'license:ijg)
> + ("Imlib2" 'license:imlib2)
> + ("IPA" 'license:ipa)
> + ("LGPL-2.0" 'license:lgpl2.0)
> + ("LGPL-2.0+" 'license:lgpl2.0+)
> + ("LGPL-2.1" 'license:lgpl2.1)
> + ("LGPL-2.1+" 'license:lgpl2.1+)
> + ("LGPL-3.0" 'license:lgpl3.0)
> + ("MPL-1.0" 'license:mpl1.0)
> + ("MPL-1.1" 'license:mpl1.1)
> + ("MPL-2.0" 'license:mpl2.0)
> + ("MS-PL" 'license:ms-pl)
> + ("NCSA" 'license:ncsa)
> + ("OpenSSL" 'license:openssl)
> + ("OLDAP-2.8" 'license:openldap2.8)
> + ("QPL-1.0" 'license:qpl)
> + ("Ruby" 'license:ruby)
> + ("SGI-B-2.0" 'license:sgifreeb2.0)
> + ("OFL-1.1" 'license:silofl1.1)
> + ("Sleepycat" 'license:sleepycat)
> + ("TCL" 'license:tcl/tk)
> + ("Vim" 'license:vim)
Alphabetically "vim" succeeds" "unlicense".
> + ("Unlicense" 'license:unlicense)
> + ("X11" 'license:x11)
> + ("ZPL-2.1" 'license:zpl2.1)
> + ("Zlib" 'license:zlib)
> (_ #f)))
>
> (define (license->symbol license)
Some that are missing(?):
"IPL-1.0" => 'license:ibmpl1.0
"CUA-OPL-1.0" => 'license:opl1.0
The "psfl" license. It appears our "psfl" doesn't seem to map cleanly
to one in the SPDX list.
--
`~Eric
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 01/12] import: Move json-fetch to (guix import utils).
2016-09-22 13:18 [PATCH 01/12] import: Move json-fetch to (guix import utils) David Craven
` (10 preceding siblings ...)
2016-09-22 13:19 ` [PATCH 12/12] gnu: Add rust helper functions David Craven
@ 2016-09-22 14:58 ` Eric Bavier
2016-09-22 15:23 ` David Craven
11 siblings, 1 reply; 32+ messages in thread
From: Eric Bavier @ 2016-09-22 14:58 UTC (permalink / raw)
To: David Craven; +Cc: guix-devel, Guix-devel
On 2016-09-22 08:18, David Craven wrote:
> * guix/import/utils.scm (json-fetch): Move json-fetch from
> (guix import json).
> ---
> guix/import/cpan.scm | 1 -
> guix/import/gem.scm | 1 -
> guix/import/json.scm | 32 --------------------------------
> guix/import/pypi.scm | 1 -
> guix/import/utils.scm | 12 ++++++++++++
> 5 files changed, 12 insertions(+), 35 deletions(-)
> delete mode 100644 guix/import/json.scm
We can't do this, since guile-json is an optional dependency for Guix.
See the manual and makefiles.
`~Eric
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 04/12] import: utils: Add spdx-string->license.
2016-09-22 14:56 ` Eric Bavier
@ 2016-09-22 15:15 ` David Craven
0 siblings, 0 replies; 32+ messages in thread
From: David Craven @ 2016-09-22 15:15 UTC (permalink / raw)
To: Eric Bavier; +Cc: guix-devel
Hi,
> SPDX seems to be a more general specification for licenses, but I still
> wonder whether its appropriate for (guix import utils), since its used
> only by the crate importer.
The npm metadata also uses spdx identifiers.
> Maybe also "cc-by-sa2.0"?
Don't know you tell me :) I copied this from a gist that Jelle
published on the ML.
> Maybe numerically sort the cc licenses, like the others?
> Alphabetically "vim" succeeds" "unlicense".
> Some that are missing(?):
>
> "IPL-1.0" => 'license:ibmpl1.0
> "CUA-OPL-1.0" => 'license:opl1.0
Sounds good.
> The "psfl" license. It appears our "psfl" doesn't seem to map cleanly to
> one in the SPDX list.
I'll add it to guix licenses.
Thanks,
David
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 01/12] import: Move json-fetch to (guix import utils).
2016-09-22 14:58 ` [PATCH 01/12] import: Move json-fetch to (guix import utils) Eric Bavier
@ 2016-09-22 15:23 ` David Craven
2016-09-22 16:52 ` Eric Bavier
0 siblings, 1 reply; 32+ messages in thread
From: David Craven @ 2016-09-22 15:23 UTC (permalink / raw)
To: Eric Bavier; +Cc: guix-devel
> guile-json is an optional dependency for Guix. See
> the manual and makefiles.
I see, didn't know.
> We can't do this
I'm not sure that this is correct.
From the manual:
> Installing Guile-JSON will allow you to use the guix
> import pypi command (see Section 6.5 [Invoking guix
> import], page 75). It is of interest primarily for
> developers and not for casual users.
CPAN, GEM and CARGO importers also use guile-json. If
a developer is using importers I think he can install guile-json
since most importers use it. (guix import utils) is only used
by importers, so people that don't want to use importers
can continue without using guile-json. To put it in perspective
guile-json is 100KB (guix size only displays MB).
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 01/12] import: Move json-fetch to (guix import utils).
2016-09-22 15:23 ` David Craven
@ 2016-09-22 16:52 ` Eric Bavier
2016-09-22 16:56 ` David Craven
0 siblings, 1 reply; 32+ messages in thread
From: Eric Bavier @ 2016-09-22 16:52 UTC (permalink / raw)
To: David Craven; +Cc: guix-devel
On 2016-09-22 10:23, David Craven wrote:
>> guile-json is an optional dependency for Guix. See
>> the manual and makefiles.
>
> I see, didn't know.
>
>> We can't do this
>
> I'm not sure that this is correct.
>
> From the manual:
>> Installing Guile-JSON will allow you to use the guix
>> import pypi command (see Section 6.5 [Invoking guix
>> import], page 75). It is of interest primarily for
>> developers and not for casual users.
>
> CPAN, GEM and CARGO importers also use guile-json. If
> a developer is using importers I think he can install guile-json
> since most importers use it. (guix import utils) is only used
> by importers, so people that don't want to use importers
> can continue without using guile-json. To put it in perspective
> guile-json is 100KB (guix size only displays MB).
Overall the patch seems like a net loss. If guile-json is an optional
dependency for Guix and there are importers that don't need it (cran,
hackage, elpa, nix, gnu), then we shouldn't make importers completely
inaccessible for those who want to use Guix without guile-json so that
we can gain what?
--
`~Eric
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 01/12] import: Move json-fetch to (guix import utils).
2016-09-22 16:52 ` Eric Bavier
@ 2016-09-22 16:56 ` David Craven
2016-09-24 5:20 ` Ludovic Courtès
0 siblings, 1 reply; 32+ messages in thread
From: David Craven @ 2016-09-22 16:56 UTC (permalink / raw)
To: Eric Bavier; +Cc: guix-devel
Just didn't see the point of having a file json.scm file there and
found the name to be a little misleading, but ok.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 01/12] import: Move json-fetch to (guix import utils).
2016-09-22 16:56 ` David Craven
@ 2016-09-24 5:20 ` Ludovic Courtès
0 siblings, 0 replies; 32+ messages in thread
From: Ludovic Courtès @ 2016-09-24 5:20 UTC (permalink / raw)
To: David Craven; +Cc: guix-devel
David Craven <david@craven.ch> skribis:
> Just didn't see the point of having a file json.scm file there and
> found the name to be a little misleading, but ok.
Yeah, what Eric describes is the reason. And then (guix scripts
refresh) has this ‘maybe-updater’ macro that checks whether a given
import depends on a missing optional dependency.
Given that JSON is used a lot, we might eventually make Guile-JSON a
mandatory dependency. We could also push David Thompson to update the
(ice-9 json) module and have it in Guile proper. :-)
Ludo’.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 02/12] import: Reorder imports in (guix import utils).
2016-09-22 13:18 ` [PATCH 02/12] import: Reorder imports in " David Craven
@ 2016-09-26 9:31 ` Ludovic Courtès
0 siblings, 0 replies; 32+ messages in thread
From: Ludovic Courtès @ 2016-09-26 9:31 UTC (permalink / raw)
To: David Craven; +Cc: guix-devel
David Craven <david@craven.ch> skribis:
> * guix/import/utils.scm (define-module): Reorder imports alphabetically.
OK! :-)
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 03/12] import: Move string->license to importers.
2016-09-22 13:18 ` [PATCH 03/12] import: Move string->license to importers David Craven
@ 2016-09-26 9:32 ` Ludovic Courtès
0 siblings, 0 replies; 32+ messages in thread
From: Ludovic Courtès @ 2016-09-26 9:32 UTC (permalink / raw)
To: David Craven; +Cc: guix-devel
David Craven <david@craven.ch> skribis:
> * guix/import/gem.scm (string->license): Move from (guix import utils).
> * guix/import/pypi.scm (string->license): Move from (guix import utils).
OK!
Eventually someone should check whether they really match the license
names used in Gem and PyPI.
Ludo’.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 04/12] import: utils: Add spdx-string->license.
2016-09-22 13:18 ` [PATCH 04/12] import: utils: Add spdx-string->license David Craven
2016-09-22 14:56 ` Eric Bavier
@ 2016-09-26 9:33 ` Ludovic Courtès
1 sibling, 0 replies; 32+ messages in thread
From: Ludovic Courtès @ 2016-09-26 9:33 UTC (permalink / raw)
To: David Craven; +Cc: guix-devel
David Craven <david@craven.ch> skribis:
> * guix/import/utils.scm (spdx-string->license): New variable.
Eric wrote:
> SPDX seems to be a more general specification for licenses, but I
> still wonder whether its appropriate for (guix import utils), since
> its used only by the crate importer.
The generality is enough to put it here IMO, and npm appears to be using
it like David wrote.
> +(define (spdx-string->license str)
> + "Convert STR, a SPDX formatted license identifier, to a license object.
^^
Could you add the URL of the SPDX spec somewhere here?
> + Return #f if STR does not match any known identifiers."
^^^
Extra space.
Otherwise LGTM, thanks!
Ludo’.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 05/12] import: utils: Refactor license->symbol.
2016-09-22 13:18 ` [PATCH 05/12] import: utils: Refactor license->symbol David Craven
@ 2016-09-26 9:39 ` Ludovic Courtès
0 siblings, 0 replies; 32+ messages in thread
From: Ludovic Courtès @ 2016-09-26 9:39 UTC (permalink / raw)
To: David Craven; +Cc: guix-devel
David Craven <david@craven.ch> skribis:
> * guix/import/utils.scm (license->symbol): Work for all licenses.
> * tests/import-utils.scm (license->symbol): Add test.
OK!
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 06/12] import: Add importer for rust crates.
2016-09-22 13:18 ` [PATCH 06/12] import: Add importer for rust crates David Craven
@ 2016-09-26 10:02 ` Ludovic Courtès
0 siblings, 0 replies; 32+ messages in thread
From: Ludovic Courtès @ 2016-09-26 10:02 UTC (permalink / raw)
To: David Craven; +Cc: guix-devel
David Craven <david@craven.ch> skribis:
> * guix/import/crate.scm (crate-fetch, make-crate-sexp,
> crate->guix-package, guix-package->crate-name, string->license,
> crate-name->package-name): New variables.
> * guix/scripts/import/crate.scm (%default-options, show-help, %options,
> guix-import-crate): New variables.
> * guix/scripts/import.scm (importers): Add crate to list of importers.
> * tests/crate.scm (test-json, test-source-hash,
> guix-package->crate-name, crate->guix-package): New variables.
Woow, great stuff! Overall this looks almost ready to me.
Make sure to mention this new importer in guix.texi, under “Invoking
guix import”.
[...]
> +(define-module (guix import crate)
> + #:use-module (gnu packages rust)
Is this package needed? Maybe for the definition of ‘crate-uri’? I
think ‘crate-uri’ should rather go to (guix import crate) or (guix
build-system rust) when that exists.
> +(define (crate-fetch name)
> + "Return an alist representation of the crates.io metadata for the package NAME,
> +or #f on failure."
> + ;; XXX: We want to silence the download progress report, which is especially
> + ;; annoying for 'guix refresh', but we have to use a file port.
> + (call-with-output-file "/dev/null"
> + (lambda (null)
> + (with-error-to-port null
> + (lambda ()
> + (json-fetch (string-append "https://crates.io/api/v1/crates/"
> + name)))))))
I don’t really like ‘json-fetch’ because it creates a temporary file,
writes progress report info, etc. (there are cases where we really need
it, for instance when using mirror:// URLs, though).
What about using (guix http-client):
(let* ((port (http-fetch …))
(result (json->scm port)))
(close-port port)
(hash-table->alist result))
?
> +;; TODO: Import inputs and native-inputs
> +(define (make-crate-sexp name version home-page synopsis description license)
> + "Return the `package' s-expression for a rust package with the given NAME,
> +VERSION, SOURCE-URL, HOME-PAGE, SYNOPSIS, DESCRIPTION, and LICENSE."
> + (call-with-temporary-output-file
> + (lambda (temp port)
> + (and (url-fetch (crate-uri name version) temp)
Likewise, I’d rather use ‘http-fetch’ and avoid the temporary file.
> +(define (crate->guix-package crate-name)
> + "Fetch the metadata for CRATE-NAME from crates.io, and return the
> +`package' s-expression corresponding to that package, or #f on failure."
> + (let ((crate (crate-fetch crate-name)))
> + (let ((name (assoc-ref* crate "crate" "name"))
> + (version (assoc-ref* crate "crate" "max_version"))
> + (home-page (assoc-ref* crate "crate" "homepage"))
> + (synopsis (assoc-ref* crate "crate" "description"))
> + (description (assoc-ref* crate "crate" "description"))
> + (license (string->license (assoc-ref* crate "crate" "license"))))
> + (make-crate-sexp name version home-page synopsis description license))))
Note for later: In an eventual patch, we should consider using something
like ‘alist-let*’ in (gnu services herd) instead of ‘assoc-ref*’.
> +(define (guix-package->crate-name package)
> + "Return the crate NAME of a PACKAGE."
Lowercase “name”, and s/a//.
> + (string-join (cdr (string-split (package-name package) #\-)) "-"))
I’d prefer:
(match (string-split …)
(("rust" rest ...)
(string-join rest "-")))
cdr is evl! :-)
> --- /dev/null
> +++ b/guix/scripts/import/crate.scm
> @@ -0,0 +1,94 @@
> +
Extra line. :-)
Could you send an updated patch?
Thank you!
Ludo’.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 07/12] import: crate: Add crate updater.
2016-09-22 13:18 ` [PATCH 07/12] import: crate: Add crate updater David Craven
@ 2016-09-26 10:09 ` Ludovic Courtès
0 siblings, 0 replies; 32+ messages in thread
From: Ludovic Courtès @ 2016-09-26 10:09 UTC (permalink / raw)
To: David Craven; +Cc: guix-devel
David Craven <david@craven.ch> skribis:
> * guix/import/crate.scm (crate-package?, latest-release,
> %crate-updater): New variables.
> * guix/scripts/refresh.scm (%updaters): Add %crate-updater to list of
> updaters.
> * guix/upstream.scm (package-update): Use a url from the list when the
> find2 procedure doesn't find a url sig-url pair.
Neat!
> +(define (latest-release package)
> + "Return an <upstream-source> for the latest release of PACKAGE."
> + (let* ((crate-name (guix-package->crate-name package))
> + (metadata (crate-fetch crate-name))
> + (version (assoc-ref* metadata "crate" "max_version"))
> + (url (crate-uri crate-name version)))
> + (upstream-source
> + (package (package-name package))
> + (version version)
> + (urls (list url)))))
So they don’t publish OpenPGP signatures? :-/
> --- a/guix/upstream.scm
> +++ b/guix/upstream.scm
> @@ -194,7 +194,7 @@ and 'interactive' (default)."
> (string-suffix? archive-type url))
> urls
> (or signature-urls (circular-list #f)))))
> - (let ((tarball (download-tarball store url signature-url
> + (let ((tarball (download-tarball store (if url url (car urls)) signature-url
I don’t understand this part, and I suspect it could lead to
inconsistent results where the signature URL doesn’t match the source
URL.
Do you have an example of the problem you experienced? Since the
problem is probably not specific to Crates, we should probably address
it in a separate patch.
Otherwise LGTM!
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 08/12] build-system: Add cargo build system.
2016-09-22 13:18 ` [PATCH 08/12] build-system: Add cargo build system David Craven
@ 2016-09-26 10:17 ` Ludovic Courtès
2016-09-26 18:01 ` David Craven
0 siblings, 1 reply; 32+ messages in thread
From: Ludovic Courtès @ 2016-09-26 10:17 UTC (permalink / raw)
To: David Craven; +Cc: guix-devel
David Craven <david@craven.ch> skribis:
> * guix/build-system/cargo.scm (default-cargo, default-rustc,
> %cargo-build-system-modules, cargo-build, lower, cargo-build-system):
> New variables.
> * guix/build/cargo-build-system.scm (configure, build, check, install,
> %standard-phases, cargo-build): New variables.
[...]
> +;; Commentary:
> +;;
> +;; Builder-side code of the standard Python package build procedure.
s/Python/Rust/ :-)
> +(define* (configure #:rest empty)
> + "Replace Cargo.toml [dependencies] section with guix inputs."
> + ;;TODO
So what would this do? Do we end up using bundled dependencies if we
don’t do that?
> +(define* (build #:rest empty)
> + "Build a given Cargo package."
> + (zero? (system* "cargo" "build" "--release")))
It may be useful to make "--release" configurable, like the #:build-type
of ‘cmake-build-system’.
Also, ‘empty’ is a confusing variable name here, because it’s definitely
a non-empty list; maybe simply ‘rest’ or ‘_’?
> +(define* (check #:rest empty)
Ditto.
> +(define* (install #:key inputs outputs #:allow-other-keys)
> + "Install a given Cargo package."
> + (let* ((out (assoc-ref outputs "out"))
> + (src (assoc-ref inputs "source"))
> + (bin (string-append out "/bin"))
> + (rsrc (string-append out "/rustsrc")))
> + (mkdir-p rsrc)
> + (copy-recursively "src" (string-append rsrc "/src"))
Why do we need to install the source code?
If it’s really needed for the functioning of the package, I’d suggest
moving it to OUT/share/rust-source/PACKAGE-VERSION or something like
this, no?
> + (install-file "Cargo.toml" rsrc)
> + ;; Will fail if crate doesn't contain an executable
> + (system* "cargo" "install" "--root" bin)
I suppose many crates provides a library and no executable, so it’d be
nice to find what needs to be done here. Thoughts?
The rest LGTM.
Thank you!
Ludo’.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 09/12] gnu: Add rust-bootstrap-x86_64-1.12.0.
2016-09-22 13:19 ` [PATCH 09/12] gnu: Add rust-bootstrap-x86_64-1.12.0 David Craven
@ 2016-09-26 10:18 ` Ludovic Courtès
0 siblings, 0 replies; 32+ messages in thread
From: Ludovic Courtès @ 2016-09-26 10:18 UTC (permalink / raw)
To: David Craven; +Cc: guix-devel
David Craven <david@craven.ch> skribis:
> * gnu/packages/rust.scm (rust-bootstrap-x86_64-1.12.0): New variable.
IMO this should go with the next patch (rustc-bootstrap) since it
doesn’t make much sense on its own.
Ludo’.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 10/12] gnu: Add rustc-bootstrap.
2016-09-22 13:19 ` [PATCH 10/12] gnu: Add rustc-bootstrap David Craven
@ 2016-09-26 10:24 ` Ludovic Courtès
0 siblings, 0 replies; 32+ messages in thread
From: Ludovic Courtès @ 2016-09-26 10:24 UTC (permalink / raw)
To: David Craven; +Cc: guix-devel
David Craven <david@craven.ch> skribis:
> * gnu/packages/rust.scm (rustc-bootstrap): New variable.
[...]
> +(define-public rustc-bootstrap
> + (package
> + (name "rustc-bootstrap")
> + (version "1.12.0")
> + (source rust-bootstrap-x86_64-1.12.0)
Could you add a comment above that summarizes the bootstrapping story
that Eric Le Bihan and others discussed about here, and/or give a link
to that discussion?
> + (inputs
> + `(("gcc-lib" ,gcc "lib")
> + ("gcc-toolchain-6" ,gcc-toolchain-6)
I think we can omit “-6” and use the current default. However could you
add a comment as to why we depend on gcc-toolchain and provide that “cc”
symlink? I’m sure Eric L.B. explained it before, but I forgot.
> + (platform ,(system->rust-platform (%current-system)))
I don’t see ‘system->rust-platform’ defined here. I think it’d be best
in the importer or in the build system.
> + (description "Rustc bootstrap.")
Could you expound a bit?
Thanks for picking it up!
Ludo’.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 11/12] gnu: Add cargo-bootstrap.
2016-09-22 13:19 ` [PATCH 11/12] gnu: Add cargo-bootstrap David Craven
@ 2016-09-26 10:28 ` Ludovic Courtès
0 siblings, 0 replies; 32+ messages in thread
From: Ludovic Courtès @ 2016-09-26 10:28 UTC (permalink / raw)
To: David Craven; +Cc: guix-devel
David Craven <david@craven.ch> skribis:
> * gnu/packages/rust.scm (cargo-bootstrap): New variable.
So I gather that Cargo cannot be built at all with a build tool other
than Cargo, right?
> +(define-public cargo-bootstrap
> + (package
> + (name "cargo-bootstrap")
> + (version "1.12.0")
> + (source rust-bootstrap-x86_64-1.12.0)
> + (build-system gnu-build-system)
> + (native-inputs
> + `(("patchelf" ,patchelf)))
> + (inputs
> + `(("gcc-lib" ,gcc "lib")
> + ("gcc-toolchain-6" ,gcc-toolchain-6)))
s/-6//
> + (description "Cargo bootstrap.")
Please expound. :-)
Otherwise LGTM, thanks!
Ludo’.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 12/12] gnu: Add rust helper functions.
2016-09-22 13:19 ` [PATCH 12/12] gnu: Add rust helper functions David Craven
@ 2016-09-26 10:29 ` Ludovic Courtès
0 siblings, 0 replies; 32+ messages in thread
From: Ludovic Courtès @ 2016-09-26 10:29 UTC (permalink / raw)
To: David Craven; +Cc: guix-devel
David Craven <david@craven.ch> skribis:
> * gnu/packages/rust.scm (crate-uri, system->rust-platform): New
> variables.
Oh, now I see. :-) This patch should come earlier, but as I wrote
before, I’d rather have those procedures in the build system or
importer, to avoid loading all of (gnu packages …) just for them.
Thanks a lot for this big series!
Ludo’.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 08/12] build-system: Add cargo build system.
2016-09-26 10:17 ` Ludovic Courtès
@ 2016-09-26 18:01 ` David Craven
2016-09-30 12:13 ` Ludovic Courtès
0 siblings, 1 reply; 32+ messages in thread
From: David Craven @ 2016-09-26 18:01 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
>> +(define* (configure #:rest empty)
>> + "Replace Cargo.toml [dependencies] section with guix inputs."
>> + ;;TODO
>
> So what would this do? Do we end up using bundled dependencies if we
> don’t do that?
If we don't do that cargo tries to download them from crates.io, and
since it's running in a container, would fail.
>> +(define* (build #:rest empty)
>> + "Build a given Cargo package."
>> + (zero? (system* "cargo" "build" "--release")))
>
> It may be useful to make "--release" configurable, like the #:build-type
> of ‘cmake-build-system’.
> Why do we need to install the source code?
>
> If it’s really needed for the functioning of the package, I’d suggest
> moving it to OUT/share/rust-source/PACKAGE-VERSION or something like
> this, no?
Rust doesn't have a fixed ABI yet, so cargo builds everything from
source. There is precedent in other distros (I think debian) and
languages (go).
>> + (install-file "Cargo.toml" rsrc)
>> + ;; Will fail if crate doesn't contain an executable
>> + (system* "cargo" "install" "--root" bin)
>
> I suppose many crates provides a library and no executable, so it’d be
> nice to find what needs to be done here. Thoughts?
if we replace all dependencies with local ones, this isn't an issue.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 08/12] build-system: Add cargo build system.
2016-09-26 18:01 ` David Craven
@ 2016-09-30 12:13 ` Ludovic Courtès
0 siblings, 0 replies; 32+ messages in thread
From: Ludovic Courtès @ 2016-09-30 12:13 UTC (permalink / raw)
To: David Craven; +Cc: guix-devel
David Craven <david@craven.ch> skribis:
>>> +(define* (configure #:rest empty)
>>> + "Replace Cargo.toml [dependencies] section with guix inputs."
>>> + ;;TODO
>>
>> So what would this do? Do we end up using bundled dependencies if we
>> don’t do that?
>
> If we don't do that cargo tries to download them from crates.io, and
> since it's running in a container, would fail.
OK, fine.
>>> +(define* (build #:rest empty)
>>> + "Build a given Cargo package."
>>> + (zero? (system* "cargo" "build" "--release")))
>>
>> It may be useful to make "--release" configurable, like the #:build-type
>> of ‘cmake-build-system’.
>
>> Why do we need to install the source code?
>>
>> If it’s really needed for the functioning of the package, I’d suggest
>> moving it to OUT/share/rust-source/PACKAGE-VERSION or something like
>> this, no?
>
> Rust doesn't have a fixed ABI yet, so cargo builds everything from
> source. There is precedent in other distros (I think debian) and
> languages (go).
So Cargo *rebuilds* dependencies, even if they were built with the exact
same compiler?
In our case it would be great if we could disable that because we can
ensure that we are indeed building using a single compiler.
Thoughts?
>>> + (install-file "Cargo.toml" rsrc)
>>> + ;; Will fail if crate doesn't contain an executable
>>> + (system* "cargo" "install" "--root" bin)
>>
>> I suppose many crates provides a library and no executable, so it’d be
>> nice to find what needs to be done here. Thoughts?
>
> if we replace all dependencies with local ones, this isn't an issue.
I was referring to the comment above; what happens if we run “cargo
install --root BIN” on a package that does not contains executables?
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 32+ messages in thread
end of thread, other threads:[~2016-09-30 12:13 UTC | newest]
Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-22 13:18 [PATCH 01/12] import: Move json-fetch to (guix import utils) David Craven
2016-09-22 13:18 ` [PATCH 02/12] import: Reorder imports in " David Craven
2016-09-26 9:31 ` Ludovic Courtès
2016-09-22 13:18 ` [PATCH 03/12] import: Move string->license to importers David Craven
2016-09-26 9:32 ` Ludovic Courtès
2016-09-22 13:18 ` [PATCH 04/12] import: utils: Add spdx-string->license David Craven
2016-09-22 14:56 ` Eric Bavier
2016-09-22 15:15 ` David Craven
2016-09-26 9:33 ` Ludovic Courtès
2016-09-22 13:18 ` [PATCH 05/12] import: utils: Refactor license->symbol David Craven
2016-09-26 9:39 ` Ludovic Courtès
2016-09-22 13:18 ` [PATCH 06/12] import: Add importer for rust crates David Craven
2016-09-26 10:02 ` Ludovic Courtès
2016-09-22 13:18 ` [PATCH 07/12] import: crate: Add crate updater David Craven
2016-09-26 10:09 ` Ludovic Courtès
2016-09-22 13:18 ` [PATCH 08/12] build-system: Add cargo build system David Craven
2016-09-26 10:17 ` Ludovic Courtès
2016-09-26 18:01 ` David Craven
2016-09-30 12:13 ` Ludovic Courtès
2016-09-22 13:19 ` [PATCH 09/12] gnu: Add rust-bootstrap-x86_64-1.12.0 David Craven
2016-09-26 10:18 ` Ludovic Courtès
2016-09-22 13:19 ` [PATCH 10/12] gnu: Add rustc-bootstrap David Craven
2016-09-26 10:24 ` Ludovic Courtès
2016-09-22 13:19 ` [PATCH 11/12] gnu: Add cargo-bootstrap David Craven
2016-09-26 10:28 ` Ludovic Courtès
2016-09-22 13:19 ` [PATCH 12/12] gnu: Add rust helper functions David Craven
2016-09-26 10:29 ` Ludovic Courtès
2016-09-22 14:58 ` [PATCH 01/12] import: Move json-fetch to (guix import utils) Eric Bavier
2016-09-22 15:23 ` David Craven
2016-09-22 16:52 ` Eric Bavier
2016-09-22 16:56 ` David Craven
2016-09-24 5:20 ` Ludovic Courtès
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.