diff options
author | Ludovic Courtès <ludo@gnu.org> | 2014-07-05 14:56:08 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2014-07-05 14:56:08 +0200 |
commit | 88371f0d7dcdbb1bd304073257e5214409e89c2f (patch) | |
tree | 1943dc4fea9f6b52e954497d1a845f19ecb08613 /guix/scripts | |
parent | e84d8b30d9ec17e1d1860a068e78631c35f6c334 (diff) | |
download | gnu-guix-88371f0d7dcdbb1bd304073257e5214409e89c2f.tar gnu-guix-88371f0d7dcdbb1bd304073257e5214409e89c2f.tar.gz |
guix package: Do the right thing for '-p ~/.guix-profile'.
Fixes <http://bugs.gnu.org/17939>.
Reported by Taylan Ulrich Bayirli/Kammer <taylanbayirli@gmail.com>.
* guix/scripts/package.scm (canonicalize-profile): New procedure.
(%options): Use it for --profile.
* tests/guix-package.sh: Add test.
Diffstat (limited to 'guix/scripts')
-rw-r--r-- | guix/scripts/package.scm | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index f930b00804..af86808fb5 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -68,6 +68,17 @@ ;; coexist with Nix profiles. (string-append %profile-directory "/guix-profile")) +(define (canonicalize-profile profile) + "If PROFILE is %USER-PROFILE-DIRECTORY, return %CURRENT-PROFILE. Otherwise +return PROFILE unchanged. The goal is to treat '-p ~/.guix-profile' as if +'-p' was omitted." ; see <http://bugs.gnu.org/17939> + (if (and %user-profile-directory + (string=? (canonicalize-path (dirname profile)) + (dirname %user-profile-directory)) + (string=? (basename profile) (basename %user-profile-directory))) + %current-profile + profile)) + (define (link-to-empty-profile generation) "Link GENERATION, a string, to the empty profile." (let* ((drv (profile-derivation (%store) (manifest '()))) @@ -573,7 +584,7 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n")) #f))) (option '(#\p "profile") #t #f (lambda (opt name arg result arg-handler) - (values (alist-cons 'profile arg + (values (alist-cons 'profile (canonicalize-profile arg) (alist-delete 'profile result)) #f))) (option '(#\n "dry-run") #f #f |