2013-01-06 00:47:50 +01:00
|
|
|
# GNU Guix --- Functional package management for GNU
|
store: Rename '&nix-error' to '&store-error'.
* guix/store.scm (&nix-error): Rename to...
(&store-error): ... this, and adjust users.
(&nix-connection-error): Rename to...
(&store-connection-error): ... this, and adjust users.
(&nix-protocol-error): Rename to...
(&store-protocol-error): ... this, adjust users.
(&nix-error, &nix-connection-error, &nix-protocol-error): Define these
condition types and their getters as deprecrated aliases.
* build-aux/run-system-tests.scm, guix/derivations.scm,
guix/grafts.scm, guix/scripts/challenge.scm,
guix/scripts/graph.scm, guix/scripts/lint.scm,
guix/scripts/offload.scm, guix/serialization.scm,
guix/ssh.scm, guix/tests.scm, guix/ui.scm,
tests/derivations.scm, tests/gexp.scm, tests/guix-daemon.sh,
tests/packages.scm, tests/store.scm, doc/guix.texi: Adjust to use the
new names.
2019-01-21 17:41:11 +01:00
|
|
|
# Copyright © 2012, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
|
2012-12-04 23:16:11 +01:00
|
|
|
#
|
2013-01-06 00:47:50 +01:00
|
|
|
# This file is part of GNU Guix.
|
2012-12-04 23:16:11 +01:00
|
|
|
#
|
2013-01-06 00:47:50 +01:00
|
|
|
# GNU Guix is free software; you can redistribute it and/or modify it
|
2012-12-04 23:16:11 +01:00
|
|
|
# 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.
|
|
|
|
#
|
2013-01-06 00:47:50 +01:00
|
|
|
# GNU Guix is distributed in the hope that it will be useful, but
|
2012-12-04 23:16:11 +01:00
|
|
|
# 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
|
2013-01-06 00:47:50 +01:00
|
|
|
# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
2012-12-04 23:16:11 +01:00
|
|
|
|
|
|
|
#
|
2015-03-26 23:34:21 +01:00
|
|
|
# Test the daemon and its interaction with 'guix substitute'.
|
2012-12-04 23:16:11 +01:00
|
|
|
#
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
guix-daemon --version
|
Replace individual scripts with master 'guix' script.
* scripts/guix.in: New script.
* Makefile.am (bin_SCRIPTS): Add 'scripts/guix'. Remove 'guix-build',
'guix-download', 'guix-import', 'guix-package', and 'guix-gc'.
(MODULES): Add 'guix/scripts/build.scm', 'guix/scripts/download.scm',
'guix/scripts/import.scm', 'guix/scripts/package.scm', and
'guix/scripts/gc.scm'.
* configure.ac (AC_CONFIG_FILES): Add 'scripts/guix'. Remove 'guix-build',
'guix-download', 'guix-import', 'guix-package', and 'guix-gc'.
* guix-build.in, guix-download.in, guix-gc.in, guix-import.in,
guix-package.in: Remove shell script boilerplate. Move to guix-COMMAND.in
to guix/scripts/COMMAND.scm. Rename module from (guix-COMMAND) to
(guix scripts COMMAND). Change "guix-COMMAND" to "guix COMMAND" in
usage help string.
* pre-inst-env.in: Add "@abs_top_builddir@/scripts" to the front of $PATH.
Export $GUIX_UNINSTALLED.
* tests/guix-build.sh, tests/guix-daemon.sh, tests/guix-download.sh,
tests/guix-gc.sh, tests/guix-package.sh: Use "guix COMMAND" instead of
"guix-COMMAND".
* doc/guix.texi: Replace all occurrences of "guix-COMMAND" with
"guix COMMAND".
* po/POTFILES.in: Update.
2013-02-14 10:15:25 +01:00
|
|
|
guix build --version
|
2012-12-04 23:16:11 +01:00
|
|
|
|
2014-03-27 23:53:00 +01:00
|
|
|
drv="`guix build emacs -d`"
|
|
|
|
out="`guile -c ' \
|
2016-03-02 14:44:18 +01:00
|
|
|
(use-modules (guix) (guix grafts) (gnu packages emacs)) \
|
2014-03-27 23:53:00 +01:00
|
|
|
(define store (open-connection)) \
|
2016-03-02 14:44:18 +01:00
|
|
|
(%graft? #f)
|
2014-03-27 23:53:00 +01:00
|
|
|
(display (derivation->output-path (package-derivation store emacs)))'`"
|
|
|
|
|
|
|
|
hash_part="`basename $out | cut -c 1-32`"
|
|
|
|
narinfo="$hash_part.narinfo"
|
|
|
|
substitute_dir="`echo $GUIX_BINARY_SUBSTITUTE_URL | sed -'es,file://,,g'`"
|
|
|
|
|
|
|
|
cat > "$substitute_dir/nix-cache-info"<<EOF
|
|
|
|
StoreDir: `dirname $drv`
|
|
|
|
WantMassQuery: 0
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat > "$substitute_dir/$narinfo"<<EOF
|
|
|
|
StorePath: $out
|
|
|
|
URL: /nowhere/example.nar
|
|
|
|
Compression: none
|
|
|
|
NarSize: 1234
|
|
|
|
References:
|
|
|
|
System: `guile -c '(use-modules (guix)) (display (%current-system))'`
|
|
|
|
Deriver: $drv
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Remove the cached narinfo.
|
2015-03-26 23:34:21 +01:00
|
|
|
rm -f "$XDG_CACHE_HOME/guix/substitute/$hash_part"
|
2014-03-27 23:53:00 +01:00
|
|
|
|
|
|
|
# Make sure we see the substitute.
|
substitute: Honor "substitute-urls" option passed by "untrusted" clients.
* guix/scripts/substitute.scm (or*): New macro.
(%cache-url): Honor "untrusted-substitute-urls".
* guix/tests.scm (%test-substitute-urls): New variable.
(open-connection-for-tests): Use it.
* tests/derivations.scm ("derivation-prerequisites-to-build and substitutes",
"derivation-prerequisites-to-build and substitutes, non-substitutable
build", "derivation-prerequisites-to-build and substitutes, local build"):
Pass it to 'set-build-options'.
* tests/guix-daemon.sh: Likewise.
* tests/store.scm ("substitute query, alternating URLs"): New test.
("substitute query", "substitute", "substitute + build-things with output
path", "substitute, corrupt output hash", "substitute --fallback"): Pass
#:substitute-urls to 'set-build-options'.
2015-07-13 15:46:12 +02:00
|
|
|
guile -c "
|
2014-03-27 23:53:00 +01:00
|
|
|
(use-modules (guix))
|
|
|
|
(define store (open-connection))
|
substitute: Honor "substitute-urls" option passed by "untrusted" clients.
* guix/scripts/substitute.scm (or*): New macro.
(%cache-url): Honor "untrusted-substitute-urls".
* guix/tests.scm (%test-substitute-urls): New variable.
(open-connection-for-tests): Use it.
* tests/derivations.scm ("derivation-prerequisites-to-build and substitutes",
"derivation-prerequisites-to-build and substitutes, non-substitutable
build", "derivation-prerequisites-to-build and substitutes, local build"):
Pass it to 'set-build-options'.
* tests/guix-daemon.sh: Likewise.
* tests/store.scm ("substitute query, alternating URLs"): New test.
("substitute query", "substitute", "substitute + build-things with output
path", "substitute, corrupt output hash", "substitute --fallback"): Pass
#:substitute-urls to 'set-build-options'.
2015-07-13 15:46:12 +02:00
|
|
|
(set-build-options store #:use-substitutes? #t
|
|
|
|
#:substitute-urls (list \"$GUIX_BINARY_SUBSTITUTE_URL\"))
|
|
|
|
(exit (has-substitutes? store \"$out\"))"
|
2014-03-27 23:53:00 +01:00
|
|
|
|
|
|
|
# Now, run guix-daemon --no-substitutes.
|
2019-02-03 22:10:06 +01:00
|
|
|
socket="$GUIX_STATE_DIRECTORY/alternate-socket"
|
2014-03-27 23:53:00 +01:00
|
|
|
guix-daemon --no-substitutes --listen="$socket" --disable-chroot &
|
|
|
|
daemon_pid=$!
|
2015-09-28 21:32:17 +02:00
|
|
|
trap 'kill $daemon_pid' EXIT
|
2014-03-27 23:53:00 +01:00
|
|
|
|
|
|
|
# Make sure we DON'T see the substitute.
|
|
|
|
guile -c "
|
|
|
|
(use-modules (guix))
|
|
|
|
(define store (open-connection \"$socket\"))
|
|
|
|
|
|
|
|
;; This setting MUST NOT override the daemon's --no-substitutes.
|
substitute: Honor "substitute-urls" option passed by "untrusted" clients.
* guix/scripts/substitute.scm (or*): New macro.
(%cache-url): Honor "untrusted-substitute-urls".
* guix/tests.scm (%test-substitute-urls): New variable.
(open-connection-for-tests): Use it.
* tests/derivations.scm ("derivation-prerequisites-to-build and substitutes",
"derivation-prerequisites-to-build and substitutes, non-substitutable
build", "derivation-prerequisites-to-build and substitutes, local build"):
Pass it to 'set-build-options'.
* tests/guix-daemon.sh: Likewise.
* tests/store.scm ("substitute query, alternating URLs"): New test.
("substitute query", "substitute", "substitute + build-things with output
path", "substitute, corrupt output hash", "substitute --fallback"): Pass
#:substitute-urls to 'set-build-options'.
2015-07-13 15:46:12 +02:00
|
|
|
(set-build-options store #:use-substitutes? #t
|
|
|
|
#:substitute-urls (list \"$GUIX_BINARY_SUBSTITUTE_URL\"))
|
2014-03-27 23:53:00 +01:00
|
|
|
|
|
|
|
(exit (not (has-substitutes? store \"$out\")))"
|
2015-09-28 21:32:17 +02:00
|
|
|
|
|
|
|
kill "$daemon_pid"
|
|
|
|
|
2017-06-19 17:39:24 +02:00
|
|
|
# Pass several '--listen' options, and make sure they are all honored.
|
|
|
|
guix-daemon --disable-chroot --listen="$socket" --listen="$socket-second" \
|
|
|
|
--listen="localhost" --listen="localhost:9876" &
|
|
|
|
daemon_pid=$!
|
|
|
|
|
|
|
|
for uri in "$socket" "$socket-second" \
|
|
|
|
"guix://localhost" "guix://localhost:9876"
|
|
|
|
do
|
|
|
|
GUIX_DAEMON_SOCKET="$uri" guix build guile-bootstrap
|
|
|
|
done
|
|
|
|
|
|
|
|
kill "$daemon_pid"
|
2015-09-28 21:32:17 +02:00
|
|
|
|
|
|
|
# Check the failed build cache.
|
|
|
|
|
|
|
|
guix-daemon --no-substitutes --listen="$socket" --disable-chroot \
|
|
|
|
--cache-failures &
|
|
|
|
daemon_pid=$!
|
|
|
|
|
|
|
|
guile -c "
|
2016-03-02 14:44:18 +01:00
|
|
|
(use-modules (guix) (guix grafts) (guix tests) (srfi srfi-34))
|
2015-09-28 21:32:17 +02:00
|
|
|
(define store (open-connection-for-tests \"$socket\"))
|
|
|
|
|
2016-03-02 14:44:18 +01:00
|
|
|
;; Disable grafts to avoid building more than needed.
|
|
|
|
(%graft? #f)
|
|
|
|
|
2015-09-28 21:32:17 +02:00
|
|
|
(define (build-without-failing drv)
|
|
|
|
(lambda (store)
|
store: Rename '&nix-error' to '&store-error'.
* guix/store.scm (&nix-error): Rename to...
(&store-error): ... this, and adjust users.
(&nix-connection-error): Rename to...
(&store-connection-error): ... this, and adjust users.
(&nix-protocol-error): Rename to...
(&store-protocol-error): ... this, adjust users.
(&nix-error, &nix-connection-error, &nix-protocol-error): Define these
condition types and their getters as deprecrated aliases.
* build-aux/run-system-tests.scm, guix/derivations.scm,
guix/grafts.scm, guix/scripts/challenge.scm,
guix/scripts/graph.scm, guix/scripts/lint.scm,
guix/scripts/offload.scm, guix/serialization.scm,
guix/ssh.scm, guix/tests.scm, guix/ui.scm,
tests/derivations.scm, tests/gexp.scm, tests/guix-daemon.sh,
tests/packages.scm, tests/store.scm, doc/guix.texi: Adjust to use the
new names.
2019-01-21 17:41:11 +01:00
|
|
|
(guard (c ((store-protocol-error? c) (values #t store)))
|
2015-09-28 21:32:17 +02:00
|
|
|
(build-derivations store (list drv))
|
|
|
|
(values #f store))))
|
|
|
|
|
|
|
|
;; Make sure failed builds are cached and can be removed from
|
|
|
|
;; the cache.
|
|
|
|
(run-with-store store
|
|
|
|
(mlet* %store-monad ((drv (gexp->derivation \"failure\"
|
|
|
|
#~(begin
|
|
|
|
(ungexp output)
|
|
|
|
#f)))
|
|
|
|
(out -> (derivation->output-path drv))
|
|
|
|
(ok? (build-without-failing drv)))
|
|
|
|
;; Note the mixture of monadic and direct style. Don't try
|
|
|
|
;; this at home!
|
|
|
|
(return (exit (and ok?
|
|
|
|
(equal? (query-failed-paths store) (list out))
|
|
|
|
(begin
|
|
|
|
(clear-failed-paths store (list out))
|
|
|
|
(null? (query-failed-paths store)))))))
|
|
|
|
#:guile-for-build (%guile-for-build)) "
|
2017-01-15 15:13:07 +01:00
|
|
|
|
|
|
|
kill "$daemon_pid"
|
|
|
|
|
|
|
|
|
|
|
|
# Make sure the daemon's default 'build-cores' setting is honored.
|
|
|
|
|
|
|
|
guix-daemon --listen="$socket" --disable-chroot --cores=42 &
|
|
|
|
daemon_pid=$!
|
|
|
|
|
|
|
|
GUIX_DAEMON_SOCKET="$socket" \
|
|
|
|
guile -c '
|
|
|
|
(use-modules (guix) (gnu packages) (guix tests))
|
|
|
|
|
|
|
|
(with-store store
|
|
|
|
(let* ((build (add-text-to-store store "build.sh"
|
|
|
|
"echo $NIX_BUILD_CORES > $out"))
|
|
|
|
(bash (add-to-store store "bash" #t "sha256"
|
|
|
|
(search-bootstrap-binary "bash"
|
|
|
|
(%current-system))))
|
|
|
|
(drv (derivation store "the-thing" bash
|
|
|
|
`("-e" ,build)
|
|
|
|
#:inputs `((,bash) (,build))
|
|
|
|
#:env-vars `(("x" . ,(random-text))))))
|
|
|
|
(and (build-derivations store (list drv))
|
|
|
|
(exit
|
|
|
|
(= 42 (pk (call-with-input-file (derivation->output-path drv)
|
|
|
|
read)))))))'
|
2017-06-03 23:55:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
kill "$daemon_pid"
|
|
|
|
|
|
|
|
# Make sure the daemon's default 'timeout' and 'max-silent-time' settings are
|
|
|
|
# honored.
|
|
|
|
|
|
|
|
client_code='
|
|
|
|
(use-modules (guix) (gnu packages) (guix tests) (srfi srfi-34))
|
|
|
|
|
|
|
|
(with-store store
|
|
|
|
(let* ((build (add-text-to-store store "build.sh"
|
|
|
|
"while true ; do : ; done"))
|
|
|
|
(bash (add-to-store store "bash" #t "sha256"
|
|
|
|
(search-bootstrap-binary "bash"
|
|
|
|
(%current-system))))
|
|
|
|
(drv (derivation store "the-thing" bash
|
|
|
|
`("-e" ,build)
|
|
|
|
#:inputs `((,bash) (,build))
|
|
|
|
#:env-vars `(("x" . ,(random-text))))))
|
store: Rename '&nix-error' to '&store-error'.
* guix/store.scm (&nix-error): Rename to...
(&store-error): ... this, and adjust users.
(&nix-connection-error): Rename to...
(&store-connection-error): ... this, and adjust users.
(&nix-protocol-error): Rename to...
(&store-protocol-error): ... this, adjust users.
(&nix-error, &nix-connection-error, &nix-protocol-error): Define these
condition types and their getters as deprecrated aliases.
* build-aux/run-system-tests.scm, guix/derivations.scm,
guix/grafts.scm, guix/scripts/challenge.scm,
guix/scripts/graph.scm, guix/scripts/lint.scm,
guix/scripts/offload.scm, guix/serialization.scm,
guix/ssh.scm, guix/tests.scm, guix/ui.scm,
tests/derivations.scm, tests/gexp.scm, tests/guix-daemon.sh,
tests/packages.scm, tests/store.scm, doc/guix.texi: Adjust to use the
new names.
2019-01-21 17:41:11 +01:00
|
|
|
(exit (guard (c ((store-protocol-error? c)
|
2017-06-03 23:55:31 +02:00
|
|
|
(->bool
|
store: Rename '&nix-error' to '&store-error'.
* guix/store.scm (&nix-error): Rename to...
(&store-error): ... this, and adjust users.
(&nix-connection-error): Rename to...
(&store-connection-error): ... this, and adjust users.
(&nix-protocol-error): Rename to...
(&store-protocol-error): ... this, adjust users.
(&nix-error, &nix-connection-error, &nix-protocol-error): Define these
condition types and their getters as deprecrated aliases.
* build-aux/run-system-tests.scm, guix/derivations.scm,
guix/grafts.scm, guix/scripts/challenge.scm,
guix/scripts/graph.scm, guix/scripts/lint.scm,
guix/scripts/offload.scm, guix/serialization.scm,
guix/ssh.scm, guix/tests.scm, guix/ui.scm,
tests/derivations.scm, tests/gexp.scm, tests/guix-daemon.sh,
tests/packages.scm, tests/store.scm, doc/guix.texi: Adjust to use the
new names.
2019-01-21 17:41:11 +01:00
|
|
|
(string-contains (pk (store-protocol-error-message c))
|
2017-06-03 23:55:31 +02:00
|
|
|
"failed"))))
|
|
|
|
(build-derivations store (list drv))
|
|
|
|
#f))))'
|
|
|
|
|
|
|
|
|
|
|
|
for option in --max-silent-time=1 --timeout=1
|
|
|
|
do
|
|
|
|
guix-daemon --listen="$socket" --disable-chroot "$option" &
|
|
|
|
daemon_pid=$!
|
|
|
|
|
|
|
|
GUIX_DAEMON_SOCKET="$socket" guile -c "$client_code"
|
|
|
|
kill "$daemon_pid"
|
|
|
|
done
|
2018-01-05 17:15:41 +01:00
|
|
|
|
2018-04-19 17:11:30 +02:00
|
|
|
# Make sure garbage collection from a TCP connection does not work.
|
|
|
|
|
2019-06-27 11:05:52 +02:00
|
|
|
tcp_socket="127.0.0.1:9998"
|
2018-04-19 17:11:30 +02:00
|
|
|
guix-daemon --listen="$tcp_socket" &
|
|
|
|
daemon_pid=$!
|
|
|
|
|
|
|
|
GUIX_DAEMON_SOCKET="guix://$tcp_socket"
|
|
|
|
export GUIX_DAEMON_SOCKET
|
|
|
|
|
|
|
|
if guix gc; then false; else true; fi
|
|
|
|
|
|
|
|
unset GUIX_DAEMON_SOCKET
|
|
|
|
kill "$daemon_pid"
|
|
|
|
|
2018-01-05 17:15:41 +01:00
|
|
|
# Log compression.
|
|
|
|
|
|
|
|
guix-daemon --listen="$socket" --disable-chroot --debug --log-compression=gzip &
|
|
|
|
daemon_pid=$!
|
|
|
|
|
|
|
|
stamp="compressed-build-log-test-$$-`date +%H%M%S`"
|
|
|
|
client_code="
|
|
|
|
(use-modules (guix) (gnu packages bootstrap))
|
|
|
|
|
|
|
|
(with-store store
|
|
|
|
(run-with-store store
|
|
|
|
(mlet %store-monad ((drv (lower-object
|
|
|
|
(computed-file \"compressed-log-test\"
|
|
|
|
#~(begin
|
|
|
|
(display \"$stamp\")
|
|
|
|
(newline)
|
|
|
|
(mkdir #\$output))
|
|
|
|
#:guile %bootstrap-guile))))
|
|
|
|
(display (derivation-file-name drv))
|
|
|
|
(newline)
|
|
|
|
(return #t))))
|
|
|
|
"
|
|
|
|
|
|
|
|
GUIX_DAEMON_SOCKET="$socket"
|
|
|
|
export GUIX_DAEMON_SOCKET
|
|
|
|
|
|
|
|
drv=`guile -c "$client_code"`
|
|
|
|
guix build "$drv"
|
|
|
|
|
|
|
|
log=`guix build "$drv" --log-file`
|
|
|
|
test -f "$log"
|
|
|
|
case "$log" in
|
|
|
|
*.gz) test "`gunzip -c < "$log"`" = "$stamp" ;;
|
|
|
|
*) false ;;
|
|
|
|
esac
|