summaryrefslogtreecommitdiff
path: root/gnu/packages.scm
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 /gnu/packages.scm
parentc2868b1e0c4155fbeffac9860d69a1ed6041156a (diff)
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 'gnu/packages.scm')
-rw-r--r--gnu/packages.scm26
1 files changed, 25 insertions, 1 deletions
diff --git a/gnu/packages.scm b/gnu/packages.scm
index f2f98de476..b639541788 100644
--- a/gnu/packages.scm
+++ b/gnu/packages.scm
@@ -22,6 +22,7 @@
#:use-module (guix utils)
#:use-module (ice-9 ftw)
#:use-module (ice-9 vlist)
+ #:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-39)
@@ -30,7 +31,8 @@
%patch-directory
%bootstrap-binaries-path
fold-packages
- find-packages-by-name))
+ find-packages-by-name
+ find-newest-available-packages))
;;; Commentary:
;;;
@@ -153,3 +155,25 @@ then only return packages whose version is equal to VERSION."
(cons package result)
result))
'()))
+
+(define (find-newest-available-packages)
+ "Return a vhash keyed by package names, and with
+associated values of the form
+
+ (newest-version newest-package ...)
+
+where the preferred package is listed first."
+
+ ;; FIXME: Currently, the preferred package is whichever one
+ ;; was found last by 'fold-packages'. Find a better solution.
+ (fold-packages (lambda (p r)
+ (let ((name (package-name p))
+ (version (package-version p)))
+ (match (vhash-assoc name r)
+ ((_ newest-so-far . pkgs)
+ (case (version-compare version newest-so-far)
+ ((>) (vhash-cons name `(,version ,p) r))
+ ((=) (vhash-cons name `(,version ,p ,@pkgs) r))
+ ((<) r)))
+ (#f (vhash-cons name `(,version ,p) r)))))
+ vlist-null))