[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#36785: Impossible to pull on foreign distro
From: |
Ludovic Courtès |
Subject: |
bug#36785: Impossible to pull on foreign distro |
Date: |
Fri, 26 Jul 2019 10:09:02 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) |
Hi Julien,
Julien Lepiller <address@hidden> skribis:
> Le 26 juillet 2019 01:03:08 GMT+02:00, "Ludovic Courtès" <address@hidden> 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:
--- 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")))
… but then ‘sudo guix pull’ won’t update root’s guix at all.
Otherwise I’m thinking of this gross hack:
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/….
I think it’s acceptable because that’s “throw away” code anyway, and
it’s not supposed to be triggered these days.
Thoughts?
Ludo’.