diff options
author | Ludovic Courtès <ludo@gnu.org> | 2013-01-22 22:13:10 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-01-22 22:14:25 +0100 |
commit | 5401dd7595f558e759c82b1dede0c2fb687f296b (patch) | |
tree | 0b04aa9805bc61d9e01676a634bf4572237e6cc2 /guix-build.in | |
parent | 476f8ea33ce3791dbe0c77332c92e4351827dcd5 (diff) | |
download | guix-5401dd7595f558e759c82b1dede0c2fb687f296b.tar.gz |
guix-build: Allow version-qualified package names.
* guix-build.in (guix-build)[find-package]: New procedure. Use it instead of using `find-packages-by-name' directly. Suggested by Andreas Enge <andreas@enge.fr>. * tests/guix-build.sh: Add tests. * doc/guix.texi (Invoking guix-build): Add `coreutils-8.20' as an example. Fix guile-1.8 example.
Diffstat (limited to 'guix-build.in')
-rw-r--r-- | guix-build.in | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/guix-build.in b/guix-build.in index e3894b8af2..7f278a5733 100644 --- a/guix-build.in +++ b/guix-build.in @@ -38,6 +38,7 @@ exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \ #:use-module (ice-9 format) #:use-module (ice-9 match) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-11) #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:use-module (srfi srfi-37) @@ -195,6 +196,30 @@ Build the given PACKAGE-OR-DERIVATION and return their output paths.\n")) root (strerror (system-error-errno args))) (exit 1))))) + (define (find-package request) + ;; Return a package matching REQUEST. REQUEST may be a package + ;; name, or a package name followed by a hyphen and a version + ;; number. + (let-values (((name version) + (package-name->name+version request))) + (match (find-packages-by-name name version) + ((p) ; one match + p) + ((p _ ...) ; several matches + (format (current-error-port) + (_ "warning: ambiguous package specification `~a'~%") + request) + (format (current-error-port) + (_ "warning: choosing ~a from ~a~%") + (package-full-name p) + (location->string (package-location p))) + p) + (_ ; no matches + (if version + (leave (_ "~A: package not found for version ~a~%") + name version) + (leave (_ "~A: unknown package~%") name)))))) + (setlocale LC_ALL "") (textdomain "guix") (setvbuf (current-output-port) _IOLBF) @@ -212,14 +237,12 @@ Build the given PACKAGE-OR-DERIVATION and return their output paths.\n")) (('argument . (? derivation-path? drv)) drv) (('argument . (? string? x)) - (match (find-packages-by-name x) - ((p _ ...) - (if src? - (let ((s (package-source p))) - (package-source-derivation (%store) s)) - (package-derivation (%store) p sys))) - (_ - (leave (_ "~A: unknown package~%") x)))) + (let ((p (find-package x))) + (if src? + (let ((s (package-source p))) + (package-source-derivation + (%store) s)) + (package-derivation (%store) p sys)))) (_ #f)) opts)) (req (append-map (lambda (drv-path) |