Mirror of GNU Guix
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

447 lines
18 KiB

derivations: 'derivation' and related procedures return a single value. * guix/derivations.scm (derivation->output-path, derivation->output-paths): New procedures. (derivation-path->output-path): Use 'derivation->output-path'. (derivation-path->output-paths): Use 'derivation->output-paths'. (derivation): Accept 'derivation?' objects as inputs. Return a single value. (build-derivations): New procedure. (compiled-modules): Use 'derivation->output-paths'. (build-expression->derivation)[source-path]: Add case for when the input matches 'derivation?'. [prologue]: Accept 'derivation?' objects in INPUTS. [mod-dir, go-dir]: Use 'derivation->output-path'. * guix/download.scm (url-fetch): Adjust to the single-value return. * guix/packages.scm (package-output): Use 'derivation->output-path'. * guix/scripts/build.scm (guix-build): When the argument is 'derivation-path?', pass it through 'read-derivation'. Use 'derivation-file-name' to print out the .drv file names, and to register them. Use 'derivation->output-path' instead of 'derivation-path->output-path'. * guix/scripts/package.scm (roll-back): Adjust to the single-value return. (guix-package): Use 'derivation->output-path'. * guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?' objects instead of .drv file names. * gnu/system/grub.scm (grub-configuration-file): Use 'derivation->output-path' instead of 'derivation-path->output-path'. * gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise. * tests/builders.scm, tests/derivations.scm, tests/packages.scm, tests/store.scm, tests/union.scm: Adjust to the new calling convention. * doc/guix.texi (Defining Packages, The Store, Derivations): Adjust accordingly.
8 years ago
derivations: 'derivation' and related procedures return a single value. * guix/derivations.scm (derivation->output-path, derivation->output-paths): New procedures. (derivation-path->output-path): Use 'derivation->output-path'. (derivation-path->output-paths): Use 'derivation->output-paths'. (derivation): Accept 'derivation?' objects as inputs. Return a single value. (build-derivations): New procedure. (compiled-modules): Use 'derivation->output-paths'. (build-expression->derivation)[source-path]: Add case for when the input matches 'derivation?'. [prologue]: Accept 'derivation?' objects in INPUTS. [mod-dir, go-dir]: Use 'derivation->output-path'. * guix/download.scm (url-fetch): Adjust to the single-value return. * guix/packages.scm (package-output): Use 'derivation->output-path'. * guix/scripts/build.scm (guix-build): When the argument is 'derivation-path?', pass it through 'read-derivation'. Use 'derivation-file-name' to print out the .drv file names, and to register them. Use 'derivation->output-path' instead of 'derivation-path->output-path'. * guix/scripts/package.scm (roll-back): Adjust to the single-value return. (guix-package): Use 'derivation->output-path'. * guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?' objects instead of .drv file names. * gnu/system/grub.scm (grub-configuration-file): Use 'derivation->output-path' instead of 'derivation-path->output-path'. * gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise. * tests/builders.scm, tests/derivations.scm, tests/packages.scm, tests/store.scm, tests/union.scm: Adjust to the new calling convention. * doc/guix.texi (Defining Packages, The Store, Derivations): Adjust accordingly.
8 years ago
derivations: 'derivation' and related procedures return a single value. * guix/derivations.scm (derivation->output-path, derivation->output-paths): New procedures. (derivation-path->output-path): Use 'derivation->output-path'. (derivation-path->output-paths): Use 'derivation->output-paths'. (derivation): Accept 'derivation?' objects as inputs. Return a single value. (build-derivations): New procedure. (compiled-modules): Use 'derivation->output-paths'. (build-expression->derivation)[source-path]: Add case for when the input matches 'derivation?'. [prologue]: Accept 'derivation?' objects in INPUTS. [mod-dir, go-dir]: Use 'derivation->output-path'. * guix/download.scm (url-fetch): Adjust to the single-value return. * guix/packages.scm (package-output): Use 'derivation->output-path'. * guix/scripts/build.scm (guix-build): When the argument is 'derivation-path?', pass it through 'read-derivation'. Use 'derivation-file-name' to print out the .drv file names, and to register them. Use 'derivation->output-path' instead of 'derivation-path->output-path'. * guix/scripts/package.scm (roll-back): Adjust to the single-value return. (guix-package): Use 'derivation->output-path'. * guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?' objects instead of .drv file names. * gnu/system/grub.scm (grub-configuration-file): Use 'derivation->output-path' instead of 'derivation-path->output-path'. * gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise. * tests/builders.scm, tests/derivations.scm, tests/packages.scm, tests/store.scm, tests/union.scm: Adjust to the new calling convention. * doc/guix.texi (Defining Packages, The Store, Derivations): Adjust accordingly.
8 years ago
derivations: 'derivation' and related procedures return a single value. * guix/derivations.scm (derivation->output-path, derivation->output-paths): New procedures. (derivation-path->output-path): Use 'derivation->output-path'. (derivation-path->output-paths): Use 'derivation->output-paths'. (derivation): Accept 'derivation?' objects as inputs. Return a single value. (build-derivations): New procedure. (compiled-modules): Use 'derivation->output-paths'. (build-expression->derivation)[source-path]: Add case for when the input matches 'derivation?'. [prologue]: Accept 'derivation?' objects in INPUTS. [mod-dir, go-dir]: Use 'derivation->output-path'. * guix/download.scm (url-fetch): Adjust to the single-value return. * guix/packages.scm (package-output): Use 'derivation->output-path'. * guix/scripts/build.scm (guix-build): When the argument is 'derivation-path?', pass it through 'read-derivation'. Use 'derivation-file-name' to print out the .drv file names, and to register them. Use 'derivation->output-path' instead of 'derivation-path->output-path'. * guix/scripts/package.scm (roll-back): Adjust to the single-value return. (guix-package): Use 'derivation->output-path'. * guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?' objects instead of .drv file names. * gnu/system/grub.scm (grub-configuration-file): Use 'derivation->output-path' instead of 'derivation-path->output-path'. * gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise. * tests/builders.scm, tests/derivations.scm, tests/packages.scm, tests/store.scm, tests/union.scm: Adjust to the new calling convention. * doc/guix.texi (Defining Packages, The Store, Derivations): Adjust accordingly.
8 years ago
derivations: 'derivation' and related procedures return a single value. * guix/derivations.scm (derivation->output-path, derivation->output-paths): New procedures. (derivation-path->output-path): Use 'derivation->output-path'. (derivation-path->output-paths): Use 'derivation->output-paths'. (derivation): Accept 'derivation?' objects as inputs. Return a single value. (build-derivations): New procedure. (compiled-modules): Use 'derivation->output-paths'. (build-expression->derivation)[source-path]: Add case for when the input matches 'derivation?'. [prologue]: Accept 'derivation?' objects in INPUTS. [mod-dir, go-dir]: Use 'derivation->output-path'. * guix/download.scm (url-fetch): Adjust to the single-value return. * guix/packages.scm (package-output): Use 'derivation->output-path'. * guix/scripts/build.scm (guix-build): When the argument is 'derivation-path?', pass it through 'read-derivation'. Use 'derivation-file-name' to print out the .drv file names, and to register them. Use 'derivation->output-path' instead of 'derivation-path->output-path'. * guix/scripts/package.scm (roll-back): Adjust to the single-value return. (guix-package): Use 'derivation->output-path'. * guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?' objects instead of .drv file names. * gnu/system/grub.scm (grub-configuration-file): Use 'derivation->output-path' instead of 'derivation-path->output-path'. * gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise. * tests/builders.scm, tests/derivations.scm, tests/packages.scm, tests/store.scm, tests/union.scm: Adjust to the new calling convention. * doc/guix.texi (Defining Packages, The Store, Derivations): Adjust accordingly.
8 years ago
derivations: 'derivation' and related procedures return a single value. * guix/derivations.scm (derivation->output-path, derivation->output-paths): New procedures. (derivation-path->output-path): Use 'derivation->output-path'. (derivation-path->output-paths): Use 'derivation->output-paths'. (derivation): Accept 'derivation?' objects as inputs. Return a single value. (build-derivations): New procedure. (compiled-modules): Use 'derivation->output-paths'. (build-expression->derivation)[source-path]: Add case for when the input matches 'derivation?'. [prologue]: Accept 'derivation?' objects in INPUTS. [mod-dir, go-dir]: Use 'derivation->output-path'. * guix/download.scm (url-fetch): Adjust to the single-value return. * guix/packages.scm (package-output): Use 'derivation->output-path'. * guix/scripts/build.scm (guix-build): When the argument is 'derivation-path?', pass it through 'read-derivation'. Use 'derivation-file-name' to print out the .drv file names, and to register them. Use 'derivation->output-path' instead of 'derivation-path->output-path'. * guix/scripts/package.scm (roll-back): Adjust to the single-value return. (guix-package): Use 'derivation->output-path'. * guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?' objects instead of .drv file names. * gnu/system/grub.scm (grub-configuration-file): Use 'derivation->output-path' instead of 'derivation-path->output-path'. * gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise. * tests/builders.scm, tests/derivations.scm, tests/packages.scm, tests/store.scm, tests/union.scm: Adjust to the new calling convention. * doc/guix.texi (Defining Packages, The Store, Derivations): Adjust accordingly.
8 years ago
derivations: 'derivation' and related procedures return a single value. * guix/derivations.scm (derivation->output-path, derivation->output-paths): New procedures. (derivation-path->output-path): Use 'derivation->output-path'. (derivation-path->output-paths): Use 'derivation->output-paths'. (derivation): Accept 'derivation?' objects as inputs. Return a single value. (build-derivations): New procedure. (compiled-modules): Use 'derivation->output-paths'. (build-expression->derivation)[source-path]: Add case for when the input matches 'derivation?'. [prologue]: Accept 'derivation?' objects in INPUTS. [mod-dir, go-dir]: Use 'derivation->output-path'. * guix/download.scm (url-fetch): Adjust to the single-value return. * guix/packages.scm (package-output): Use 'derivation->output-path'. * guix/scripts/build.scm (guix-build): When the argument is 'derivation-path?', pass it through 'read-derivation'. Use 'derivation-file-name' to print out the .drv file names, and to register them. Use 'derivation->output-path' instead of 'derivation-path->output-path'. * guix/scripts/package.scm (roll-back): Adjust to the single-value return. (guix-package): Use 'derivation->output-path'. * guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?' objects instead of .drv file names. * gnu/system/grub.scm (grub-configuration-file): Use 'derivation->output-path' instead of 'derivation-path->output-path'. * gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise. * tests/builders.scm, tests/derivations.scm, tests/packages.scm, tests/store.scm, tests/union.scm: Adjust to the new calling convention. * doc/guix.texi (Defining Packages, The Store, Derivations): Adjust accordingly.
8 years ago
derivations: 'derivation' and related procedures return a single value. * guix/derivations.scm (derivation->output-path, derivation->output-paths): New procedures. (derivation-path->output-path): Use 'derivation->output-path'. (derivation-path->output-paths): Use 'derivation->output-paths'. (derivation): Accept 'derivation?' objects as inputs. Return a single value. (build-derivations): New procedure. (compiled-modules): Use 'derivation->output-paths'. (build-expression->derivation)[source-path]: Add case for when the input matches 'derivation?'. [prologue]: Accept 'derivation?' objects in INPUTS. [mod-dir, go-dir]: Use 'derivation->output-path'. * guix/download.scm (url-fetch): Adjust to the single-value return. * guix/packages.scm (package-output): Use 'derivation->output-path'. * guix/scripts/build.scm (guix-build): When the argument is 'derivation-path?', pass it through 'read-derivation'. Use 'derivation-file-name' to print out the .drv file names, and to register them. Use 'derivation->output-path' instead of 'derivation-path->output-path'. * guix/scripts/package.scm (roll-back): Adjust to the single-value return. (guix-package): Use 'derivation->output-path'. * guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?' objects instead of .drv file names. * gnu/system/grub.scm (grub-configuration-file): Use 'derivation->output-path' instead of 'derivation-path->output-path'. * gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise. * tests/builders.scm, tests/derivations.scm, tests/packages.scm, tests/store.scm, tests/union.scm: Adjust to the new calling convention. * doc/guix.texi (Defining Packages, The Store, Derivations): Adjust accordingly.
8 years ago
derivations: 'derivation' and related procedures return a single value. * guix/derivations.scm (derivation->output-path, derivation->output-paths): New procedures. (derivation-path->output-path): Use 'derivation->output-path'. (derivation-path->output-paths): Use 'derivation->output-paths'. (derivation): Accept 'derivation?' objects as inputs. Return a single value. (build-derivations): New procedure. (compiled-modules): Use 'derivation->output-paths'. (build-expression->derivation)[source-path]: Add case for when the input matches 'derivation?'. [prologue]: Accept 'derivation?' objects in INPUTS. [mod-dir, go-dir]: Use 'derivation->output-path'. * guix/download.scm (url-fetch): Adjust to the single-value return. * guix/packages.scm (package-output): Use 'derivation->output-path'. * guix/scripts/build.scm (guix-build): When the argument is 'derivation-path?', pass it through 'read-derivation'. Use 'derivation-file-name' to print out the .drv file names, and to register them. Use 'derivation->output-path' instead of 'derivation-path->output-path'. * guix/scripts/package.scm (roll-back): Adjust to the single-value return. (guix-package): Use 'derivation->output-path'. * guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?' objects instead of .drv file names. * gnu/system/grub.scm (grub-configuration-file): Use 'derivation->output-path' instead of 'derivation-path->output-path'. * gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise. * tests/builders.scm, tests/derivations.scm, tests/packages.scm, tests/store.scm, tests/union.scm: Adjust to the new calling convention. * doc/guix.texi (Defining Packages, The Store, Derivations): Adjust accordingly.
8 years ago
derivations: 'derivation' and related procedures return a single value. * guix/derivations.scm (derivation->output-path, derivation->output-paths): New procedures. (derivation-path->output-path): Use 'derivation->output-path'. (derivation-path->output-paths): Use 'derivation->output-paths'. (derivation): Accept 'derivation?' objects as inputs. Return a single value. (build-derivations): New procedure. (compiled-modules): Use 'derivation->output-paths'. (build-expression->derivation)[source-path]: Add case for when the input matches 'derivation?'. [prologue]: Accept 'derivation?' objects in INPUTS. [mod-dir, go-dir]: Use 'derivation->output-path'. * guix/download.scm (url-fetch): Adjust to the single-value return. * guix/packages.scm (package-output): Use 'derivation->output-path'. * guix/scripts/build.scm (guix-build): When the argument is 'derivation-path?', pass it through 'read-derivation'. Use 'derivation-file-name' to print out the .drv file names, and to register them. Use 'derivation->output-path' instead of 'derivation-path->output-path'. * guix/scripts/package.scm (roll-back): Adjust to the single-value return. (guix-package): Use 'derivation->output-path'. * guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?' objects instead of .drv file names. * gnu/system/grub.scm (grub-configuration-file): Use 'derivation->output-path' instead of 'derivation-path->output-path'. * gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise. * tests/builders.scm, tests/derivations.scm, tests/packages.scm, tests/store.scm, tests/union.scm: Adjust to the new calling convention. * doc/guix.texi (Defining Packages, The Store, Derivations): Adjust accordingly.
8 years ago
derivations: 'derivation' and related procedures return a single value. * guix/derivations.scm (derivation->output-path, derivation->output-paths): New procedures. (derivation-path->output-path): Use 'derivation->output-path'. (derivation-path->output-paths): Use 'derivation->output-paths'. (derivation): Accept 'derivation?' objects as inputs. Return a single value. (build-derivations): New procedure. (compiled-modules): Use 'derivation->output-paths'. (build-expression->derivation)[source-path]: Add case for when the input matches 'derivation?'. [prologue]: Accept 'derivation?' objects in INPUTS. [mod-dir, go-dir]: Use 'derivation->output-path'. * guix/download.scm (url-fetch): Adjust to the single-value return. * guix/packages.scm (package-output): Use 'derivation->output-path'. * guix/scripts/build.scm (guix-build): When the argument is 'derivation-path?', pass it through 'read-derivation'. Use 'derivation-file-name' to print out the .drv file names, and to register them. Use 'derivation->output-path' instead of 'derivation-path->output-path'. * guix/scripts/package.scm (roll-back): Adjust to the single-value return. (guix-package): Use 'derivation->output-path'. * guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?' objects instead of .drv file names. * gnu/system/grub.scm (grub-configuration-file): Use 'derivation->output-path' instead of 'derivation-path->output-path'. * gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise. * tests/builders.scm, tests/derivations.scm, tests/packages.scm, tests/store.scm, tests/union.scm: Adjust to the new calling convention. * doc/guix.texi (Defining Packages, The Store, Derivations): Adjust accordingly.
8 years ago
derivations: 'derivation' and related procedures return a single value. * guix/derivations.scm (derivation->output-path, derivation->output-paths): New procedures. (derivation-path->output-path): Use 'derivation->output-path'. (derivation-path->output-paths): Use 'derivation->output-paths'. (derivation): Accept 'derivation?' objects as inputs. Return a single value. (build-derivations): New procedure. (compiled-modules): Use 'derivation->output-paths'. (build-expression->derivation)[source-path]: Add case for when the input matches 'derivation?'. [prologue]: Accept 'derivation?' objects in INPUTS. [mod-dir, go-dir]: Use 'derivation->output-path'. * guix/download.scm (url-fetch): Adjust to the single-value return. * guix/packages.scm (package-output): Use 'derivation->output-path'. * guix/scripts/build.scm (guix-build): When the argument is 'derivation-path?', pass it through 'read-derivation'. Use 'derivation-file-name' to print out the .drv file names, and to register them. Use 'derivation->output-path' instead of 'derivation-path->output-path'. * guix/scripts/package.scm (roll-back): Adjust to the single-value return. (guix-package): Use 'derivation->output-path'. * guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?' objects instead of .drv file names. * gnu/system/grub.scm (grub-configuration-file): Use 'derivation->output-path' instead of 'derivation-path->output-path'. * gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise. * tests/builders.scm, tests/derivations.scm, tests/packages.scm, tests/store.scm, tests/union.scm: Adjust to the new calling convention. * doc/guix.texi (Defining Packages, The Store, Derivations): Adjust accordingly.
8 years ago
derivations: 'derivation' and related procedures return a single value. * guix/derivations.scm (derivation->output-path, derivation->output-paths): New procedures. (derivation-path->output-path): Use 'derivation->output-path'. (derivation-path->output-paths): Use 'derivation->output-paths'. (derivation): Accept 'derivation?' objects as inputs. Return a single value. (build-derivations): New procedure. (compiled-modules): Use 'derivation->output-paths'. (build-expression->derivation)[source-path]: Add case for when the input matches 'derivation?'. [prologue]: Accept 'derivation?' objects in INPUTS. [mod-dir, go-dir]: Use 'derivation->output-path'. * guix/download.scm (url-fetch): Adjust to the single-value return. * guix/packages.scm (package-output): Use 'derivation->output-path'. * guix/scripts/build.scm (guix-build): When the argument is 'derivation-path?', pass it through 'read-derivation'. Use 'derivation-file-name' to print out the .drv file names, and to register them. Use 'derivation->output-path' instead of 'derivation-path->output-path'. * guix/scripts/package.scm (roll-back): Adjust to the single-value return. (guix-package): Use 'derivation->output-path'. * guix/ui.scm (show-what-to-build): Adjust to deal with 'derivation?' objects instead of .drv file names. * gnu/system/grub.scm (grub-configuration-file): Use 'derivation->output-path' instead of 'derivation-path->output-path'. * gnu/system/vm.scm (qemu-image, system-qemu-image): Likewise. * tests/builders.scm, tests/derivations.scm, tests/packages.scm, tests/store.scm, tests/union.scm: Adjust to the new calling convention. * doc/guix.texi (Defining Packages, The Store, Derivations): Adjust accordingly.
8 years ago
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
  3. ;;;
  4. ;;; This file is part of GNU Guix.
  5. ;;;
  6. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or (at
  9. ;;; your option) any later version.
  10. ;;;
  11. ;;; GNU Guix is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  18. (define-module (test-store)
  19. #:use-module (guix store)
  20. #:use-module (guix utils)
  21. #:use-module (guix hash)
  22. #:use-module (guix base32)
  23. #:use-module (guix packages)
  24. #:use-module (guix derivations)
  25. #:use-module (guix nar)
  26. #:use-module (gnu packages)
  27. #:use-module (gnu packages bootstrap)
  28. #:use-module (ice-9 match)
  29. #:use-module (rnrs bytevectors)
  30. #:use-module (rnrs io ports)
  31. #:use-module (web uri)
  32. #:use-module (srfi srfi-1)
  33. #:use-module (srfi srfi-11)
  34. #:use-module (srfi srfi-26)
  35. #:use-module (srfi srfi-34)
  36. #:use-module (srfi srfi-64))
  37. ;; Test the (guix store) module.
  38. (define %store
  39. (false-if-exception (open-connection)))
  40. (when %store
  41. ;; Make sure we build everything by ourselves.
  42. (set-build-options %store #:use-substitutes? #f))
  43. (define %seed
  44. (seed->random-state (logxor (getpid) (car (gettimeofday)))))
  45. (define (random-text)
  46. (number->string (random (expt 2 256) %seed) 16))
  47. (test-begin "store")
  48. (test-equal "store-path-hash-part"
  49. "283gqy39v3g9dxjy26rynl0zls82fmcg"
  50. (store-path-hash-part
  51. (string-append (%store-prefix)
  52. "/283gqy39v3g9dxjy26rynl0zls82fmcg-guile-2.0.7")))
  53. (test-equal "store-path-hash-part #f"
  54. #f
  55. (store-path-hash-part
  56. (string-append (%store-prefix)
  57. "/foo/bar/283gqy39v3g9dxjy26rynl0zls82fmcg-guile-2.0.7")))
  58. (test-equal "store-path-package-name"
  59. "guile-2.0.7"
  60. (store-path-package-name
  61. (string-append (%store-prefix)
  62. "/283gqy39v3g9dxjy26rynl0zls82fmcg-guile-2.0.7")))
  63. (test-equal "store-path-package-name #f"
  64. #f
  65. (store-path-package-name
  66. "/foo/bar/283gqy39v3g9dxjy26rynl0zls82fmcg-guile-2.0.7"))
  67. (test-assert "direct-store-path?"
  68. (and (direct-store-path?
  69. (string-append (%store-prefix)
  70. "/283gqy39v3g9dxjy26rynl0zls82fmcg-guile-2.0.7"))
  71. (not (direct-store-path?
  72. (string-append
  73. (%store-prefix)
  74. "/283gqy39v3g9dxjy26rynl0zls82fmcg-guile-2.0.7/bin/guile")))))
  75. (test-skip (if %store 0 10))
  76. (test-assert "dead-paths"
  77. (let ((p (add-text-to-store %store "random-text" (random-text))))
  78. (member p (dead-paths %store))))
  79. ;; FIXME: Find a test for `live-paths'.
  80. ;;
  81. ;; (test-assert "temporary root is in live-paths"
  82. ;; (let* ((p1 (add-text-to-store %store "random-text"
  83. ;; (random-text) '()))
  84. ;; (b (add-text-to-store %store "link-builder"
  85. ;; (format #f "echo ~a > $out" p1)
  86. ;; '()))
  87. ;; (d1 (derivation %store "link"
  88. ;; "/bin/sh" `("-e" ,b)
  89. ;; #:inputs `((,b) (,p1))))
  90. ;; (p2 (derivation->output-path d1)))
  91. ;; (and (add-temp-root %store p2)
  92. ;; (build-derivations %store (list d1))
  93. ;; (valid-path? %store p1)
  94. ;; (member (pk p2) (live-paths %store)))))
  95. (test-assert "dead path can be explicitly collected"
  96. (let ((p (add-text-to-store %store "random-text"
  97. (random-text) '())))
  98. (let-values (((paths freed) (delete-paths %store (list p))))
  99. (and (equal? paths (list p))
  100. (> freed 0)
  101. (not (file-exists? p))))))
  102. (test-assert "references"
  103. (let* ((t1 (add-text-to-store %store "random1"
  104. (random-text)))
  105. (t2 (add-text-to-store %store "random2"
  106. (random-text) (list t1))))
  107. (and (equal? (list t1) (references %store t2))
  108. (equal? (list t2) (referrers %store t1))
  109. (null? (references %store t1))
  110. (null? (referrers %store t2)))))
  111. (test-assert "requisites"
  112. (let* ((t1 (add-text-to-store %store "random1"
  113. (random-text) '()))
  114. (t2 (add-text-to-store %store "random2"
  115. (random-text) (list t1)))
  116. (t3 (add-text-to-store %store "random3"
  117. (random-text) (list t2)))
  118. (t4 (add-text-to-store %store "random4"
  119. (random-text) (list t1 t3))))
  120. (define (same? x y)
  121. (and (= (length x) (length y))
  122. (lset= equal? x y)))
  123. (and (same? (requisites %store t1) (list t1))
  124. (same? (requisites %store t2) (list t1 t2))
  125. (same? (requisites %store t3) (list t1 t2 t3))
  126. (same? (requisites %store t4) (list t1 t2 t3 t4)))))
  127. (test-assert "derivers"
  128. (let* ((b (add-text-to-store %store "build" "echo $foo > $out" '()))
  129. (s (add-to-store %store "bash" #t "sha256"
  130. (search-bootstrap-binary "bash"
  131. (%current-system))))
  132. (d (derivation %store "the-thing"
  133. s `("-e" ,b)
  134. #:env-vars `(("foo" . ,(random-text)))
  135. #:inputs `((,b) (,s))))
  136. (o (derivation->output-path d)))
  137. (and (build-derivations %store (list d))
  138. (equal? (query-derivation-outputs %store (derivation-file-name d))
  139. (list o))
  140. (equal? (valid-derivers %store o)
  141. (list (derivation-file-name d))))))
  142. (test-assert "topologically-sorted, one item"
  143. (let* ((a (add-text-to-store %store "a" "a"))
  144. (b (add-text-to-store %store "b" "b" (list a)))
  145. (c (add-text-to-store %store "c" "c" (list b)))
  146. (d (add-text-to-store %store "d" "d" (list c)))
  147. (s (topologically-sorted %store (list d))))
  148. (equal? s (list a b c d))))
  149. (test-assert "topologically-sorted, several items"
  150. (let* ((a (add-text-to-store %store "a" "a"))
  151. (b (add-text-to-store %store "b" "b" (list a)))
  152. (c (add-text-to-store %store "c" "c" (list b)))
  153. (d (add-text-to-store %store "d" "d" (list c)))
  154. (s1 (topologically-sorted %store (list d a c b)))
  155. (s2 (topologically-sorted %store (list b d c a b d))))
  156. (equal? s1 s2 (list a b c d))))
  157. (test-assert "topologically-sorted, more difficult"
  158. (let* ((a (add-text-to-store %store "a" "a"))
  159. (b (add-text-to-store %store "b" "b" (list a)))
  160. (c (add-text-to-store %store "c" "c" (list b)))
  161. (d (add-text-to-store %store "d" "d" (list c)))
  162. (w (add-text-to-store %store "w" "w"))
  163. (x (add-text-to-store %store "x" "x" (list w)))
  164. (y (add-text-to-store %store "y" "y" (list x d)))
  165. (s1 (topologically-sorted %store (list y)))
  166. (s2 (topologically-sorted %store (list c y)))
  167. (s3 (topologically-sorted %store (cons y (references %store y)))))
  168. (and (equal? s1 (list w x a b c d y))
  169. (equal? s2 (list a b c w x d y))
  170. (lset= string=? s1 s3))))
  171. (test-assert "log-file, derivation"
  172. (let* ((b (add-text-to-store %store "build" "echo $foo > $out" '()))
  173. (s (add-to-store %store "bash" #t "sha256"
  174. (search-bootstrap-binary "bash"
  175. (%current-system))))
  176. (d (derivation %store "the-thing"
  177. s `("-e" ,b)
  178. #:env-vars `(("foo" . ,(random-text)))
  179. #:inputs `((,b) (,s)))))
  180. (and (build-derivations %store (list d))
  181. (file-exists? (pk (log-file %store (derivation-file-name d)))))))
  182. (test-assert "log-file, output file name"
  183. (let* ((b (add-text-to-store %store "build" "echo $foo > $out" '()))
  184. (s (add-to-store %store "bash" #t "sha256"
  185. (search-bootstrap-binary "bash"
  186. (%current-system))))
  187. (d (derivation %store "the-thing"
  188. s `("-e" ,b)
  189. #:env-vars `(("foo" . ,(random-text)))
  190. #:inputs `((,b) (,s))))
  191. (o (derivation->output-path d)))
  192. (and (build-derivations %store (list d))
  193. (file-exists? (pk (log-file %store o)))
  194. (string=? (log-file %store (derivation-file-name d))
  195. (log-file %store o)))))
  196. (test-assert "no substitutes"
  197. (let* ((s (open-connection))
  198. (d1 (package-derivation s %bootstrap-guile (%current-system)))
  199. (d2 (package-derivation s %bootstrap-glibc (%current-system)))
  200. (o (map derivation->output-path (list d1 d2))))
  201. (set-build-options s #:use-substitutes? #f)
  202. (and (not (has-substitutes? s (derivation-file-name d1)))
  203. (not (has-substitutes? s (derivation-file-name d2)))
  204. (null? (substitutable-paths s o))
  205. (null? (substitutable-path-info s o)))))
  206. (test-skip (if (getenv "GUIX_BINARY_SUBSTITUTE_URL") 0 1))
  207. (test-assert "substitute query"
  208. (let* ((s (open-connection))
  209. (d (package-derivation s %bootstrap-guile (%current-system)))
  210. (o (derivation->output-path d))
  211. (dir (and=> (getenv "GUIX_BINARY_SUBSTITUTE_URL")
  212. (compose uri-path string->uri))))
  213. ;; Create fake substituter data, to be read by `substitute-binary'.
  214. (call-with-output-file (string-append dir "/nix-cache-info")
  215. (lambda (p)
  216. (format p "StoreDir: ~a\nWantMassQuery: 0\n"
  217. (%store-prefix))))
  218. (call-with-output-file (string-append dir "/" (store-path-hash-part o)
  219. ".narinfo")
  220. (lambda (p)
  221. (format p "StorePath: ~a
  222. URL: ~a
  223. Compression: none
  224. NarSize: 1234
  225. References:
  226. System: ~a
  227. Deriver: ~a~%"
  228. o ; StorePath
  229. (string-append dir "/example.nar") ; URL
  230. (%current-system) ; System
  231. (basename
  232. (derivation-file-name d))))) ; Deriver
  233. ;; Remove entry from the local cache.
  234. (false-if-exception
  235. (delete-file (string-append (getenv "XDG_CACHE_HOME")
  236. "/guix/substitute-binary/"
  237. (store-path-hash-part o))))
  238. ;; Make sure `substitute-binary' correctly communicates the above data.
  239. (set-build-options s #:use-substitutes? #t)
  240. (and (has-substitutes? s o)
  241. (equal? (list o) (substitutable-paths s (list o)))
  242. (match (pk 'spi (substitutable-path-info s (list o)))
  243. (((? substitutable? s))
  244. (and (string=? (substitutable-deriver s) (derivation-file-name d))
  245. (null? (substitutable-references s))
  246. (equal? (substitutable-nar-size s) 1234)))))))
  247. (test-assert "substitute"
  248. (let* ((s (open-connection))
  249. (c (random-text)) ; contents of the output
  250. (d (build-expression->derivation
  251. s "substitute-me"
  252. `(call-with-output-file %output
  253. (lambda (p)
  254. (exit 1) ; would actually fail
  255. (display ,c p)))
  256. #:guile-for-build
  257. (package-derivation s %bootstrap-guile (%current-system))))
  258. (o (derivation->output-path d))
  259. (dir (and=> (getenv "GUIX_BINARY_SUBSTITUTE_URL")
  260. (compose uri-path string->uri))))
  261. ;; Create fake substituter data, to be read by `substitute-binary'.
  262. (call-with-output-file (string-append dir "/nix-cache-info")
  263. (lambda (p)
  264. (format p "StoreDir: ~a\nWantMassQuery: 0\n"
  265. (%store-prefix))))
  266. (call-with-output-file (string-append dir "/example.out")
  267. (lambda (p)
  268. (display c p)))
  269. (call-with-output-file (string-append dir "/example.nar")
  270. (lambda (p)
  271. (write-file (string-append dir "/example.out") p)))
  272. (call-with-output-file (string-append dir "/" (store-path-hash-part o)
  273. ".narinfo")
  274. (lambda (p)
  275. (format p "StorePath: ~a
  276. URL: ~a
  277. Compression: none
  278. NarSize: 1234
  279. NarHash: sha256:~a
  280. References:
  281. System: ~a
  282. Deriver: ~a~%"
  283. o ; StorePath
  284. "example.nar" ; relative URL
  285. (call-with-input-file (string-append dir "/example.nar")
  286. (compose bytevector->nix-base32-string sha256
  287. get-bytevector-all))
  288. (%current-system) ; System
  289. (basename
  290. (derivation-file-name d))))) ; Deriver
  291. ;; Make sure we use `substitute-binary'.
  292. (set-build-options s #:use-substitutes? #t)
  293. (and (has-substitutes? s o)
  294. (build-derivations s (list d))
  295. (equal? c (call-with-input-file o get-string-all)))))
  296. (test-assert "substitute --fallback"
  297. (let* ((s (open-connection))
  298. (t (random-text)) ; contents of the output
  299. (d (build-expression->derivation
  300. s "substitute-me-not"
  301. `(call-with-output-file %output
  302. (lambda (p)
  303. (display ,t p)))
  304. #:guile-for-build
  305. (package-derivation s %bootstrap-guile (%current-system))))
  306. (o (derivation->output-path d))
  307. (dir (and=> (getenv "GUIX_BINARY_SUBSTITUTE_URL")
  308. (compose uri-path string->uri))))
  309. ;; Create fake substituter data, to be read by `substitute-binary'.
  310. (call-with-output-file (string-append dir "/nix-cache-info")
  311. (lambda (p)
  312. (format p "StoreDir: ~a\nWantMassQuery: 0\n"
  313. (%store-prefix))))
  314. (call-with-output-file (string-append dir "/" (store-path-hash-part o)
  315. ".narinfo")
  316. (lambda (p)
  317. (format p "StorePath: ~a
  318. URL: ~a
  319. Compression: none
  320. NarSize: 1234
  321. NarHash: sha256:0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
  322. References:
  323. System: ~a
  324. Deriver: ~a~%"
  325. o ; StorePath
  326. "does-not-exist.nar" ; relative URL
  327. (%current-system) ; System
  328. (basename
  329. (derivation-file-name d))))) ; Deriver
  330. ;; Make sure we use `substitute-binary'.
  331. (set-build-options s #:use-substitutes? #t)
  332. (and (has-substitutes? s o)
  333. (guard (c ((nix-protocol-error? c)
  334. ;; The substituter failed as expected. Now make sure that
  335. ;; #:fallback? #t works correctly.
  336. (set-build-options s
  337. #:use-substitutes? #t
  338. #:fallback? #t)
  339. (and (build-derivations s (list d))
  340. (equal? t (call-with-input-file o get-string-all)))))
  341. ;; Should fail.
  342. (build-derivations s (list d))
  343. #f))))
  344. (test-assert "export/import several paths"
  345. (let* ((texts (unfold (cut >= <> 10)
  346. (lambda _ (random-text))
  347. 1+
  348. 0))
  349. (files (map (cut add-text-to-store %store "text" <>) texts))
  350. (dump (call-with-bytevector-output-port
  351. (cut export-paths %store files <>))))
  352. (delete-paths %store files)
  353. (and (every (negate file-exists?) files)
  354. (let* ((source (open-bytevector-input-port dump))
  355. (imported (import-paths %store source)))
  356. (and (equal? imported files)
  357. (every file-exists? files)
  358. (equal? texts
  359. (map (lambda (file)
  360. (call-with-input-file file
  361. get-string-all))
  362. files)))))))
  363. (test-assert "import corrupt path"
  364. (let* ((text (random-text))
  365. (file (add-text-to-store %store "text" text))
  366. (dump (call-with-bytevector-output-port
  367. (cut export-paths %store (list file) <>))))
  368. (delete-paths %store (list file))
  369. ;; Flip a bit in the stream's payload.
  370. (let* ((index (quotient (bytevector-length dump) 4))
  371. (byte (bytevector-u8-ref dump index)))
  372. (bytevector-u8-set! dump index (logxor #xff byte)))
  373. (and (not (file-exists? file))
  374. (guard (c ((nix-protocol-error? c)
  375. (pk 'c c)
  376. (and (not (zero? (nix-protocol-error-status c)))
  377. (string-contains (nix-protocol-error-message c)
  378. "corrupt"))))
  379. (let* ((source (open-bytevector-input-port dump))
  380. (imported (import-paths %store source)))
  381. (pk 'corrupt-imported imported)
  382. #f)))))
  383. (test-assert "register-path"
  384. (let ((file (string-append (%store-prefix) "/" (make-string 32 #\f)
  385. "-fake")))
  386. (when (valid-path? %store file)
  387. (delete-paths %store (list file)))
  388. (false-if-exception (delete-file file))
  389. (let ((ref (add-text-to-store %store "ref-of-fake" (random-text)))
  390. (drv (string-append file ".drv")))
  391. (call-with-output-file file
  392. (cut display "This is a fake store item.\n" <>))
  393. (register-path file
  394. #:references (list ref)
  395. #:deriver drv)
  396. (and (valid-path? %store file)
  397. (equal? (references %store file) (list ref))
  398. (null? (valid-derivers %store file))
  399. (null? (referrers %store file))))))
  400. (test-end "store")
  401. (exit (= (test-runner-fail-count (test-runner-current)) 0))