2013-01-05 23:47:50 +00:00
|
|
|
# GNU Guix --- Functional package management for GNU
|
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 13:46:12 +00:00
|
|
|
# Copyright © 2012, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
|
2012-12-04 22:16:11 +00:00
|
|
|
#
|
2013-01-05 23:47:50 +00:00
|
|
|
# This file is part of GNU Guix.
|
2012-12-04 22:16:11 +00:00
|
|
|
#
|
2013-01-05 23:47:50 +00:00
|
|
|
# GNU Guix is free software; you can redistribute it and/or modify it
|
2012-12-04 22:16:11 +00: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-05 23:47:50 +00:00
|
|
|
# GNU Guix is distributed in the hope that it will be useful, but
|
2012-12-04 22:16:11 +00: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-05 23:47:50 +00:00
|
|
|
# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
2012-12-04 22:16:11 +00:00
|
|
|
|
|
|
|
#
|
2015-03-26 22:34:21 +00:00
|
|
|
# Test the daemon and its interaction with 'guix substitute'.
|
2012-12-04 22:16:11 +00: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 09:15:25 +00:00
|
|
|
guix build --version
|
2012-12-04 22:16:11 +00:00
|
|
|
|
2014-03-27 22:53:00 +00:00
|
|
|
drv="`guix build emacs -d`"
|
|
|
|
out="`guile -c ' \
|
|
|
|
(use-modules (guix) (gnu packages emacs)) \
|
|
|
|
(define store (open-connection)) \
|
|
|
|
(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 22:34:21 +00:00
|
|
|
rm -f "$XDG_CACHE_HOME/guix/substitute/$hash_part"
|
2014-03-27 22:53:00 +00: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 13:46:12 +00:00
|
|
|
guile -c "
|
2014-03-27 22:53:00 +00: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 13:46:12 +00:00
|
|
|
(set-build-options store #:use-substitutes? #t
|
|
|
|
#:substitute-urls (list \"$GUIX_BINARY_SUBSTITUTE_URL\"))
|
|
|
|
(exit (has-substitutes? store \"$out\"))"
|
2014-03-27 22:53:00 +00:00
|
|
|
|
|
|
|
# Now, run guix-daemon --no-substitutes.
|
|
|
|
socket="$NIX_STATE_DIR/alternate-socket"
|
|
|
|
guix-daemon --no-substitutes --listen="$socket" --disable-chroot &
|
|
|
|
daemon_pid=$!
|
|
|
|
trap "kill $daemon_pid" EXIT
|
|
|
|
|
|
|
|
# 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 13:46:12 +00:00
|
|
|
(set-build-options store #:use-substitutes? #t
|
|
|
|
#:substitute-urls (list \"$GUIX_BINARY_SUBSTITUTE_URL\"))
|
2014-03-27 22:53:00 +00:00
|
|
|
|
|
|
|
(exit (not (has-substitutes? store \"$out\")))"
|