unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: John Kehayias <john.kehayias@protonmail.com>
Cc: "guix-devel@gnu.org" <guix-devel@gnu.org>
Subject: Re: [WIP Patch] Adding an FHS container to guix shell
Date: Mon, 18 Jul 2022 13:40:24 +0200	[thread overview]
Message-ID: <875yju1wev.fsf@gnu.org> (raw)
In-Reply-To: <wRurC6zEkibzf7R3zDyicYmqKPN1NUSJ6gAS5qvTrsL-MmfRTpbJOqbBoIhjhEGYFMswI0RvU3tDSTldLKot9fP21R4XW_bXwMKbL4RE7P4=@protonmail.com> (John Kehayias's message of "Tue, 12 Jul 2022 15:59:14 +0000")

Hello!

John Kehayias <john.kehayias@protonmail.com> skribis:

> 2. Typically binaries will expect the ld loader to use
> /etc/ld.so.cache for finding libraries.

Not necessarily.  /etc/ld.so.cache is an optimization, but it’s entirely
possible to opt out: if that file is missing, things will work fine, but
libc will ‘stat’ more to find files.  That would make glibc-for-fhs
unnecessary.

> +(define* (launch-environment/container #:key command bash fhs-container? user
> +                                       user-mappings profile manifest
> +                                       link-profile? network? map-cwd?
> +                                       (white-list '()))
>    "Run COMMAND within a container that features the software in PROFILE.
>  Environment variables are set according to the search paths of MANIFEST.
>  The global shell is BASH, a file name for a GNU Bash binary in the
> @@ -709,6 +718,49 @@ (define* (launch-environment/container #:key command bash user user-mappings
>              (mkdir-p home-dir)
>              (setenv "HOME" home-dir)
>  
> +            ;; Set up an FHS container.
> +            (when fhs-container?
> +              ;; Set up the expected bin and library directories as symlinks to
> +              ;; the profile lib directory.  Note that this is assuming a 64bit
> +              ;; architecture.
> +              (let ((lib-dir (string-append profile "/lib")))
> +                (symlink lib-dir "/lib64")
> +                (symlink lib-dir "/lib")
> +                (mkdir-p "/usr")
> +                (symlink lib-dir "/usr/lib"))

Instead of adding code here, maybe you could do in a more declarative
fashion, like:

  (define fhs-mappings
    (list (file-system-mapping
            (source (string-append profile "/bin")) (target "/bin"))
          …))

and append that to the ‘mappings’ variable there.  It’s not necessarily
more compact, but maybe marginally easier to read?

> +              ;; Define an entry script to start the container: generate
> +              ;; ld.so.cache, supplement $PATH, and include command.

I’d leave ld.so.cache generation out.

> +              (call-with-output-file "/tmp/fhs.sh"
> +                (lambda (port)
> +                  (display "ldconfig -X -f /tmp/ld.so.conf" port)
> +                  (newline port)
> +                  (display "export PATH=/bin:/usr/bin:/sbin:/usr/sbin:$PATH" port)

I think the default value of PATH in our libc is the FHS one:

--8<---------------cut here---------------start------------->8---
$ env -i $(type -P strace) -e execve -f $(type -P guile) -c '(system* "whatever")'
execve("/gnu/store/lpcjxka7hx3ypv4nz47g08k4m2syqwlj-profile/bin/guile", ["/gnu/store/lpcjxka7hx3ypv4nz47g0"..., "-c", "(system* \"whatever\")"], 0x7ffede27ad38 /* 0 vars */) = 0
/home/ludo/.guix-home/profile/bin/strace: Process 9727 attached
/home/ludo/.guix-home/profile/bin/strace: Process 9728 attached
/home/ludo/.guix-home/profile/bin/strace: Process 9729 attached
/home/ludo/.guix-home/profile/bin/strace: Process 9730 attached
/home/ludo/.guix-home/profile/bin/strace: Process 9731 attached
/home/ludo/.guix-home/profile/bin/strace: Process 9732 attached
[pid  9732] execve("/bin/whatever", ["whatever"], 0x7ffed6d967c8 /* 0 vars */) = -1 ENOENT (No such file or directory)
[pid  9732] execve("/usr/bin/whatever", ["whatever"], 0x7ffed6d967c8 /* 0 vars */) = -1 ENOENT (No such file or directory)
In execvp of whatever: No such file or directory
--8<---------------cut here---------------end--------------->8---

So you could leave it undefined, but ‘load-profile’ in
‘launch-environment’ will define it.

Instead of the wrapper script, maybe you could extend
‘launch-environment’ so the caller can make it override certain
variables?  I would find it a bit clearer.

Thanks,
Ludo’.


  parent reply	other threads:[~2022-07-18 11:42 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-12 15:59 [WIP Patch] Adding an FHS container to guix shell John Kehayias
2022-07-12 17:34 ` Vagrant Cascadian
2022-07-15 15:41   ` John Kehayias
2022-07-13  2:11 ` Dominic Martinez
2022-07-13 23:27   ` Blake Shaw
2022-07-15 15:44   ` John Kehayias
2022-07-14 10:01 ` zimoun
2022-07-15 15:46   ` John Kehayias
2022-07-14 14:59 ` Liliana Marie Prikler
2022-07-15 16:00   ` John Kehayias
2022-07-15 13:43 ` Maxim Cournoyer
2022-07-15 16:35   ` John Kehayias
2022-07-15 13:45 ` Maxim Cournoyer
2022-07-18 11:40 ` Ludovic Courtès [this message]
2022-07-20 21:22   ` John Kehayias
2022-07-20 23:49     ` Maxime Devos
2022-07-21  3:15       ` John Kehayias
2022-07-21  0:20 ` debbugs irritation Was: " Csepp
2022-07-21  4:18   ` John Kehayias
2022-07-21 16:45   ` zimoun
2022-07-21 20:22     ` Csepp
2022-08-18 10:55       ` zimoun
2022-08-19 22:13         ` jbranso
2022-07-21  4:25 ` John Kehayias

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=875yju1wev.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guix-devel@gnu.org \
    --cc=john.kehayias@protonmail.com \
    /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).