diff options
author | Mark H Weaver <mhw@netris.org> | 2013-02-12 01:24:21 -0500 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-02-27 20:55:39 +0100 |
commit | 854d62777938eaf5552d8e90a3848e3a8fdbbbbd (patch) | |
tree | 9cd99c670c4146dd6b6fc1eddae270b3685773a7 /gnu | |
parent | 9ede36f0ed2ea3c2a6a020b52e51b741b07cbc1f (diff) | |
download | guix-854d62777938eaf5552d8e90a3848e3a8fdbbbbd.tar guix-854d62777938eaf5552d8e90a3848e3a8fdbbbbd.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 'gnu')
-rw-r--r-- | gnu/packages.scm | 26 |
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)) |