From c7ba5f38b80433b040d3946b8fc0b1e8621ba30a Mon Sep 17 00:00:00 2001 From: John Kehayias Date: Wed, 20 Jul 2022 23:46:45 -0400 Subject: environment: Add '--emulate-fhs'. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/scripts/environment.scm (show-environment-options-help, %options): Add '--emulate-fhs'. (setup-fhs): New procedure. Setup for the Filesystem Hierarchy Standard (FHS) container. Defines and uses FHS-SYMLINKS and LINK-CONTENTS to create FHS expected directories and creates /etc/ld.so.conf. (launch-environment): Add 'emulate-fhs?' key and implement it to set $PATH and generate /etc/ld.so.cache before calling COMMAND. (launch-environment/container): Add 'emulate-fhs?' and 'setup-hook' keys and implement them. Define and use FHS-MAPPINGS, to set up additional bind mounts in the container to follow FHS expectations. (guix-environment*): Add glibc-for-fhs to the container packages when 'emulate-fhs?' key is in OPTS. * doc/guix.texi (Invoking guix shell): Document '--emulate-fhs'. (Invoking guix environment): Document '--emulate-fhs'. * tests/guix-environment-container.sh: Add tests for '--emulate-fhs'. Co-authored-by: Ludovic Courtès --- tests/guix-environment-container.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests') diff --git a/tests/guix-environment-container.sh b/tests/guix-environment-container.sh index 2e238c501d..898c57f41b 100644 --- a/tests/guix-environment-container.sh +++ b/tests/guix-environment-container.sh @@ -197,3 +197,37 @@ then false; else test $? -gt 127 fi + +# Test the Filesystem Hierarchy Standard (FHS) container option, --emulate-fhs (-F) + +# As this option requires a glibc package (glibc-for-fhs), try to run these +# tests with the user's global store to make it easier to build or download a +# substitute. +storedir="`guile -c '(use-modules (guix config))(display %storedir)'`" +localstatedir="`guile -c '(use-modules (guix config))(display %localstatedir)'`" +NIX_STORE_DIR="$storedir" +GUIX_DAEMON_SOCKET="$localstatedir/guix/daemon-socket/socket" +export NIX_STORE_DIR GUIX_DAEMON_SOCKET + +if ! guile -c '(use-modules (guix)) (exit (false-if-exception (open-connection)))' +then + exit 77 +fi + +# Test that the container has FHS specific files/directories. Note that /bin +# exists in a non-FHS container as it will contain sh, a symlink to the bash +# package, so we don't test for it. +guix environment -C --emulate-fhs --ad-hoc --bootstrap guile-bootstrap \ + -- guile -c '(exit (and (file-exists? "/etc/ld.so.cache") + (file-exists? "/lib") + (file-exists? "/sbin") + (file-exists? "/usr/bin") + (file-exists? "/usr/include") + (file-exists? "/usr/lib") + (file-exists? "/usr/libexec") + (file-exists? "/usr/sbin") + (file-exists? "/usr/share")))' + +# Test that the ld cache was generated and can be successfully read. +guix environment -C --emulate-fhs --ad-hoc --bootstrap guile-bootstrap \ + -- guile -c '(execlp "ldconfig" "ldconfig" "-p")' -- cgit v1.2.3