f535dcbe19
* guix/scripts/system.scm (specification->file-system-mapping): Move from here... * guix/ui.scm (specification->file-system-mapping): ... to here. * guix/scripts/enviroment.scm (show-help): Show help for new options. (%options): Add --container --network, --expose, and --share options. (%network-configuration-files): New variable. (launch-environment, launch-environment/container, requisites*, inputs->requisites): New procedures. (guix-environment): Spawn new process in a container when requested. * doc/guix.texi (Invoking guix environment): Document it. * tests/guix-environment-container.sh: New file. * Makefile.am (SH_TESTS): Add it.
76 lines
2.2 KiB
Bash
76 lines
2.2 KiB
Bash
# GNU Guix --- Functional package management for GNU
|
|
# Copyright © 2015 David Thompson <davet@gnu.org>
|
|
#
|
|
# This file is part of GNU Guix.
|
|
#
|
|
# GNU Guix is free software; you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or (at
|
|
# your option) any later version.
|
|
#
|
|
# GNU Guix is distributed in the hope that it will be useful, but
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
# Test 'guix environment'.
|
|
#
|
|
|
|
set -e
|
|
|
|
guix environment --version
|
|
|
|
tmpdir="t-guix-environment-$$"
|
|
trap 'rm -r "$tmpdir"' EXIT
|
|
|
|
mkdir "$tmpdir"
|
|
|
|
# Make sure the exit value is preserved.
|
|
if guix environment --container --ad-hoc --bootstrap guile-bootstrap \
|
|
-- guile -c '(exit 42)'
|
|
then
|
|
false
|
|
else
|
|
test $? = 42
|
|
fi
|
|
|
|
# Make sure that the right directories are mapped.
|
|
mount_test_code="
|
|
(use-modules (ice-9 rdelim)
|
|
(ice-9 match)
|
|
(srfi srfi-1))
|
|
|
|
(define mappings
|
|
(filter-map (lambda (line)
|
|
(match (string-split line #\space)
|
|
;; Empty line.
|
|
((\"\") #f)
|
|
;; Ignore these types of file systems.
|
|
((_ _ (or \"tmpfs\" \"proc\" \"sysfs\" \"devtmpfs\"
|
|
\"devpts\" \"cgroup\" \"mqueue\") _ _ _)
|
|
#f)
|
|
((_ mount _ _ _ _)
|
|
mount)))
|
|
(string-split (call-with-input-file \"/proc/mounts\" read-string)
|
|
#\newline)))
|
|
|
|
(for-each (lambda (mount)
|
|
(display mount)
|
|
(newline))
|
|
mappings)"
|
|
|
|
guix environment --container --ad-hoc --bootstrap guile-bootstrap \
|
|
-- guile -c "$mount_test_code" > $tmpdir/mounts
|
|
|
|
test `wc -l < $tmpdir/mounts` -eq 3
|
|
|
|
grep -e "$PWD$" $tmpdir/mounts # current directory
|
|
grep $(guix build guile-bootstrap) $tmpdir/mounts
|
|
grep -e "$NIX_STORE_DIR/.*-bash" $tmpdir/mounts # bootstrap bash
|
|
|
|
rm $tmpdir/mounts
|