diff options
author | Ludovic Courtès <ludo@gnu.org> | 2013-03-01 21:12:32 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-03-01 21:54:56 +0100 |
commit | 5d4b411f8a3372455a8c92d10a28e88e9edba6eb (patch) | |
tree | a5ae425d43fa307dc3e86166d1901905727c66b3 /guix/scripts | |
parent | 431a35518f74f50238ccc106a6a3121a9fcc11b9 (diff) | |
download | gnu-guix-5d4b411f8a3372455a8c92d10a28e88e9edba6eb.tar gnu-guix-5d4b411f8a3372455a8c92d10a28e88e9edba6eb.tar.gz |
guix package: Add `--install-from-expression'.
* guix/scripts/package.scm (read/eval-package-expression): New
procedure.
(show-help): Add `-e'.
(%options): Likewise.
(guix-package)[process-actions]: Handle ('install . p) pairs, where P
is a package.
* tests/guix-package.sh: Add `boot_make_drv'. Use `-i $boot_make_drv'
once, and then use `-e $boot_make'.
* doc/guix.texi (Invoking guix package): Document `-e'.
Diffstat (limited to 'guix/scripts')
-rw-r--r-- | guix/scripts/package.scm | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 1f9355ff22..28ef721603 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -266,6 +266,26 @@ matching packages." (assoc-ref (derivation-outputs drv) sub-drv)))) `(,name ,out)))))) +(define (read/eval-package-expression str) + "Read and evaluate STR and return the package it refers to, or exit an +error." + (let ((exp (catch #t + (lambda () + (call-with-input-string str read)) + (lambda args + (leave (_ "failed to read expression ~s: ~s~%") + str args))))) + (let ((p (catch #t + (lambda () + (eval exp the-scm-module)) + (lambda args + (leave (_ "failed to evaluate expression `~a': ~s~%") + exp args))))) + (if (package? p) + p + (leave (_ "expression `~s' does not evaluate to a package~%") + exp))))) + ;;; ;;; Command-line options. @@ -281,6 +301,9 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n")) (display (_ " -i, --install=PACKAGE install PACKAGE")) (display (_ " + -e, --install-from-expression=EXP + install the package EXP evaluates to")) + (display (_ " -r, --remove=PACKAGE remove PACKAGE")) (display (_ " -u, --upgrade=REGEXP upgrade all the installed packages matching REGEXP")) @@ -325,6 +348,10 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n")) (option '(#\i "install") #t #f (lambda (opt name arg result) (alist-cons 'install arg result))) + (option '(#\e "install-from-expression") #t #f + (lambda (opt name arg result) + (alist-cons 'install (read/eval-package-expression arg) + result))) (option '(#\r "remove") #t #f (lambda (opt name arg result) (alist-cons 'remove arg result))) @@ -490,6 +517,19 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n")) (delete-duplicates (map input->name+path deps) same?)) + (define (package->tuple p) + (let ((path (package-derivation (%store) p)) + (deps (package-transitive-propagated-inputs p))) + `(,(package-name p) + ,(package-version p) + + ;; When given a package via `-e', install the first of its + ;; outputs (XXX). + ,(car (package-outputs p)) + + ,path + ,(canonicalize-deps deps)))) + ;; First roll back if asked to. (if (and (assoc-ref opts 'roll-back?) (not dry-run?)) (begin @@ -515,6 +555,8 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n")) (install (append upgrade (filter-map (match-lambda + (('install . (? package? p)) + #f) (('install . (? store-path?)) #f) (('install . package) @@ -530,6 +572,8 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n")) install)) (install* (append (filter-map (match-lambda + (('install . (? package? p)) + (package->tuple p)) (('install . (? store-path? path)) (let-values (((name version) (package-name->name+version |