From: "Ludovic Courtès" <ludo@gnu.org>
To: Julien Lepiller <julien@lepiller.eu>
Cc: 36785@debbugs.gnu.org
Subject: bug#36785: Impossible to pull on foreign distro
Date: Fri, 26 Jul 2019 10:09:02 +0200 [thread overview]
Message-ID: <87tvb9qktd.fsf@gnu.org> (raw)
In-Reply-To: <3DC355B8-FE36-4C4E-BBC9-EEC5F580AF0D@lepiller.eu> (Julien Lepiller's message of "Fri, 26 Jul 2019 08:22:01 +0200")
[-- Attachment #1: Type: text/plain, Size: 1578 bytes --]
Hi Julien,
Julien Lepiller <julien@lepiller.eu> skribis:
> Le 26 juillet 2019 01:03:08 GMT+02:00, "Ludovic Courtès" <ludo@gnu.org> a écrit :
[...]
>>;; In 0.15.0+ we'd create ~/.config/guix/current-[0-9]*-link symlinks.
>>Move
>> ;; them to %PROFILE-DIRECTORY.
>> (unless (string=? %profile-directory
>> (dirname (canonicalize-profile %user-profile-directory)))
>> (migrate-generations %user-profile-directory %profile-directory))
[...]
> Could there be some veird interaction between sudo and these %profile-directory and %user-profile-directory variables?
Indeed. I added ‘pk’ calls to print ‘%profile-directory’ and
(canonicalize-profile %user-profile-directory), and here’s what I see
with ‘sudo’:
--8<---------------cut here---------------start------------->8---
$ sudo -E ./pre-inst-env guix pull
;;; (pd "/var/guix/profiles/per-user/root")
;;; (upd "/home/ludo/.config/guix/current")
Migrating profile generations to '/var/guix/profiles/per-user/root'...
guix pull: error: symlink: Dosiero jam ekzistas: "/var/guix/profiles/per-user/root/current-guix"
--8<---------------cut here---------------end--------------->8---
‘%user-profile-directory’ is computed as a function of $HOME, which is
unchanged when using ‘sudo’, whereas ‘%profile-directory’ is computed as
a function of $USER.
I think $HOME should always prevail over the home directory defined in
/etc/passwd, so think we should not change the way
‘%user-profile-directory’ is computed.
We could do this:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 483 bytes --]
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -1721,7 +1721,8 @@ because the NUMBER is zero.)"
(define %profile-directory
(string-append %state-directory "/profiles/"
- (or (and=> (or (getenv "USER")
+ (or (and=> (or (getenv "SUDO_USER")
+ (getenv "USER")
(getenv "LOGNAME"))
(cut string-append "per-user/" <>))
"default")))
[-- Attachment #3: Type: text/plain, Size: 124 bytes --]
… but then ‘sudo guix pull’ won’t update root’s guix at all.
Otherwise I’m thinking of this gross hack:
[-- Attachment #4: Type: text/x-patch, Size: 816 bytes --]
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 54bbaddf30..8d8a8aa889 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -293,8 +293,9 @@ true, display what would be built without actually building it."
;; In 0.15.0+ we'd create ~/.config/guix/current-[0-9]*-link symlinks. Move
;; them to %PROFILE-DIRECTORY.
- (unless (string=? %profile-directory
- (dirname (canonicalize-profile %user-profile-directory)))
+ (unless (or (getenv "SUDO_USER")
+ (string=? (pk 'pd %profile-directory)
+ (dirname (pk 'upd (canonicalize-profile %user-profile-directory)))))
(migrate-generations %user-profile-directory %profile-directory))
;; Make sure ~/.config/guix/current points to /var/guix/profiles/….
[-- Attachment #5: Type: text/plain, Size: 154 bytes --]
I think it’s acceptable because that’s “throw away” code anyway, and
it’s not supposed to be triggered these days.
Thoughts?
Ludo’.
next prev parent reply other threads:[~2019-07-26 8:10 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-24 14:40 bug#36785: Impossible to pull on foreign distro Julien Lepiller
2019-07-25 23:03 ` Ludovic Courtès
2019-07-26 6:22 ` Julien Lepiller
2019-07-26 8:09 ` Ludovic Courtès [this message]
2019-09-17 22:03 ` Ludovic Courtès
2019-09-17 23:33 ` Gábor Boskovits
2019-09-18 8:48 ` Ludovic Courtès
2019-09-20 8:47 ` Maxim Cournoyer
2019-09-20 15:44 ` Ludovic Courtès
2019-09-21 12:31 ` Maxim Cournoyer
2019-09-23 8:29 ` Ludovic Courtès
2019-09-23 9:00 ` Gábor Boskovits
2019-09-23 12:48 ` Ludovic Courtès
2019-09-23 14:09 ` Maxim Cournoyer
2019-09-24 12:37 ` Ludovic Courtès
2019-09-27 15:23 ` Maxim Cournoyer
2019-09-28 17:49 ` Ludovic Courtès
2019-09-29 1:36 ` Maxim Cournoyer
2019-09-21 12:32 ` Maxim Cournoyer
2019-09-18 18:35 ` Ricardo Wurmus
2019-09-19 8:24 ` 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=87tvb9qktd.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=36785@debbugs.gnu.org \
--cc=julien@lepiller.eu \
/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).