profiles: Generalize 'canonicalize-profile'.
* guix/profiles.scm (canonicalize-profile): Rewrite to work with any profile that lives under %PROFILE-DIRECTORY.
This commit is contained in:
parent
77dcfb4c02
commit
50c72ecd9e
|
@ -1652,19 +1652,18 @@ to user ~s.")
|
||||||
(getuid))))))))))
|
(getuid))))))))))
|
||||||
|
|
||||||
(define (canonicalize-profile profile)
|
(define (canonicalize-profile profile)
|
||||||
"If PROFILE is %USER-PROFILE-DIRECTORY, return %CURRENT-PROFILE. Otherwise
|
"If PROFILE points to a profile in %PROFILE-DIRECTORY, return that.
|
||||||
return PROFILE unchanged. The goal is to treat '-p ~/.guix-profile' as if
|
Otherwise return PROFILE unchanged. The goal is to treat '-p ~/.guix-profile'
|
||||||
'-p' was omitted." ; see <http://bugs.gnu.org/17939>
|
as if '-p' was omitted." ; see <http://bugs.gnu.org/17939>
|
||||||
|
;; Trim trailing slashes so 'readlink' can do its job.
|
||||||
;; Trim trailing slashes so that the basename comparison below works as
|
|
||||||
;; intended.
|
|
||||||
(let ((profile (string-trim-right profile #\/)))
|
(let ((profile (string-trim-right profile #\/)))
|
||||||
(if (and %user-profile-directory
|
(catch 'system-error
|
||||||
(string=? (canonicalize-path (dirname profile))
|
(lambda ()
|
||||||
(dirname %user-profile-directory))
|
(let ((target (readlink profile)))
|
||||||
(string=? (basename profile) (basename %user-profile-directory)))
|
(if (string=? (dirname target) %profile-directory)
|
||||||
%current-profile
|
target
|
||||||
profile)))
|
profile)))
|
||||||
|
(const profile))))
|
||||||
|
|
||||||
(define (user-friendly-profile profile)
|
(define (user-friendly-profile profile)
|
||||||
"Return either ~/.guix-profile if that's what PROFILE refers to, directly or
|
"Return either ~/.guix-profile if that's what PROFILE refers to, directly or
|
||||||
|
|
Loading…
Reference in New Issue