From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 oNPlBS9h/WLCOwAAbAwnHQ (envelope-from ) for ; Wed, 17 Aug 2022 23:44:15 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id iCkIBS9h/WKBTAAAG6o9tA (envelope-from ) for ; Wed, 17 Aug 2022 23:44:15 +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 BAB50DB38 for ; Wed, 17 Aug 2022 23:44:14 +0200 (CEST) Received: from localhost ([::1]:58664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOQph-0008Cn-3n for larch@yhetil.org; Wed, 17 Aug 2022 17:44:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOQpW-0008Ce-62 for guix-patches@gnu.org; Wed, 17 Aug 2022 17:44:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35226) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oOQpV-0003rA-UD for guix-patches@gnu.org; Wed, 17 Aug 2022 17:44:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oOQpV-0006Zx-QH for guix-patches@gnu.org; Wed, 17 Aug 2022 17:44:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#56677] [PATCH 0/2] environment: Add --emulate-fhs option. Resent-From: John Kehayias Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 17 Aug 2022 21:44:01 +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: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 56677@debbugs.gnu.org Received: via spool by 56677-submit@debbugs.gnu.org id=B56677.166077260225237 (code B ref 56677); Wed, 17 Aug 2022 21:44:01 +0000 Received: (at 56677) by debbugs.gnu.org; 17 Aug 2022 21:43:22 +0000 Received: from localhost ([127.0.0.1]:53208 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oOQor-0006Yy-Os for submit@debbugs.gnu.org; Wed, 17 Aug 2022 17:43:22 -0400 Received: from mail-4316.protonmail.ch ([185.70.43.16]:62737) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oOQop-0006Yk-F6 for 56677@debbugs.gnu.org; Wed, 17 Aug 2022 17:43:20 -0400 Date: Wed, 17 Aug 2022 21:43:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1660772593; x=1661031793; bh=5UyTKApOZ1EK9X0PIKHh7Ypg03tEUrHdnj+ZoQjw578=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:In-Reply-To: References:Feedback-ID:From:To:Cc:Date:Subject:Reply-To: Feedback-ID:Message-ID; b=WMoKL23GMIb1Gg+/vHgPR6qa6kNfvwuPkqRvWBlhVpghRRWaEOkPfoobRdubVAkk3 ht5elQxNSju7fwEcsGmUzn6vAlrQ7iPRyVyxn6jXsm9X1rROmPK1lIvDbQLM+Hbg2T uVir1AOTzPd1wUQfFBvswy/xU07tMGGV5H8JobK6CpHSiWTLLWQ4bGsVFsegest1DM fRBIN3u42qj3kVkUxG3vVsopH7kc6tajQXS8WHL5Uk767vWBUT/FklP0/CcR1Q7EjY 10jAZDNSZXLwT2V8DY+pZCCrEWa/BhL9u5oGi3eMH2BjdfJmc0fyi6fBJXq9DNF/M+ WXdJQxtgIZZzg== Message-ID: In-Reply-To: <87r11wmh2h.fsf@gnu.org> References: <1LCXD7_zuGflSFovh_mKvhdayNcoWp8ALeguq3i2-XWwWHgzZuPak2gSBN91VLNJ84lubuFAt1dPB282Zy0pBmh_zbiI2qI-7n0LP9F03u4=@protonmail.com> <87r11wmh2h.fsf@gnu.org> Feedback-ID: 7805494:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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" Reply-to: John Kehayias X-ACL-Warn: , John Kehayias via Guix-patches From: John Kehayias via Guix-patches via X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1660772654; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: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=5UyTKApOZ1EK9X0PIKHh7Ypg03tEUrHdnj+ZoQjw578=; b=TfTMzzcdgHQpxsmLZAnKY2uaymwVAisYEE5xFvYAXJG3KpHRmbUfMsznRr/MRvleQpRuck siwSvHyX8ehDUuwhb3HHRJ+jQ50S3uI5pXmC68mxQ/ZzE2T51R1uzMf8J/pMKxRYLqDyS+ tQ4p+0juWrmHKb8dmXzIFKIucSzEJe9xAGOB/4mjd/pS7RYGHplgYGljXO3RyICw3M9dRb tbk88P3KBQ8hc7zZGPKGe8a93WEjqIHSVwZ3VURU7+Dx3uVB+wfKSoMvZDlhj6wYMaMs6A 0cROgQngCP6qngdExqRSxkzqTTpd4CgamUSQu4XC0m1/Hu593tN+gbTuQPaFKw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1660772654; a=rsa-sha256; cv=none; b=js2p3faglPb//rW9Xh/fEsARDyaEJ1ZyQBGkMER/Y/uIysC65b9SySfdRwEGfFQ2hlDHsh Yj6MhuXaXCclE8C/Qvms3DV5dlW/NT0RHFE831vkV7TwhP5+h1p2qq+hsnKcTwa89YBEA8 nJgYxvTAf9zm2qa6NGKxb0n+EmGYE/MjwmiPIWiVRwW7iTG9T/jQSj58z1PQlIrTvBJvLy QL188+hCwGuIjRm7je0w1TLC350lEKCLyZwLTRK+awWcEovsAhZTDmBWqEDOfB8DM/Msor lPt2tGkNVseeKgE1bee9IBgKxzGNY3bCx6pNbyzZ7fQ+nsTL1SvqwAf5uJIRUA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=protonmail.com header.s=protonmail3 header.b=WMoKL23G; 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: -2.16 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=protonmail.com header.s=protonmail3 header.b=WMoKL23G; 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: BAB50DB38 X-Spam-Score: -2.16 X-Migadu-Scanner: scn0.migadu.com X-TUID: iAHzVFHuYi9m Hello, Took me a while to respond as well, summer meaning more time to hack on thi= ngs and then also let them get away... ------- Original Message ------- On Thursday, August 4th, 2022 at 6:36 AM, Ludovic Court=C3=A8s wrote: >=20 > Hello, >=20 > John Kehayias john.kehayias@protonmail.com skribis: >=20 > > As discussed on guix-devel here (please see for more detailed discussio= n and design aims): https://lists.gnu.org/r/guix-devel/2022-07/msg00161.htm= l this is a patch to add an FHS (Filesystem Hierarchy Standard) emulation o= ption for environments. >=20 > Wo0t! >=20 > > 1. On the mailing list there was discussion about the necessity or not = of glibc-for-fhs (added in the first patch). I find this useful and a big p= iece of making this FHS option work, but open to discussion or if it should= be a further option. >=20 > I would prefer to keep complexity as low as possible, and thus not have > this glibc variant. >=20 > Now, I don=E2=80=99t know for this use case how much it matters that libc= honors > /etc/ld.so.cache. Intuitively, like I wrote on guix-devel, I=E2=80=99d th= ink > ld.so.cache doesn=E2=80=99t matter, but you encountered counterexamples. >=20 > So I guess that if in practice presence of /etc/ld.so.cache and having > glibc honor it is necessary often enough, we can do that. >=20 Right, though as I said, happy to hear of alternatives or what other use ca= ses come up. This seems rather robust to any "usual" assumptions though. > It seems that =E2=80=98glibc-for-fhs=E2=80=99 is merely added to the envi= ronment though, > and not actually used? >=20 Well, it is added to the environment which here means the glibc-for-fhs lib= directory ends up in the container's global /lib. This may be useful for a= nything expecting a more "typical" glibc to be found in the typical locatio= n. I can't say I know the particulars here, other than binaries and an exam= ple of other nested containers (used in non-free software, but the containe= rs are bwrap and friends) expecting glibc to default to a global ld cache. = Again, there may be other workarounds or ways to reduce this, but for now I= followed the "emulate" part of the flag :) > + ;; For an FHS-container, add the > + ;; (hidden) package glibc-for-fhs which > + ;; uses the global cache at > + ;; /etc/ld.so.cache. > + (if emulate-fhs? > + (alist-cons 'expression > + '(ad-hoc-package > + "(@@ (gnu packages base) glibc-for-fhs)") > + opts) > + opts))) >=20 > Or rather it=E2=80=99s only used when running =E2=80=98ldconfig=E2=80= =99, right? >=20 Yes, since that is the glibc in the container. Though actually generating a= cache shouldn't matter, right? Guix's glibc will do that as well, as the o= nly patch removed is the one that changed where glibc reads the ld cache fr= om. So the cache could be generated with Guix's glibc, but then likely won'= t be read otherwise? Sorry, a bit out of what I know for all the details; I= 'm mostly at "this is what is often expected" and "this makes it work." > > 2. Right now I used a script written to the containers /tmp/fhs.sh to g= enerate the ld cache, supplement $PATH (somewhat optional, but I found usef= ul for less tinkering), and finally launch the given command or shell. I fo= und that when not providing a command the prompt for /bin/sh is not the sam= e as when not using --emulate-fhs. So I'm not sure if this is the correct w= ay to launch the default /bin/sh if no command is given. Open to ideas of a= better way to implement these actions for a container start up as well. > >=20 > > 3. This is my first time touching a guix script and the documentation, = so please do check the commit message and guix.texi. > >=20 > > 4. I decided to link the second level FHS directories, like /usr/bin, a= s well as optional ones like /lib64 (or /lib32), to the top level /bin, /li= b, and so on. These could just be bind mounted to profile/bin and so on as = well, but again tried to mimic an FHS distribution like Arch where the file= s only live in one place. While perhaps making the code a little more invol= ved, I hope this makes the container look tidier. > >=20 > > I may be forgetting other elements in the implementation decisions I ma= de, but I have been testing these patches along the way and have gotten goo= d usage of them. Please test further too! >=20 > At first sight, I find it pretty cool! I would have two grievances: >=20 Thanks! It is serving me in some day-to-day work nicely. > 1. Can we make the implementation more orthogonal and less entangled > in the already-long =E2=80=98launch-environment/container=E2=80=99? >=20 > Maybe that can be accomplished by moving all the code conditional > on =E2=80=98emulate-fhs?=E2=80=99 out of the way in a separate procedure,= and > possibly by adding a generic hook in =E2=80=98launch-environment/containe= r=E2=80=99 > that would call said procedure. >=20 Sure, this sounds like a good idea. I can certainly separate out the FHS se= tup to a separate function and call it. But I'm not sure what you mean by a= "generic hook" here. Do you mean that launch-environment/container would h= ave as an argument say a list of functions it would call? > 2. Please add tests. You can probably augment > =E2=80=98tests/guix-environment-container.sh=E2=80=99 for that. Let us kn= ow if > you=E2=80=99re not sure how to do that. >=20 Thanks, definitely forgot about that. In looking at that, I've just ran it = with "./pre-inst-env sh tests/guix-environment-container.sh" and see that t= he exit code is 0. Is that the correct way to run these? Secondly, I'm trying to think of what tests to add. I could of course run t= he same tests already, but with the --emulate-fhs option, to check that the= re are no regressions. Other than that, maybe checking that e.g. there's /e= tc/ld.so.cache, /lib, and so on? > Thanks for all the work, and sorry for the delay: it seems to be summer > time for many of us. :-) >=20 > Ludo=E2=80=99. No worries, summer is a good time to get away, or dig in :) John