summaryrefslogtreecommitdiff
path: root/guix/scripts
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2015-01-11 09:38:49 -0500
committerMark H Weaver <mhw@netris.org>2015-01-11 09:38:49 -0500
commit77448857311318fc9cd866afcb85ca98fccdb25b (patch)
treeefed3a71d1f7b2c2cc292e7e4ba1884c4d26a9e4 /guix/scripts
parent62c155c0bcbc0d71b1bc35e966193b6e8de03246 (diff)
parent0009ed71ad288358cbc7828954b5e1a3f18fd525 (diff)
downloadguix-patches-77448857311318fc9cd866afcb85ca98fccdb25b.tar
guix-patches-77448857311318fc9cd866afcb85ca98fccdb25b.tar.gz
Merge branch 'master' into core-updates
Diffstat (limited to 'guix/scripts')
-rw-r--r--guix/scripts/import.scm2
-rw-r--r--guix/scripts/import/cpan.scm91
-rwxr-xr-xguix/scripts/substitute-binary.scm13
3 files changed, 97 insertions, 9 deletions
diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index 86ef05bc2c..7e75c10b3e 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"))
+(define importers '("gnu" "nix" "pypi" "cpan"))
(define (resolve-importer name)
(let ((module (resolve-interface
diff --git a/guix/scripts/import/cpan.scm b/guix/scripts/import/cpan.scm
new file mode 100644
index 0000000000..1f4dedf23f
--- /dev/null
+++ b/guix/scripts/import/cpan.scm
@@ -0,0 +1,91 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2014 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 scripts import cpan)
+ #:use-module (guix ui)
+ #:use-module (guix utils)
+ #:use-module (guix import cpan)
+ #: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-cpan))
+
+
+;;;
+;;; Command-line options.
+;;;
+
+(define %default-options
+ '())
+
+(define (show-help)
+ (display (_ "Usage: guix import cpan PACKAGE-NAME
+Import and convert the CPAN 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 cpan")))
+ %standard-import-options))
+
+
+;;;
+;;; Entry point.
+;;;
+
+(define (guix-import-cpan . 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 (cpan->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/guix/scripts/substitute-binary.scm b/guix/scripts/substitute-binary.scm
index 9c96411630..09b917fdf6 100755
--- a/guix/scripts/substitute-binary.scm
+++ b/guix/scripts/substitute-binary.scm
@@ -241,7 +241,7 @@ failure."
((version _ sig)
(let ((maybe-number (string->number version)))
(cond ((not (number? maybe-number))
- (leave (_ "signature version must be a number: ~a~%")
+ (leave (_ "signature version must be a number: ~s~%")
version))
;; Currently, there are no other versions.
((not (= 1 maybe-number))
@@ -313,18 +313,15 @@ No authentication and authorization checks are performed here!"
"References" "Deriver" "System"
"Signature"))))
-(define %signature-line-rx
- ;; Regexp matching a signature line in a narinfo.
- (make-regexp "(.+)^[[:blank:]]*Signature:[[:blank:]].+$"))
-
(define (narinfo-sha256 narinfo)
"Return the sha256 hash of NARINFO as a bytevector, or #f if NARINFO lacks a
'Signature' field."
(let ((contents (narinfo-contents narinfo)))
- (match (regexp-exec %signature-line-rx contents)
+ (match (string-contains contents "Signature:")
(#f #f)
- ((= (cut match:substring <> 1) above-signature)
- (sha256 (string->utf8 above-signature))))))
+ (index
+ (let ((above-signature (string-take contents index)))
+ (sha256 (string->utf8 above-signature)))))))
(define* (assert-valid-narinfo narinfo
#:optional (acl (current-acl))