aboutsummaryrefslogtreecommitdiff
path: root/guix-build.in
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2013-02-12 01:24:21 -0500
committerMark H Weaver <mhw@netris.org>2013-02-13 22:05:19 -0500
commitdc5669cd654019994fa59ab26db59c292332ae55 (patch)
treec288dbbba737db6b71ca42da37b700b28caa6fac /guix-build.in
parentc2868b1e0c4155fbeffac9860d69a1ed6041156a (diff)
downloadguix-dc5669cd654019994fa59ab26db59c292332ae55.tar
guix-dc5669cd654019994fa59ab26db59c292332ae55.tar.gz
Build newest versions unless specified, and implement upgrades.
* gnu/packages.scm (find-newest-available-packages): New exported procedure. * guix-build.in (newest-available-packages, find-best-packages-by-name): New procedures. (find-package): Use find-best-packages-by-name, to guarantee that if a version number is not specified, only the newest versions will be considered. * guix-package.in (%options): Add --upgrade/-u option. (newest-available-packages, find-best-packages-by-name, upgradeable?): New procedures. (find-package): Use find-best-packages-by-name, to guarantee that if a version number is not specified, only the newest versions will be considered. (process-actions): Implement upgrade option. * doc/guix.texi (Invoking guix-package): In the description of --install, mention that if no version number is specified, the newest available version will be selected.
Diffstat (limited to 'guix-build.in')
-rw-r--r--guix-build.in20
1 files changed, 17 insertions, 3 deletions
diff --git a/guix-build.in b/guix-build.in
index f8c7115999..35ddb00861 100644
--- a/guix-build.in
+++ b/guix-build.in
@@ -13,6 +13,7 @@ exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \
!#
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -37,12 +38,14 @@ exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \
#:use-module (guix utils)
#:use-module (ice-9 format)
#:use-module (ice-9 match)
+ #:use-module (ice-9 vlist)
#: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)
- #:autoload (gnu packages) (find-packages-by-name)
+ #:autoload (gnu packages) (find-packages-by-name
+ find-newest-available-packages)
#:export (guix-build))
(define %store
@@ -196,13 +199,24 @@ Build the given PACKAGE-OR-DERIVATION and return their output paths.\n"))
root (strerror (system-error-errno args)))
(exit 1)))))
+ (define newest-available-packages
+ (memoize find-newest-available-packages))
+
+ (define (find-best-packages-by-name name version)
+ (if version
+ (find-packages-by-name name version)
+ (match (vhash-assoc name (newest-available-packages))
+ ((_ version pkgs ...) pkgs)
+ (#f '()))))
+
(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.
+ ;; number. If the version number is not present, return the
+ ;; preferred newest version.
(let-values (((name version)
(package-name->name+version request)))
- (match (find-packages-by-name name version)
+ (match (find-best-packages-by-name name version)
((p) ; one match
p)
((p x ...) ; several matches