guix package: Trim trailing slashes from the profile name.

Fixes <https://bugs.gnu.org/25762>.
Reported by Ricardo Wurmus <rekado@elephly.net>.

* guix/scripts/package.scm (canonicalize-profile): Trim trailing slashes
from PROFILE.
This commit is contained in:
Ludovic Courtès 2017-07-20 15:23:13 +02:00
parent 457103b90b
commit edbe07cd67
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5

View File

@ -84,12 +84,16 @@
"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))
;; Trim trailing slashes so that the basename comparison below works as
;; intended.
(let ((profile (string-trim-right profile #\/)))
(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 (user-friendly-profile profile)
"Return either ~/.guix-profile if that's what PROFILE refers to, directly or