~ruther/guix-local

edbe07cd67d6050d94fe8ac1af15ab15e857b61d — Ludovic Courtès 8 years ago 457103b
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.
1 files changed, 10 insertions(+), 6 deletions(-)

M guix/scripts/package.scm
M guix/scripts/package.scm => guix/scripts/package.scm +10 -6
@@ 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