From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id MI98N23IR2NTXwAAbAwnHQ (envelope-from ) for ; Thu, 13 Oct 2022 10:12:29 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id oG+aN23IR2NZAwEA9RJhRA (envelope-from ) for ; Thu, 13 Oct 2022 10:12:29 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7393720D41 for ; Thu, 13 Oct 2022 10:12:29 +0200 (CEST) Received: from localhost ([::1]:36682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oitKO-00033M-Im for larch@yhetil.org; Thu, 13 Oct 2022 04:12:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41360) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oisn9-0007Y8-U1 for guix-patches@gnu.org; Thu, 13 Oct 2022 03:38:13 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:60203) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oisn4-00056v-De for guix-patches@gnu.org; Thu, 13 Oct 2022 03:38:07 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oisn4-00012V-8F for guix-patches@gnu.org; Thu, 13 Oct 2022 03:38:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#56677] [PATCH 0/2] environment: Add --emulate-fhs option. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 13 Oct 2022 07:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56677 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: John Kehayias Cc: 56677@debbugs.gnu.org Received: via spool by 56677-submit@debbugs.gnu.org id=B56677.16656466743977 (code B ref 56677); Thu, 13 Oct 2022 07:38:02 +0000 Received: (at 56677) by debbugs.gnu.org; 13 Oct 2022 07:37:54 +0000 Received: from localhost ([127.0.0.1]:59281 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oismv-000124-Et for submit@debbugs.gnu.org; Thu, 13 Oct 2022 03:37:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37714) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oismu-00011s-7e for 56677@debbugs.gnu.org; Thu, 13 Oct 2022 03:37:52 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:35902) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oismo-000568-V3; Thu, 13 Oct 2022 03:37:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=ULwBArjOfaBh0W5k3usCZ+yTPkMJvMoZGFSLudPqnxw=; b=WR26XYkkZCrIhBHQr/fj 4GEpBb8Bw6qY+0XdZkMhRUAcGQwxUaxalWAVE5W3YdynMhNL9r6ublLDWgpf15zLhHArzbGIPni3O k/1agk5fk/SUGC1+UxFX1JcHKdMbTsvLqGrSY1QYest7HghGnrooYG41Sh6KhnJ43lpexcM9iXiLz 8OugJ0sIJlqXqi5u/ieT0zry5kTR02fveJouAA9ZhkY6W/RrS54QptfOCquJkyHnSjbUNrQy2ynMM 3eVnYSZPol4/rQBCpU92sQGZy2ZTXwn8gJjEI1eOcxf7PIdzvbO4B4cD+O4ufnvYcmTfJYazVbvjX ytQGjQ73UWQQ3w==; Received: from no3.u-bordeaux.fr ([147.210.179.68]:39538 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oismn-00041W-U6; Thu, 13 Oct 2022 03:37:46 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <1LCXD7_zuGflSFovh_mKvhdayNcoWp8ALeguq3i2-XWwWHgzZuPak2gSBN91VLNJ84lubuFAt1dPB282Zy0pBmh_zbiI2qI-7n0LP9F03u4=@protonmail.com> <87r11wmh2h.fsf@gnu.org> <87leqtd1m4.fsf_-_@gnu.org> <87edvntp6f.fsf@protonmail.com> Date: Thu, 13 Oct 2022 09:37:41 +0200 In-Reply-To: <87edvntp6f.fsf@protonmail.com> (John Kehayias's message of "Tue, 04 Oct 2022 18:32:44 +0000") Message-ID: <877d14tbqy.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1665648749; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=ULwBArjOfaBh0W5k3usCZ+yTPkMJvMoZGFSLudPqnxw=; b=YnkdHib31dTwvfh+4u0UmuyP8CEep50Roco3yC9QtAnLqwUhqHcGNVjBLaw/4zx/cdY5hY EAkKI+BvTnJlcJAuQjgelq0FgorsnJgLiB6iJ4MurxRAMo4Qhq19Qnv6ZIXirKvuSrQGCI Z6/XDXCxjV2mTzVSas930zRSVdGv5u9ljepMhi2fUmKh31gRl3ZD1/HHFgTPWu3lNgl4Nf S7FunBIwaKX1wwCE7xa3484Fk4IbPHYrCKcq6dtSxlPqO1/SG29aM7PJgIvomcXPyK9Aka JeLWogS6WIQG9h2bGMUarb/UxMycbi5IxBLVDRlDI5kHcqiGHDHFmTery/fvWg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1665648749; a=rsa-sha256; cv=none; b=DuPZ7oDWWY2xTO6fkfzUW5aTwWVzY4o825TNyzU4kjLy7b91HvP2MGWSzp0tTo7EwflWSg feJonOI8ySuVY9KKBFrVlErvVh9Uh7SUQPl/vYyvArNkvIbfQOhw0qZeDddd4+YnZgRcJt Tg+rABJeeIf5Zm8OD2ytYNXyTrJTz/+W6a3gHgdzcOHAHCjN8Kh1gj/BIooZz+mQ10tjzs rAi15UQgmzlbpsENim9rk387ph33BVfFhqIlDdfEj50idZWog3pvSAKrsXik/FwNP09Zz6 I/9jZ0JUuuvyH6ecc5TgDR5FtXytaV667dCO2wBdZkBuVRV6aJLSwxMud/DMgQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=WR26XYkk; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -1.30 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=WR26XYkk; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 7393720D41 X-Spam-Score: -1.30 X-Migadu-Scanner: scn1.migadu.com X-TUID: 9dBFZcBC3S8r --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi John, John Kehayias skribis: > From de7ae9b203a65e1ec1b1429ca4076f3f91b1ae33 Mon Sep 17 00:00:00 2001 > From: John Kehayias > Date: Wed, 20 Jul 2022 23:46:45 -0400 > Subject: [PATCH] environment: Add '--emulate-fhs'. > > * 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 $PAT= H 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 m= ounts > 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'. This new version of the patch looks great to me! I applied it and took the liberty to make the changes below; let me know if anything=E2=80=99s amiss. Pushed together with a news entry: 2c11e857af news: Add entry for 'guix shell --emulate-fhs'. c7ba5f38b8 environment: Add '--emulate-fhs'. 3d1d29e440 gnu: Add glibc-for-fhs. Thanks a lot for your work and for your patience! Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/doc/guix.texi b/doc/guix.texi index 43dfdd64f2..8803353f24 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -6196,21 +6196,26 @@ directory: guix shell --container --expose=$HOME=/exchange guile -- guile @end example +@cindex file system hierarchy standard (FHS) +@cindex FHS (file system hierarchy standard) @item --emulate-fhs -@item -F -For containers, emulate a Filesystem Hierarchy Standard (FHS) -configuration within the container, see -@uref{https://refspecs.linuxfoundation.org/fhs.shtml, the official -specification}. As Guix deviates from the FHS specification, this +@itemx -F +When used with @option{--container}, emulate a +@uref{https://refspecs.linuxfoundation.org/fhs.shtml, Filesystem +Hierarchy Standard (FHS)} configuration within the container, providing +@file{/bin}, @file{/lib}, and other directories and files specified by +the FHS. + +As Guix deviates from the FHS specification, this option sets up the container to more closely mimic that of other GNU/Linux distributions. This is useful for reproducing other development environments, testing, and using programs which expect the FHS specification to be followed. With this option, the container will -include a version of @code{glibc} which will read -@code{/etc/ld.so.cache} within the container for the shared library -cache (contrary to @code{glibc} in regular Guix usage) and set up the -expected FHS directories: @code{/bin}, @code{/etc}, @code{/lib}, and -@code{/usr} from the container's profile. +include a version of glibc that will read +@file{/etc/ld.so.cache} within the container for the shared library +cache (contrary to glibc in regular Guix usage) and set up the +expected FHS directories: @file{/bin}, @file{/etc}, @file{/lib}, and +@file{/usr} from the container's profile. @item --rebuild-cache @cindex caching, of profiles diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm index b566057b41..2a9f2f34fc 100644 --- a/gnu/packages/base.scm +++ b/gnu/packages/base.scm @@ -933,15 +933,15 @@ (define (linker-script? file) ;; in FHS containers. (define-public glibc-for-fhs (hidden-package - (package - (inherit glibc) + (package/inherit glibc (name "glibc-for-fhs") (source (origin (inherit (package-source glibc)) ;; Remove Guix's patch to read ld.so.cache from /gnu/store ;; directories, re-enabling the default /etc/ld.so.cache ;; behavior. - (patches (delete (car (search-patches "glibc-dl-cache.patch")) - (origin-patches (package-source glibc))))))))) + (patches + (delete (search-patch "glibc-dl-cache.patch") + (origin-patches (package-source glibc))))))))) ;; Below are old libc versions, which we use mostly to build locale data in ;; the old format (which the new libc cannot cope with.) diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index f5b417457d..cf99760859 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -475,10 +475,10 @@ (define* (launch-environment command profile manifest (catch 'system-error (lambda () (when emulate-fhs? - ;; When running in a container with EMULATE-FHS?, supplement $PATH + ;; When running in a container with EMULATE-FHS?, override $PATH ;; (optional, but to better match FHS expectations), and generate ;; /etc/ld.so.cache. - (setenv "PATH" "/bin:/usr/bin:/sbin:/usr/sbin:$PATH") + (setenv "PATH" "/bin:/usr/bin:/sbin:/usr/sbin") (invoke "ldconfig" "-X")) (apply execlp program program args)) (lambda _ @@ -687,12 +687,15 @@ (define* (launch-environment/container #:key command bash user user-mappings list of file system mappings, contains the user-specified host file systems to mount inside the container. If USER is not #f, each target of USER-MAPPINGS will be re-written relative to '/home/USER', and USER will be used for the -passwd entry. When EMULATE-FHS?, set up the container to follow the -Filesystem Hierarchy Standard and provide a glibc that reads the cache from -/etc/ld.so.cache. SETUP-HOOK is an additional setup procedure to be called, as a -list with the function name and arguments, currently only used with the -EMULATE-FHS? option. LINK-PROFILE? creates a symbolic link from -~/.guix-profile to the environment profile. +passwd entry. + +When EMULATE-FHS?, set up the container to follow the Filesystem Hierarchy +Standard and provide a glibc that reads the cache from /etc/ld.so.cache. +SETUP-HOOK is an additional setup procedure to be called, currently only used +with the EMULATE-FHS? option. + +LINK-PROFILE? creates a symbolic link from ~/.guix-profile to the +environment profile. Preserve environment variables whose name matches the one of the regexps in WHILE-LIST." @@ -801,11 +804,9 @@ (define fhs-mappings (mkdir-p home-dir) (setenv "HOME" home-dir) - ;; Call an additional setup procedure, if provided. Currently - ;; this is only used with the EMULATE-FHS? option, but could be - ;; expanded to a general list of functions to be called. - (if setup-hook - (apply (car setup-hook) (cdr setup-hook))) + ;; Call an additional setup procedure, if provided. + (when setup-hook + (setup-hook profile)) ;; If requested, link $GUIX_ENVIRONMENT to $HOME/.guix-profile; ;; this allows programs expecting that path to continue working as @@ -1113,9 +1114,9 @@ (define manifest #:network? network? #:map-cwd? (not no-cwd?) #:emulate-fhs? emulate-fhs? - #:setup-hook (if emulate-fhs? - (list setup-fhs profile) - #f)))) + #:setup-hook + (and emulate-fhs? + setup-fhs)))) (else (return diff --git a/tests/guix-environment-container.sh b/tests/guix-environment-container.sh index 31e409420f..898c57f41b 100644 --- a/tests/guix-environment-container.sh +++ b/tests/guix-environment-container.sh @@ -230,4 +230,4 @@ guix environment -C --emulate-fhs --ad-hoc --bootstrap guile-bootstrap \ # Test that the ld cache was generated and can be successfully read. guix environment -C --emulate-fhs --ad-hoc --bootstrap guile-bootstrap \ - -- guile -c '(exit (execlp "ldconfig" "-p"))' + -- guile -c '(execlp "ldconfig" "ldconfig" "-p")' --=-=-=--