aboutsummaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-10-09 11:51:12 +0200
committerLudovic Courtès <ludo@gnu.org>2018-10-11 18:29:11 +0200
commit50c72ecd9e272d959dfc346b5baea9137f6820ad (patch)
tree131ce56c4b727fba847cfb0ca3ae6ba725294114 /guix
parent77dcfb4c028417bed53c523dbb8c314e9556f85b (diff)
downloadgnu-guix-50c72ecd9e272d959dfc346b5baea9137f6820ad.tar
gnu-guix-50c72ecd9e272d959dfc346b5baea9137f6820ad.tar.gz
profiles: Generalize 'canonicalize-profile'.
* guix/profiles.scm (canonicalize-profile): Rewrite to work with any profile that lives under %PROFILE-DIRECTORY.
Diffstat (limited to 'guix')
-rw-r--r--guix/profiles.scm23
1 files changed, 11 insertions, 12 deletions
diff --git a/guix/profiles.scm b/guix/profiles.scm
index 6c3b26423e..99e6fe7371 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -1652,19 +1652,18 @@ to user ~s.")
(getuid))))))))))
(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>
-
- ;; Trim trailing slashes so that the basename comparison below works as
- ;; intended.
+ "If PROFILE points to a profile in %PROFILE-DIRECTORY, return that.
+Otherwise return PROFILE unchanged. The goal is to treat '-p ~/.guix-profile'
+as if '-p' was omitted." ; see <http://bugs.gnu.org/17939>
+ ;; Trim trailing slashes so 'readlink' can do its job.
(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)))
+ (catch 'system-error
+ (lambda ()
+ (let ((target (readlink profile)))
+ (if (string=? (dirname target) %profile-directory)
+ target
+ profile)))
+ (const profile))))
(define (user-friendly-profile profile)
"Return either ~/.guix-profile if that's what PROFILE refers to, directly or