summaryrefslogtreecommitdiff
path: root/guix/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'guix/scripts')
-rw-r--r--guix/scripts/build.scm49
-rw-r--r--guix/scripts/graph.scm27
-rw-r--r--guix/scripts/import.scm2
-rw-r--r--guix/scripts/import/cran.scm92
-rw-r--r--guix/scripts/lint.scm28
-rw-r--r--guix/scripts/publish.scm23
-rw-r--r--guix/scripts/pull.scm2
-rw-r--r--guix/scripts/refresh.scm2
-rwxr-xr-xguix/scripts/substitute.scm2
9 files changed, 209 insertions, 18 deletions
diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index d593b5a8a7..ab2a39b1f8 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -25,6 +25,7 @@
#:use-module (guix utils)
#:use-module (guix monads)
#:use-module (guix gexp)
+ #:autoload (guix http-client) (http-fetch http-get-error?)
#:use-module (ice-9 format)
#:use-module (ice-9 match)
#:use-module (ice-9 vlist)
@@ -42,6 +43,45 @@
guix-build))
+(define %default-log-urls
+ ;; Default base URLs for build logs.
+ '("http://hydra.gnu.org/log"))
+
+;; XXX: The following procedure cannot be in (guix store) because of the
+;; dependency on (guix derivations).
+(define* (log-url store file #:key (base-urls %default-log-urls))
+ "Return a URL under one of the BASE-URLS where a build log for FILE can be
+found. Return #f if no build log was found."
+ (define (valid-url? url)
+ ;; Probe URL and return #t if it is accessible.
+ (guard (c ((http-get-error? c) #f))
+ (close-port (http-fetch url #:buffered? #f))
+ #t))
+
+ (define (find-url file)
+ (let ((base (basename file)))
+ (any (lambda (base-url)
+ (let ((url (string-append base-url "/" base)))
+ (and (valid-url? url) url)))
+ base-urls)))
+
+ (cond ((derivation-path? file)
+ (catch 'system-error
+ (lambda ()
+ ;; Usually we'll have more luck with the output file name since
+ ;; the deriver that was used by the server could be different, so
+ ;; try one of the output file names.
+ (let ((drv (call-with-input-file file read-derivation)))
+ (or (find-url (derivation->output-path drv))
+ (find-url file))))
+ (lambda args
+ ;; As a last resort, try the .drv.
+ (if (= ENOENT (system-error-errno args))
+ (find-url file)
+ (apply throw args)))))
+ (else
+ (find-url file))))
+
(define (register-root store paths root)
"Register ROOT as an indirect GC root for all of PATHS."
(let* ((root (string-append (canonicalize-path (dirname root))
@@ -457,6 +497,11 @@ arguments with packages that use the specified source."
(list %default-options)))
(store (open-connection))
(drv (options->derivations store opts))
+ (urls (map (cut string-append <> "/log")
+ (if (assoc-ref opts 'substitutes?)
+ (or (assoc-ref opts 'substitute-urls)
+ %default-substitute-urls)
+ '())))
(roots (filter-map (match-lambda
(('gc-root . root) root)
(_ #f))
@@ -470,7 +515,9 @@ arguments with packages that use the specified source."
(cond ((assoc-ref opts 'log-file?)
(for-each (lambda (file)
- (let ((log (log-file store file)))
+ (let ((log (or (log-file store file)
+ (log-url store file
+ #:base-urls urls))))
(if log
(format #t "~a~%" log)
(leave (_ "no build log for '~a'~%")
diff --git a/guix/scripts/graph.scm b/guix/scripts/graph.scm
index 475f054571..2b671be131 100644
--- a/guix/scripts/graph.scm
+++ b/guix/scripts/graph.scm
@@ -39,6 +39,16 @@
%bag-emerged-node-type
%derivation-node-type
%reference-node-type
+ %node-types
+
+ node-type
+ node-type?
+ node-type-identifier
+ node-type-label
+ node-type-edges
+ node-type-convert
+ node-type-name
+ node-type-description
%graphviz-backend
graph-backend?
@@ -370,6 +380,9 @@ given BACKEND. Use NODE-TYPE to traverse the DAG."
(lambda (opt name arg result)
(list-node-types)
(exit 0)))
+ (option '(#\e "expression") #t #f
+ (lambda (opt name arg result)
+ (alist-cons 'expression arg result)))
(option '(#\h "help") #f #f
(lambda args
(show-help)
@@ -387,6 +400,8 @@ Emit a Graphviz (dot) representation of the dependencies of PACKAGE...\n"))
-t, --type=TYPE represent nodes of the given TYPE"))
(display (_ "
--list-types list the available graph types"))
+ (display (_ "
+ -e, --expression=EXPR consider the package EXPR evaluates to"))
(newline)
(display (_ "
-h, --help display this help and exit"))
@@ -407,12 +422,14 @@ Emit a Graphviz (dot) representation of the dependencies of PACKAGE...\n"))
(with-error-handling
(let* ((opts (parse-command-line args %options
(list %default-options)))
- (specs (filter-map (match-lambda
- (('argument . spec) spec)
- (_ #f))
- opts))
(type (assoc-ref opts 'node-type))
- (packages (map specification->package specs)))
+ (packages (filter-map (match-lambda
+ (('argument . spec)
+ (specification->package spec))
+ (('expression . exp)
+ (read/eval-package-expression exp))
+ (_ #f))
+ opts)))
(with-store store
(run-with-store store
(mlet %store-monad ((nodes (mapm %store-monad
diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index 6cd762a537..7b29794e8f 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"))
+(define importers '("gnu" "nix" "pypi" "cpan" "hackage" "elpa" "gem" "cran"))
(define (resolve-importer name)
(let ((module (resolve-interface
diff --git a/guix/scripts/import/cran.scm b/guix/scripts/import/cran.scm
new file mode 100644
index 0000000000..f11fa1004f
--- /dev/null
+++ b/guix/scripts/import/cran.scm
@@ -0,0 +1,92 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
+;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
+;;;
+;;; 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 cran)
+ #:use-module (guix ui)
+ #:use-module (guix utils)
+ #:use-module (guix import cran)
+ #: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-cran))
+
+
+;;;
+;;; Command-line options.
+;;;
+
+(define %default-options
+ '())
+
+(define (show-help)
+ (display (_ "Usage: guix import cran PACKAGE-NAME
+Import and convert the CRAN 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 cran")))
+ %standard-import-options))
+
+
+;;;
+;;; Entry point.
+;;;
+
+(define (guix-import-cran . 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 (cran->guix-package package-name)))
+ (unless sexp
+ (leave (_ "failed to download description for package '~a'~%")
+ package-name))
+ sexp))
+ (()
+ (leave (_ "too few arguments~%")))
+ ((many ...)
+ (leave (_ "too many arguments~%"))))))
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index 14ac8cba81..2a618c9451 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -24,6 +24,7 @@
#:use-module (guix download)
#:use-module (guix ftp-client)
#:use-module (guix packages)
+ #:use-module (guix licenses)
#:use-module (guix records)
#:use-module (guix ui)
#:use-module (guix utils)
@@ -56,7 +57,15 @@
check-derivation
check-home-page
check-source
- check-formatting))
+ check-license
+ check-formatting
+
+ %checkers
+ lint-checker
+ lint-checker?
+ lint-checker-name
+ lint-checker-description
+ lint-checker-check))
;;;
@@ -511,6 +520,16 @@ descriptions maintained upstream."
(format #f (_ "failed to create derivation: ~s~%")
args)))))
+(define (check-license package)
+ "Warn about type errors of the 'license' field of PACKAGE."
+ (match (package-license package)
+ ((or (? license?)
+ ((? license?) ...))
+ #t)
+ (x
+ (emit-warning package (_ "invalid license field")
+ 'license))))
+
;;;
;;; Source code formatting.
@@ -613,6 +632,13 @@ them for PACKAGE."
(description "Validate home-page URLs")
(check check-home-page))
(lint-checker
+ (name 'license)
+ ;; TRANSLATORS: <license> is the name of a data type and must not be
+ ;; translated.
+ (description "Make sure the 'license' field is a <license> \
+or a list thereof")
+ (check check-license))
+ (lint-checker
(name 'source)
(description "Validate source URLs")
(check check-source))
diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm
index e3bcac8047..cc96355947 100644
--- a/guix/scripts/publish.scm
+++ b/guix/scripts/publish.scm
@@ -151,7 +151,7 @@ PATH-INFO. The narinfo is signed with KEY."
(references (string-join
(map basename (path-info-references path-info))
" "))
- (deriver (path-info-deriver path-info))
+ (deriver (path-info-deriver path-info))
(base-info (format #f
"StorePath: ~a
URL: ~a
@@ -162,12 +162,21 @@ References: ~a~%"
store-path url hash size references))
;; Do not render a "Deriver" or "System" line if we are rendering
;; info for a derivation.
- (info (if (string-null? deriver)
- base-info
- (let ((drv (load-derivation deriver)))
- (format #f "~aSystem: ~a~%Deriver: ~a~%"
- base-info (derivation-system drv)
- (basename deriver)))))
+ (info (if (string-null? deriver)
+ base-info
+ (catch 'system-error
+ (lambda ()
+ (let ((drv (load-derivation deriver)))
+ (format #f "~aSystem: ~a~%Deriver: ~a~%"
+ base-info (derivation-system drv)
+ (basename deriver))))
+ (lambda args
+ ;; DERIVER might be missing, but that's fine:
+ ;; it's only used for <substitutable> where it's
+ ;; optional. 'System' is currently unused.
+ (if (= ENOENT (system-error-errno args))
+ base-info
+ (apply throw args))))))
(signature (base64-encode-string
(canonical-sexp->string (signed-string info)))))
(format #f "~aSignature: 1;~a;~a~%" info (gethostname) signature)))
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index e6ed8d23eb..e8459e5ffb 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -43,7 +43,7 @@
(define %snapshot-url
;; "http://hydra.gnu.org/job/guix/master/tarball/latest/download"
- "http://git.savannah.gnu.org/cgit/guix.git/snapshot/guix-master.tar.gz"
+ "http://git.savannah.gnu.org/cgit/guix.git/snapshot/master.tar.gz"
)
(define-syntax-rule (with-environment-variable variable value body ...)
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index 28519d78e2..e7980a97b0 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -149,7 +149,7 @@ values: 'interactive' (default), 'always', and 'never'."
port-sha256)))
(update-package-source package version hash)))
(warning (_ "~a: version ~a could not be \
-downloaded and authenticated; not updating")
+downloaded and authenticated; not updating~%")
(package-name package) version)))))
diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm
index 95aae2a372..e908bc997e 100755
--- a/guix/scripts/substitute.scm
+++ b/guix/scripts/substitute.scm
@@ -703,7 +703,7 @@ Internal tool to substitute a pre-built binary to a local build.\n"))
;;;
(define (display-narinfo-data narinfo)
- "Write to the current output port the contents of NARINFO is the format
+ "Write to the current output port the contents of NARINFO in the format
expected by the daemon."
(format #t "~a\n~a\n~a\n"
(narinfo-path narinfo)