From: ludo@gnu.org (Ludovic Courtès)
To: Roel Janssen <roel@gnu.org>
Cc: guix-devel <guix-devel@gnu.org>
Subject: Re: [PATCH] profiles: Let canonicalize-profile return an absolute path.
Date: Wed, 11 Jul 2018 13:06:22 +0200 [thread overview]
Message-ID: <87tvp6m3pt.fsf@gnu.org> (raw)
In-Reply-To: <87fu106vzk.fsf@gnu.org> (Roel Janssen's message of "Tue, 03 Jul 2018 19:59:43 +0200")
[-- Attachment #1: Type: text/plain, Size: 1333 bytes --]
Hi Roel,
Roel Janssen <roel@gnu.org> skribis:
> I'd like to change the way the symlinks to custom profiles are created.
> Here's what currently happens:
>
> $ guixr package -i hello -p guix-profiles/test
> $ ls -l guix-profiles
> lrwxrwxrwx. 1 user group 25 Jul 3 19:53 test -> guix-profiles/test-1-link
> lrwxrwxrwx. 1 user group 51 Jul 3 19:53 test-1-link -> /gnu/store/...6qbaps-profile
>
> Now, that symlink is broken.
> Instead, I'd like to have it always use absolute paths:
How about instead making the link to the generation file (“test-1-link”)
always a relative symlink? Like this:
--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix package -p foo/x -i sed
[...]
$ ls -l foo/*
lrwxrwxrwx 1 ludo users 8 Jul 11 13:03 foo/x -> x-1-link
lrwxrwxrwx 1 ludo users 51 Jul 11 13:03 foo/x-1-link -> /gnu/store/qp6dqlbsf0pw9p9fwc3gzdcaxx40rn9v-profile
--8<---------------cut here---------------end--------------->8---
Patch below.
FWIW I prefer avoiding ‘canonicalize-path’ in general because it’s
inefficient and because it can surprise the user: you can end up with a
long file name that you didn’t type in, or you can have ENOENT errors
because ‘canonicalize-path’ requires the given file to exist.
WDYT?
Thanks,
Ludo’.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1680 bytes --]
diff --git a/guix/profiles.scm b/guix/profiles.scm
index d2a794b18..f34f4fcff 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -1521,7 +1521,7 @@ the generation that was current before switching."
(profile profile)
(generation number)))))
(else
- (switch-symlinks profile generation)
+ (switch-symlinks profile (basename generation))
current))))
(define (switch-to-previous-generation profile)
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 29829f52c..b38a55d01 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -190,7 +190,7 @@ do not treat collisions in MANIFEST as an error."
(let* ((entries (manifest-entries manifest))
(count (length entries)))
(switch-symlinks name prof)
- (switch-symlinks profile name)
+ (switch-symlinks profile (basename name))
(unless (string=? profile %current-profile)
(register-gc-root store name))
(format #t (N_ "~a package in profile~%"
diff --git a/tests/guix-package.sh b/tests/guix-package.sh
index 3b3fa35cd..3833b568a 100644
--- a/tests/guix-package.sh
+++ b/tests/guix-package.sh
@@ -215,7 +215,7 @@ do
guix package --bootstrap --roll-back
! test -f "$HOME/.guix-profile/bin"
! test -f "$HOME/.guix-profile/lib"
- test "`readlink "$default_profile"`" = "$default_profile-0-link"
+ test "`readlink "$default_profile"`" = "`basename $default_profile-0-link`"
done
# Check whether '-p ~/.guix-profile' makes any difference.
next prev parent reply other threads:[~2018-07-11 11:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-03 17:59 [PATCH] profiles: Let canonicalize-profile return an absolute path Roel Janssen
2018-07-11 11:06 ` Ludovic Courtès [this message]
2018-07-12 20:53 ` Roel Janssen
2018-07-13 15:33 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87tvp6m3pt.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guix-devel@gnu.org \
--cc=roel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).