diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2015-11-10 22:00:53 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2015-11-11 00:37:50 +0100 |
| commit | fc2d2339644b408574f0ead4436e751fa423a7e6 (patch) | |
| tree | 2c5875eed1bad42d8f81a11ce8b49ff203fe09d7 | |
| parent | 21059b26b070d6064202272982392a299f09b6e4 (diff) | |
guix package: '--search-paths' can report combined search paths.
Partly fixes <http://bugs.gnu.org/20255>.
* guix/scripts/package.scm (search-path-environment-variables): Change
'profile' to 'profiles'; expect it to be a list.
(display-search-paths): Likewise.
(%default-options): Remove 'profile' entry.
(%options) <--profile>: Keep previous values associated with 'profile'
in RESULT.
(guix-package)[process-actions, process-query]: Handle the possible
lack of 'profile' pair in OPTS.
| -rw-r--r-- | doc/guix.texi | 14 | ||||
| -rw-r--r-- | guix/scripts/package.scm | 64 | ||||
| -rw-r--r-- | tests/guix-package-net.sh | 12 |
3 files changed, 60 insertions, 30 deletions
diff --git a/doc/guix.texi b/doc/guix.texi index 896a8c84967..09a860a64f4 100644 --- a/doc/guix.texi +++ b/doc/guix.texi | |||
| @@ -1347,6 +1347,20 @@ meaning that the returned environment variable definitions will either | |||
| 1347 | be exact settings, or prefixes or suffixes of the current value of these | 1347 | be exact settings, or prefixes or suffixes of the current value of these |
| 1348 | variables. When omitted, @var{kind} defaults to @code{exact}. | 1348 | variables. When omitted, @var{kind} defaults to @code{exact}. |
| 1349 | 1349 | ||
| 1350 | This option can also be used to compute the @emph{combined} search paths | ||
| 1351 | of several profiles. Consider this example: | ||
| 1352 | |||
| 1353 | @example | ||
| 1354 | $ guix package -p foo -i guile | ||
| 1355 | $ guix package -p bar -i guile-json | ||
| 1356 | $ guix package -p foo -p bar --search-paths | ||
| 1357 | @end example | ||
| 1358 | |||
| 1359 | The last command above reports about the @code{GUILE_LOAD_PATH} | ||
| 1360 | variable, even though, taken individually, neither @file{foo} nor | ||
| 1361 | @file{bar} would lead to that recommendation. | ||
| 1362 | |||
| 1363 | |||
| 1350 | @item --profile=@var{profile} | 1364 | @item --profile=@var{profile} |
| 1351 | @itemx -p @var{profile} | 1365 | @itemx -p @var{profile} |
| 1352 | Use @var{profile} instead of the user's default profile. | 1366 | Use @var{profile} instead of the user's default profile. |
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index adbc4a18282..5a059f12ae2 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm | |||
| @@ -186,11 +186,11 @@ an output path different than CURRENT-PATH." | |||
| 186 | ;;; Search paths. | 186 | ;;; Search paths. |
| 187 | ;;; | 187 | ;;; |
| 188 | 188 | ||
| 189 | (define* (search-path-environment-variables entries profile | 189 | (define* (search-path-environment-variables entries profiles |
| 190 | #:optional (getenv getenv) | 190 | #:optional (getenv getenv) |
| 191 | #:key (kind 'exact)) | 191 | #:key (kind 'exact)) |
| 192 | "Return environment variable definitions that may be needed for the use of | 192 | "Return environment variable definitions that may be needed for the use of |
| 193 | ENTRIES, a list of manifest entries, in PROFILE. Use GETENV to determine the | 193 | ENTRIES, a list of manifest entries, in PROFILES. Use GETENV to determine the |
| 194 | current settings and report only settings not already effective. KIND | 194 | current settings and report only settings not already effective. KIND |
| 195 | must be one of 'exact, 'prefix, or 'suffix, depending on the kind of search | 195 | must be one of 'exact, 'prefix, or 'suffix, depending on the kind of search |
| 196 | path definition to be returned." | 196 | path definition to be returned." |
| @@ -205,15 +205,15 @@ path definition to be returned." | |||
| 205 | (environment-variable-definition variable value | 205 | (environment-variable-definition variable value |
| 206 | #:separator sep | 206 | #:separator sep |
| 207 | #:kind kind)))) | 207 | #:kind kind)))) |
| 208 | (evaluate-search-paths search-paths (list profile) | 208 | (evaluate-search-paths search-paths profiles |
| 209 | getenv)))) | 209 | getenv)))) |
| 210 | 210 | ||
| 211 | (define* (display-search-paths entries profile | 211 | (define* (display-search-paths entries profiles |
| 212 | #:key (kind 'exact)) | 212 | #:key (kind 'exact)) |
| 213 | "Display the search path environment variables that may need to be set for | 213 | "Display the search path environment variables that may need to be set for |
| 214 | ENTRIES, a list of manifest entries, in the context of PROFILE." | 214 | ENTRIES, a list of manifest entries, in the context of PROFILE." |
| 215 | (let* ((profile (user-friendly-profile profile)) | 215 | (let* ((profiles (map user-friendly-profile profiles)) |
| 216 | (settings (search-path-environment-variables entries profile | 216 | (settings (search-path-environment-variables entries profiles |
| 217 | #:kind kind))) | 217 | #:kind kind))) |
| 218 | (unless (null? settings) | 218 | (unless (null? settings) |
| 219 | (format #t (_ "The following environment variable definitions may be needed:~%")) | 219 | (format #t (_ "The following environment variable definitions may be needed:~%")) |
| @@ -226,8 +226,7 @@ ENTRIES, a list of manifest entries, in the context of PROFILE." | |||
| 226 | 226 | ||
| 227 | (define %default-options | 227 | (define %default-options |
| 228 | ;; Alist of default option values. | 228 | ;; Alist of default option values. |
| 229 | `((profile . ,%current-profile) | 229 | `((max-silent-time . 3600) |
| 230 | (max-silent-time . 3600) | ||
| 231 | (verbosity . 0) | 230 | (verbosity . 0) |
| 232 | (substitutes? . #t))) | 231 | (substitutes? . #t))) |
| 233 | 232 | ||
| @@ -386,7 +385,7 @@ kind of search path~%") | |||
| 386 | (option '(#\p "profile") #t #f | 385 | (option '(#\p "profile") #t #f |
| 387 | (lambda (opt name arg result arg-handler) | 386 | (lambda (opt name arg result arg-handler) |
| 388 | (values (alist-cons 'profile (canonicalize-profile arg) | 387 | (values (alist-cons 'profile (canonicalize-profile arg) |
| 389 | (alist-delete 'profile result)) | 388 | result) |
| 390 | #f))) | 389 | #f))) |
| 391 | (option '(#\n "dry-run") #f #f | 390 | (option '(#\n "dry-run") #f #f |
| 392 | (lambda (opt name arg result arg-handler) | 391 | (lambda (opt name arg result arg-handler) |
| @@ -601,7 +600,7 @@ more information.~%")) | |||
| 601 | ;; Process any install/remove/upgrade action from OPTS. | 600 | ;; Process any install/remove/upgrade action from OPTS. |
| 602 | 601 | ||
| 603 | (define dry-run? (assoc-ref opts 'dry-run?)) | 602 | (define dry-run? (assoc-ref opts 'dry-run?)) |
| 604 | (define profile (assoc-ref opts 'profile)) | 603 | (define profile (or (assoc-ref opts 'profile) %current-profile)) |
| 605 | 604 | ||
| 606 | (define (build-and-use-profile manifest) | 605 | (define (build-and-use-profile manifest) |
| 607 | (let* ((bootstrap? (assoc-ref opts 'bootstrap?))) | 606 | (let* ((bootstrap? (assoc-ref opts 'bootstrap?))) |
| @@ -645,7 +644,7 @@ more information.~%")) | |||
| 645 | "~a packages in profile~%" | 644 | "~a packages in profile~%" |
| 646 | count) | 645 | count) |
| 647 | count) | 646 | count) |
| 648 | (display-search-paths entries profile))))))))) | 647 | (display-search-paths entries (list profile)))))))))) |
| 649 | 648 | ||
| 650 | ;; First roll back if asked to. | 649 | ;; First roll back if asked to. |
| 651 | (cond ((and (assoc-ref opts 'roll-back?) | 650 | (cond ((and (assoc-ref opts 'roll-back?) |
| @@ -674,12 +673,12 @@ more information.~%")) | |||
| 674 | (not dry-run?)) | 673 | (not dry-run?)) |
| 675 | (for-each | 674 | (for-each |
| 676 | (match-lambda | 675 | (match-lambda |
| 677 | (('delete-generations . pattern) | 676 | (('delete-generations . pattern) |
| 678 | (delete-matching-generations (%store) profile pattern) | 677 | (delete-matching-generations (%store) profile pattern) |
| 679 | 678 | ||
| 680 | (process-actions | 679 | (process-actions |
| 681 | (alist-delete 'delete-generations opts))) | 680 | (alist-delete 'delete-generations opts))) |
| 682 | (_ #f)) | 681 | (_ #f)) |
| 683 | opts)) | 682 | opts)) |
| 684 | ((assoc-ref opts 'manifest) | 683 | ((assoc-ref opts 'manifest) |
| 685 | (let* ((file-name (assoc-ref opts 'manifest)) | 684 | (let* ((file-name (assoc-ref opts 'manifest)) |
| @@ -709,7 +708,14 @@ more information.~%")) | |||
| 709 | (define (process-query opts) | 708 | (define (process-query opts) |
| 710 | ;; Process any query specified by OPTS. Return #t when a query was | 709 | ;; Process any query specified by OPTS. Return #t when a query was |
| 711 | ;; actually processed, #f otherwise. | 710 | ;; actually processed, #f otherwise. |
| 712 | (let ((profile (assoc-ref opts 'profile))) | 711 | (let* ((profiles (match (filter-map (match-lambda |
| 712 | (('profile . p) p) | ||
| 713 | (_ #f)) | ||
| 714 | opts) | ||
| 715 | (() (list %current-profile)) | ||
| 716 | (lst lst))) | ||
| 717 | (profile (match profiles | ||
| 718 | ((head tail ...) head)))) | ||
| 713 | (match (assoc-ref opts 'query) | 719 | (match (assoc-ref opts 'query) |
| 714 | (('list-generations pattern) | 720 | (('list-generations pattern) |
| 715 | (define (list-generation number) | 721 | (define (list-generation number) |
| @@ -718,7 +724,7 @@ more information.~%")) | |||
| 718 | (display-profile-content profile number) | 724 | (display-profile-content profile number) |
| 719 | (newline))) | 725 | (newline))) |
| 720 | 726 | ||
| 721 | (cond ((not (file-exists? profile)) ; XXX: race condition | 727 | (cond ((not (file-exists? profile)) ; XXX: race condition |
| 722 | (raise (condition (&profile-not-found-error | 728 | (raise (condition (&profile-not-found-error |
| 723 | (profile profile))))) | 729 | (profile profile))))) |
| 724 | ((string-null? pattern) | 730 | ((string-null? pattern) |
| @@ -741,11 +747,11 @@ more information.~%")) | |||
| 741 | (installed (manifest-entries manifest))) | 747 | (installed (manifest-entries manifest))) |
| 742 | (leave-on-EPIPE | 748 | (leave-on-EPIPE |
| 743 | (for-each (match-lambda | 749 | (for-each (match-lambda |
| 744 | (($ <manifest-entry> name version output path _) | 750 | (($ <manifest-entry> name version output path _) |
| 745 | (when (or (not regexp) | 751 | (when (or (not regexp) |
| 746 | (regexp-exec regexp name)) | 752 | (regexp-exec regexp name)) |
| 747 | (format #t "~a\t~a\t~a\t~a~%" | 753 | (format #t "~a\t~a\t~a\t~a~%" |
| 748 | name (or version "?") output path)))) | 754 | name (or version "?") output path)))) |
| 749 | 755 | ||
| 750 | ;; Show most recently installed packages last. | 756 | ;; Show most recently installed packages last. |
| 751 | (reverse installed))) | 757 | (reverse installed))) |
| @@ -793,12 +799,12 @@ more information.~%")) | |||
| 793 | #t)) | 799 | #t)) |
| 794 | 800 | ||
| 795 | (('search-paths kind) | 801 | (('search-paths kind) |
| 796 | (let* ((manifest (profile-manifest profile)) | 802 | (let* ((manifests (map profile-manifest profiles)) |
| 797 | (entries (manifest-entries manifest)) | 803 | (entries (append-map manifest-entries manifests)) |
| 798 | (profile (user-friendly-profile profile)) | 804 | (profiles (map user-friendly-profile profiles)) |
| 799 | (settings (search-path-environment-variables entries profile | 805 | (settings (search-path-environment-variables entries profiles |
| 800 | (const #f) | 806 | (const #f) |
| 801 | #:kind kind))) | 807 | #:kind kind))) |
| 802 | (format #t "~{~a~%~}" settings) | 808 | (format #t "~{~a~%~}" settings) |
| 803 | #t)) | 809 | #t)) |
| 804 | 810 | ||
diff --git a/tests/guix-package-net.sh b/tests/guix-package-net.sh index 14222cfd25d..35ef6ff1a02 100644 --- a/tests/guix-package-net.sh +++ b/tests/guix-package-net.sh | |||
| @@ -46,9 +46,10 @@ fi | |||
| 46 | 46 | ||
| 47 | 47 | ||
| 48 | profile="t-profile-$$" | 48 | profile="t-profile-$$" |
| 49 | profile_alt="t-profile-alt-$$" | ||
| 49 | rm -f "$profile" | 50 | rm -f "$profile" |
| 50 | 51 | ||
| 51 | trap 'rm -f "$profile" "$profile-"[0-9]* ; rm -rf t-home-'"$$" EXIT | 52 | trap 'rm -f "$profile" "$profile_alt" "$profile-"[0-9]* ; rm -rf t-home-'"$$" EXIT |
| 52 | 53 | ||
| 53 | 54 | ||
| 54 | guix package --bootstrap -p "$profile" -i guile-bootstrap | 55 | guix package --bootstrap -p "$profile" -i guile-bootstrap |
| @@ -156,6 +157,15 @@ guix package -p "$profile" --switch-generation=2 | |||
| 156 | guix package -p "$profile" --delete-generations=3 | 157 | guix package -p "$profile" --delete-generations=3 |
| 157 | test -z "`guix package -p "$profile" -l 3`" | 158 | test -z "`guix package -p "$profile" -l 3`" |
| 158 | 159 | ||
| 160 | # Search path of combined profiles. 'LIBRARY_PATH' should show up only in the | ||
| 161 | # combination, not in the individual profiles. | ||
| 162 | rm "$profile" | ||
| 163 | guix package --bootstrap -p "$profile" -i guile-bootstrap | ||
| 164 | guix package --bootstrap -p "$profile_alt" -i gcc-bootstrap | ||
| 165 | if guix package -p "$profile" --search-paths | grep LIBRARY_PATH | ||
| 166 | then false; fi | ||
| 167 | guix package -p "$profile" -p "$profile_alt" --search-paths \ | ||
| 168 | | grep "LIBRARY_PATH.*$profile/lib" | ||
| 159 | 169 | ||
| 160 | # | 170 | # |
| 161 | # Try with the default profile. | 171 | # Try with the default profile. |
