From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erhoJ-0001Jv-Lw for guix-patches@gnu.org; Fri, 02 Mar 2018 05:21:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1erhoE-00060J-9m for guix-patches@gnu.org; Fri, 02 Mar 2018 05:21:07 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:60453) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1erhoE-00060B-5B for guix-patches@gnu.org; Fri, 02 Mar 2018 05:21:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1erhoD-0000JQ-W7 for guix-patches@gnu.org; Fri, 02 Mar 2018 05:21:02 -0500 Subject: bug#30255: [PATCH 1/3] scripts: environment: Add --link-profile. Resent-To: guix-patches@gnu.org Resent-Message-ID: From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <87vag2wopo.fsf@gnu.org> Date: Fri, 02 Mar 2018 11:20:00 +0100 In-Reply-To: (Mike Gerwitz's message of "Thu, 25 Jan 2018 22:29:15 -0500") Message-ID: <87371iixtb.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Mike Gerwitz Cc: 30255-done@debbugs.gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Mike, Mike Gerwitz skribis: > This change is motivated by attempts to run programs (like GNU IceCat) wi= thin > containers. The 'fontconfig' program, for example, is configured explici= tly > to check ~/.guix-profile for additional fonts. > > There were no existing container tests in 'tests/guix-environment.sh', bu= t I > added one anyway for this change. > > * doc/guix.texi (Invoking guix environment): Add '--link-profile'. > * guix/scripts/environment.scm (show-help): Add '--link-profile'. > (%options): Add 'link-profile' as '#\P', assigned to 'link-profile?'. > (lnk-environment): New procedure. > (launch-environment/container): Use it when 'link-profile?'. > [link-profile?]: New parameter. > (guix-environment): Leave when '--link-prof' but not '--container'. Add > '#:link-profile?' argument to 'launch-environment/container' application. > * tests/guix-environment.sh: New '--link-profile' test. Sorry for forgetting about this patch series. It=E2=80=99s perfect, and very useful! I applied this one with the changes below. The main change is moving the test to guix-environment-container.sh, which is skipped when user namespaces are not supported. Thank you! Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index d86d30308..5c7d83881 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -513,7 +513,7 @@ symbolic link from ~/.guix-profile to the environment profile." (symlink profile profile-dir)) (lambda args (if (= EEXIST (system-error-errno args)) - (leave (G_ "cannot link profile: path '~a' already exists within container~%") + (leave (G_ "cannot link profile: '~a' already exists within container~%") profile-dir) (apply throw args)))))) @@ -625,7 +625,7 @@ message if any test fails." (when container? (assert-container-features)) (when (and (not container?) link-prof?) - (leave (G_ "--link-prof cannot be used without --container~%"))) + (leave (G_ "'--link-profile' cannot be used without '--container'~%"))) (with-store store (set-build-options-from-command-line store opts) diff --git a/tests/guix-environment-container.sh b/tests/guix-environment-container.sh index d7c1b7057..df40ce03e 100644 --- a/tests/guix-environment-container.sh +++ b/tests/guix-environment-container.sh @@ -97,6 +97,20 @@ grep -e "$NIX_STORE_DIR/.*-bash" $tmpdir/mounts # bootstrap bash rm $tmpdir/mounts +# Make sure 'GUIX_ENVIRONMENT' is linked to '~/.guix-profile' when requested +# within a container. +( + linktest='(exit (string=? (getenv "GUIX_ENVIRONMENT") +(readlink (string-append (getenv "HOME") "/.guix-profile"))))' + + cd "$tmpdir" \ + && guix environment --bootstrap --container --link-profile \ + --ad-hoc guile-bootstrap --pure \ + -- guile -c "$linktest" +) + +# Check the exit code. + abnormal_exit_code=" (use-modules (system foreign)) ;; Purposely make Guile crash with a segfault. :) diff --git a/tests/guix-environment.sh b/tests/guix-environment.sh index ba686816f..b44aca099 100644 --- a/tests/guix-environment.sh +++ b/tests/guix-environment.sh @@ -71,18 +71,6 @@ echo "(use-modules (guix profiles) (gnu packages bootstrap)) guix environment --bootstrap --manifest=$tmpdir/manifest.scm --pure \ -- "$SHELL" -c 'test -f "$GUIX_ENVIRONMENT/bin/guile"' -# Make sure 'GUIX_ENVIRONMENT' is linked to '~/.guix-profile' when requested -# within a container -( - linktest='(exit (string=? (getenv "GUIX_ENVIRONMENT") -(readlink (string-append (getenv "HOME") "/.guix-profile"))))' - - cd "$tmpdir" \ - && guix environment --bootstrap --container --link-profile \ - --ad-hoc guile-bootstrap --pure \ - -- guile -c "$linktest" -) - # Make sure '-r' works as expected. rm -f "$gcroot" expected="`guix environment --bootstrap --ad-hoc guile-bootstrap \ --=-=-=--