Commit Graph

434 Commits (aa30c6e73856a1c03230c14e31e892777bf37877)

Author SHA1 Message Date
Ludovic Courtès af9142dce0 tests: Fix typo in guix-build.sh.
* tests/guix-build.sh: Refer to the '%bootstrap' variables from (gnu
  packages bootstrap), not (gnu packages base).
2014-08-27 00:27:12 +02:00
Ludovic Courtès c6df09941b guix-register: By default, attempt to deduplicate registered items.
* nix/guix-register/guix-register.cc (GUIX_OPT_DEDUPLICATE): New macro.
  (options): Add --no-deduplication.
  (deduplication): New variable.
  (parse_opt): Handle GUIX_OPT_DEDUPLICATE.
  (register_validity): Add 'optimize' parameter and honor it.
  (main): Move 'store' instanatiation after 'settings.nixStore'
  assignment.
* tests/guix-register.sh: Add test for deduplication.
* guix/nar.scm (finalize-store-file): Update comment above
  'register-path' call.
2014-08-25 00:16:49 +02:00
Ludovic Courtès c1bc358f29 Factorize test suite support in (guix tests).
* guix/tests.scm: New file.
* Makefile.am (noinst_DATA): New variable.
  (GOBJECTS): Add guix/tests.go.
* tests/builders.scm (%store): Use 'open-connection-for-tests'
  from (guix tests).
* tests/derivations.scm: Likewise.
* tests/monads.scm: Likewise.
* tests/packages.scm: Likewise.
* tests/profiles.scm: Likewise.
* tests/union.scm: Likewise.
* tests/gexp.scm: Likewise.
  (guile-for-build): Remove.  Use (%guile-for-build) instead.
* tests/nar.scm (make-random-bytevector, %seed, random-text): Remove.
  (populate-file): Change 'make-random-bytevector' to 'random-bytevector'.
  Use (guix tests).
* tests/store.scm (%seed, random-text): Remove.
  Use (guix tests).
2014-08-23 22:33:04 +02:00
Ludovic Courtès 79ee406d51 profiles: Produce a top-level Info 'dir' file.
Fixes <http://bugs.gnu.org/18305>.
Reported by Brandon Invergo <brandon@gnu.org>.

* guix/profiles.scm (manifest-inputs, info-dir-file): New procedures.
  (profile-derivation): Use them.  Add #:info-dir? parameter and honor
  it.
* guix/scripts/package.scm (guix-package): Call 'profile-derivation'
  with #:info-dir? #f when the 'bootstrap? option is set.
* tests/profiles.scm ("profile-derivation"): Pass #:info-dir? #f.
2014-08-23 22:33:03 +02:00
Alex Kost 343745c80a profiles: Add 'manifest-transaction'.
* guix/profiles.scm (<manifest-transaction>): New record-type.
  (manifest-perform-transaction): New procedure.
  (manifest-show-transaction): New procedure.
* tests/profiles.scm ("manifest-perform-transaction"): New test.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2014-08-19 22:55:22 +02:00
Ludovic Courtès 667b250846 gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
  (write-gexp): Use both 'gexp-references' and
  'gexp-native-references'.
  (gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
  and append them.
  (gexp-inputs): Add 'references' parameter and honor it.
  (gexp-native-inputs): New procedure.
  (gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
  Use it, and use 'gexp-native-references'.
  (gexp)[collect-native-escapes]: New procedure.
  [escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
  [substitute-ungexp, substitute-ungexp-splicing]: New procedures.
  [substitute-references]: Use them, and handle 'ungexp-native' and
  'ungexp-native-splicing'.
  Adjust generated 'make-gexp' call to provide both normal references
  and native references.
  [read-ungexp]: Support 'ungexp-native' and
  'ungexp-native-splicing'.
  Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
  (gexp->sexp*): Add 'target' parameter.
  ("ungexp + ungexp-native",
  "input list + ungexp-native",
  "input list splicing + ungexp-native-splicing",
  "gexp->derivation, ungexp-native",
  "gexp->derivation, ungexp + ungexp-native"): New tests.
  ("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 15:01:58 +02:00
Ludovic Courtès 68a61e9ffb gexp: Add #:target parameter to 'gexp->derivation'.
* guix/gexp.scm (lower-inputs): Add #:system and #:target.  Use
  'package->cross-derivation' when TARGET is true.  Honor SYSTEM.
  (gexp->derivation): Add #:target argument.  Pass SYSTEM and TARGET to
  'lower-inputs' and 'gexp->sexp'.
  (gexp->sexp): Add #:system and #:target.  Pass them in recursive call
  and to 'package-file'.
* tests/gexp.scm (gexp->sexp*): Add 'system' and 'target' parameters.
  ("gexp->derivation, cross-compilation"): New test.
2014-08-17 21:20:11 +02:00
Ludovic Courtès c90ddc8f81 monads: 'package-file' uses '%current-system' at '>>=' time.
* guix/monads.scm (package-file): Leave #:system to #f by default.
* tests/monads.scm ("package-file, default system"): New test.
2014-08-17 21:08:06 +02:00
Ludovic Courtès 4231f05bbc monads: Add 'package->cross-derivation' and #:target for 'package-file'.
* guix/monads.scm (package-file): Add #:target keyword parameter and
  honor it.
  (package->cross-derivation): New procedure.
* tests/monads.scm ("package-file + package->cross-derivation"): New test.
* doc/guix.texi (The Store Monad): Update 'package-file' documentation.
  Add 'package->cross-derivation'.
2014-08-17 20:58:58 +02:00
Alex Kost f755403014 profiles: Add 'manifest-add'.
* guix/profiles.scm (manifest-add): New procedure.
* tests/profiles.scm (guile-1.8.8): New variable.
  ("manifest-add"): New test.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2014-08-12 16:03:33 +02:00
Cyrill Schenkel 3a09e1d2e8 ui: Fix handling of periods by fill-paragraph.
Fixes <http://bugs.gnu.org/17468>.

* guix/ui.scm (fill-paragraph): Two spaces after period and no spaces before newline.
* tests/ui.scm: New test case.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2014-08-11 18:27:03 +02:00
Ludovic Courtès 462f5ccade profiles: Add 'package->manifest-entry'.
Suggested by Alex Kost <alezost@gmail.com>.

* guix/scripts/package.scm (options->installable)[package->manifest-entry]:
  Move to (guix profiles).
  [package->manifest-entry*]: New procedure.
  Use it.
* guix/profiles.scm (package->manifest-entry): New procedure.
* tests/profiles.scm (guile-for-build): New variable.
  Call '%guile-for-build'.
  ("profile-derivation"): New test.
2014-07-26 22:57:00 +02:00
Ludovic Courtès a54c94a40d profiles: Switch to gexps.
* guix/profiles.scm (<manifest-entry>)[path]: Rename to...
  [item]: ... this.  Update users.
  (manifest->sexp): Rename to...
  (manifest->gexp): ... this.  Return a gexp.
  (lower-input): Remove.
  (profile-derivation): Remove 'store' parameter, and turn into a
  monadic procedure.
  [inputs]: New variable.
  [builder]: Turn into a gexp.
  Replace call to 'build-expression->derivation' with call to
  'gexp->derivation'.
* guix/scripts/package.scm (link-to-empty-profile): Adjust call to
  'profile-derivation', and wrap it in 'run-with-store'.
  (show-what-to-remove/install): Rename 'path' to 'item'.  Check whether
  ITEM is a package, and return its output path if it is.
  (input->name+path): Remove.
  (options->installable): Set 'item' to P.
  (guix-package): Adjust call to 'profile-derivation'.
* tests/profiles.scm (guile-2.0.9): Change 'path' to 'item'.
2014-07-26 22:56:59 +02:00
Ludovic Courtès 1b0a86dd1d tests: Make sure --search="" works.
* tests/guix-package.sh: Move '-s' tests outside of the network-only
  section.  Make sure --search="" works.
2014-07-25 17:56:14 +02:00
Eric Bavier 5e6feee617 guix: package: Fix recutils output for non-package inputs.
* guix/ui.scm (package->recutils)[dependencies]: Ignore non-package inputs.
* tests/guix-package.sh: New test.
2014-07-25 07:41:57 -05:00
Ludovic Courtès 3ce9aa44f1 build: Fix typo in 'guix package --show' test.
* tests/guix-package.sh: Change "^Package:" to "^name:".
2014-07-25 00:26:55 +02:00
Ludovic Courtès 6c9e7b2bea build: Better reject systems where the shebang would be too long.
* tests/gexp.scm (shebang): Add "#!".
2014-07-25 00:26:29 +02:00
Ludovic Courtès 0a90af1531 monads: Add 'interned-file'.
* guix/monads.scm (interned-file): New procedure.
* tests/monads.scm ("interned-file"): New test.
* doc/guix.texi (The Store Monad): Document it.
2014-07-24 23:02:26 +02:00
Cyril Roelandt 2aa6efb0b9 guix package: add a "show" option.
* doc/guix.texi: Update the documentation.
* guix/scripts/package.scm: Add a "show" option.
* tests/guix-package.sh: Add a test for the "show" option.
2014-07-21 22:18:03 +02:00
Ludovic Courtès 58f485cc80 build: Fix typo that would lead to hitting the socket name length limit.
* tests/guix-register.sh: Remove redundant $new_store in $NIX_STATE_DIR,
  introduced in 689142cd ("guix-register: Add '--state-directory'
  parameter.")  Reported by Eric Bavier <ericbavier@gmail.com> and
  Alen Skondro <askondro@gmail.com>.
2014-07-20 22:39:02 +02:00
Eric Bavier 516e3b6f7a guix: utils: Add fold-tree and fold-tree-leaves.
* guix/utils.scm (fold-tree, fold-tree-leaves): New functions.
* tests/utils.scm: Add tests for them.
2014-07-20 11:36:09 -05:00
Ludovic Courtès 689142cd75 guix-register: Add '--state-directory' parameter.
* nix/guix-register/guix-register.cc (GUIX_OPT_STATE_DIRECTORY): New
  macro.
  (parse_opt): Honor it.
* tests/guix-register.sh: Add test with '--state-directory'.
* guix/store.scm (register-path): Add #:state-directory parameter.
2014-07-18 20:40:51 +02:00
Ludovic Courtès a1906758c3 records: Report unknown field names in inheriting forms.
* guix/records.scm (define-record-type*)[record-inheritance]: Check for
  unexpected field names.
* tests/records.scm ("define-record-type* with let* behavior"): Return
  #t, not *unspecified*.
  ("define-record-type* & inherit & extra initializers"): New test.
2014-07-17 16:45:45 +02:00
Ludovic Courtès 23e9a68088 records: Add tests for error cases.
* tests/records.scm (test-module): New procedure.
  ("define-record-type* & missing initializers",
  "define-record-type* & extra initializers"): New tests.
2014-07-17 16:06:36 +02:00
Ludovic Courtès 2cf0ea0dbb gexp: Gracefully handle printing of gexps with spliced references.
* guix/gexp.scm (write-gexp): Wrap 'write' call in
  'false-if-exception'.
* tests/gexp.scm ("printer", "printer vs. ungexp-splicing"): New tests.
2014-07-17 15:40:06 +02:00
Ludovic Courtès 5d0984595c gexp: Resolve the default system at '>>=' time.
Partly fixes <http://bugs.gnu.org/18002>.
Reported by David Thompson <dthompson2@worcester.edu>.

* guix/gexp.scm (gexp->derivation): Change #:system to default #f.
  Use (%current-system) from within the 'mlet*'.
* tests/gexp.scm ("gexp->derivation, default system"): New test.
2014-07-12 23:17:53 +02:00
Ludovic Courtès f62435e286 monads: Fix 'mapm' so that effects happen from left to right.
* guix/monads.scm (mapm): Don't reverse LST, so that items are processed
  from left to right.  Bind the result of 'foldm' and reverse it.
* tests/monads.scm ("sequence"): Change 'frob' so it performs its side
  effect within an 'mlet' body.  Adjust call accordingly.
2014-07-12 23:17:53 +02:00
Ludovic Courtès 59c51be290 build: Get the canonical $HOME name when testing 'guix package'.
* tests/guix-package.sh (HOME): Recompute using 'pwd -P'.
2014-07-06 21:26:11 +02:00
Ludovic Courtès 8ad49499b9 build: Support running the test suite from a directory with symlinks.
Fixes <http://bugs.gnu.org/17935>.
Reported by Alex Kost <alezost@gmail.com>.

* test-env.in: Canonicalize $NIX_STORE_DIR, and remove
  $NIX_IGNORE_SYMLINK_STORE setting.
* tests/guix-register.sh: Likewise, canonicalize $new_store_dir and
  $new_store and leave $NIX_IGNORE_SYMLINK_STORE unchanged.
2014-07-05 19:15:08 +02:00
Ludovic Courtès 88371f0d7d guix package: Do the right thing for '-p ~/.guix-profile'.
Fixes <http://bugs.gnu.org/17939>.
Reported by Taylan Ulrich Bayirli/Kammer <taylanbayirli@gmail.com>.

* guix/scripts/package.scm (canonicalize-profile): New procedure.
  (%options): Use it for --profile.
* tests/guix-package.sh: Add test.
2014-07-05 14:56:08 +02:00
Ludovic Courtès c1202fb1f9 guix {system,offload}: Improve reporting of syntax errors.
* guix/scripts/system.scm (read-operating-system) <catch handler>: Add
  case for 'syntax-error'.  Correct message for default case.
* guix/scripts/offload.scm (build-machines) <catch handler>: Add case
  for 'syntax-error'.
* tests/guix-system.sh: New file.
* Makefile.am (SH_TESTS): Add it.
2014-06-27 00:12:40 +02:00
Ludovic Courtès 278b64283a tests: Use the C locale for 'guix package -s'.
* tests/guix-package.sh: Set LC_MESSAGES=C before the 'guix package -s'
  test.
2014-06-16 23:49:05 +02:00
Ludovic Courtès 56b8210697 guix build: Allow gexps to be passed to '-e'.
* guix/ui.scm (%guix-user-module): New variable.
  (read/eval): Pass it as the second argument to 'eval'.
* guix/scripts/build.scm (options/resolve-packages): Add case for
  'gexp?'.
* tests/guix-build.sh: Add tests.
* doc/guix.texi (Invoking guix build): Document '-e gexp'.
guxi build: Allow gexps to be passed to '-e'.

* guix/ui.scm (%guix-user-module): New variable.
  (read/eval): Pass it as the second argument to 'eval'.
* guix/scripts/build.scm (options/resolve-packages): Add case for
  'gexp?'.
* tests/guix-build.sh: Add tests.
* doc/guix.texi (Invoking guix build): Document '-e gexp'.
2014-06-14 22:55:59 +02:00
Ludovic Courtès c17b5ab4db tests: Skip tests that would hit the shebang length limitation.
* tests/gexp.scm (shebang): New variable.
  Skip "gexp->script" when SHEBANG is longer than 127 chars.
* guix/gexp.scm (gexp->script): Add comment on the issue.
2014-06-04 18:15:50 +02:00
Ludovic Courtès b53be755e4 derivations: Add #:allowed-references 'derivation' parameter.
* guix/derivations.scm (derivation): Add #:allowed-references
  parameter.
  [user+system-env-vars]: Honor it.
* tests/derivations.scm ("derivation #:allowed-references, ok",
  "derivation #:allowed-references, not allowed",
  "derivation #:allowed-references, self allowed",
  "derivation #:allowed-references, self not allowed"): New tests.
* doc/guix.texi (Derivations): Document #:allowed-references.
2014-06-01 23:32:26 +02:00
Ludovic Courtès 35066aa596 syscalls: Be more permissive in 'umount' test.
* tests/syscalls.scm ("umount, ENOENT"): Rename to...
  ("umount, ENOENT/EPERM"): ... this.  Accept EPERM as a valid return
  value.
2014-05-27 22:36:54 +02:00
Ludovic Courtès 52ddf2ae6f ui: Gracefully deal with zero-output derivations.
* guix/ui.scm (show-what-to-build)[built-or-substitutable?]: New
  procedure.  Check whether OUT is #f.
  Use it.
* tests/ui.scm ("show-what-to-build, zero outputs"): New test.
2014-05-19 23:52:40 +02:00
Ludovic Courtès 29fa45f45d Add (guix build syscalls).
* guix/build/syscalls.scm, tests/syscalls.scm: New files.
* Makefile.am (MODULES): Add guix/build/syscalls.scm.
  (SCM_TESTS): Add tests/syscalls.scm.
* guix/utils.scm (%libc-errno-pointer, errno): Remove; take from (guix
  build syscalls).
2014-05-10 22:55:34 +02:00
Ludovic Courtès 79c0c8cdf7 gexp: Add support for 'origin?' objects in 'ungexp' forms.
* guix/gexp.scm (lower-inputs, gexp-inputs, gexp->sexp,
  canonicalize-reference): Add 'origin?' case.
* guix/monads.scm (origin->derivation): New procedure.
* tests/gexp.scm ("one input origin"): New test.
2014-05-01 22:31:36 +02:00
Ludovic Courtès ada3df03e3 monads: Hide 'derivation-expression' and 'lower-inputs'.
* guix/monads.scm: Unexport 'lower-inputs' and 'derivation-expression'.
  (text-file*): Add comment about the switch to 'gexp->derivation'.
  (lower-inputs): Add comment about its doom.
  (derivation-expression): Likewise.
* guix/gexp.scm (lower-inputs*): Rename to...
  (lower-inputs): ... this.  Update callers.
* tests/monads.scm (derivation-expression): New procedure.
* doc/guix.texi (The Store Monad): Use 'gexp->derivation' instead of
  'derivation-expression'.  Remove documentation of
  'derivation-expression'.
* guix/ui.scm (read/eval): Use THE-ROOT-MODULE so that macros are
  properly expanded.
* tests/guix-build.sh: Use 'gexp->derivation' instead of
  'derivation-expression'.monads: Hide 'derivation-expression' and 'lower-inputs'.
2014-04-28 23:41:12 +02:00
Ludovic Courtès eee2127109 store: (direct-store-path? (%store-prefix)) returns #f.
* guix/store.scm (direct-store-path?): Return #f if PATH
  is (%store-prefix).
* tests/store.scm ("direct-store-path?"): Add test.
2014-04-28 23:24:18 +02:00
Ludovic Courtès 21b679f694 Add (guix gexp).
* guix/gexp.scm: New file.
* tests/gexp.scm: New file.
* Makefile.am (MODULES): Add guix/gexp.scm.
  (SCM_TESTS): Add tests/gexp.scm.
* doc/guix.texi (Derivations): Add #:inputs in 'derivation' example.
  Mark 'build-expression->derivation' as deprecated, refer to
  "G-Expressions".  Remove paragraph about code strata.
  (G-Expressions): New node.
2014-04-28 23:24:17 +02:00
Ludovic Courtès 6f69588529 authenticate: Allow signatures with binary data to be written to stdout.
Fixes <http://bugs.gnu.org/17312>.

* guix/scripts/authenticate.scm (guix-authenticate): Add calls to
  'set-port-encoding!' and 'set-port-conversion-strategy!'.  Wrap body
  in 'with-fluids' form that sets '%default-port-encoding' and
  '%default-port-conversion-strategy'.
* tests/guix-authenticate.sh: Add test.
* tests/pk-crypto.scm ("hash corrupt due to restrictive locale
  encoding"): Add reference to bug.
2014-04-22 11:30:58 +02:00
Ludovic Courtès 6030d8493e pk-crypto: Use ISO-8859-1 for strings passed to 'gcry_sexp_new'.
* guix/pk-crypto.scm (string->canonical-sexp): Pass "ISO-8859-1" as the
  2nd argument to 'string->pointer'.
* tests/pk-crypto.scm ("version"): New test.
  ("hash corrupt due to restrictive locale encoding"): New test.
2014-04-22 01:39:31 +02:00
Ludovic Courtès 30ce8012cd offload: '{send,receive}-files' wait for completion of the transfer.
Fixes situations where the remote 'guix build' is invoked before the
.drv has been completely copied, as reported at
<https://lists.gnu.org/archive/html/guix-devel/2014-04/msg00174.html>.

In some cases 'send-files' would return before the other end is done
importing the files, and so the subsequent 'guix build' invocation would
just miss the .drv file it refers to.

* guix/utils.scm (call-with-decompressed-port): Don't close PORT.
  (call-with-compressed-output-port): Likewise.
* tests/utils.scm ("compressed-output-port + decompressed-port"): Adjust
  accordingly.
* guix/scripts/offload.scm (send-files): Add explicit (close-pipe pipe)
  call.
  (retrieve-files): Likewise.
2014-04-14 00:24:24 +02:00
Ludovic Courtès 99e17dc927 derivations: Fix 'fixed-output-derivation?'.
Reported by Nikita Karetnikov <nikita@karetnikov.org>.

* guix/derivations.scm (fixed-output-derivation?): Fix pattern.
* tests/derivations.scm ("fixed-output-derivation?"): Add test.
2014-04-13 00:42:07 +02:00
Ludovic Courtès a9d2a10546 store: Add 'add-permanent-root' and 'remove-permanent-root'.
* guix/store.scm (add-indirect-root): Improve docstring.
  (%gc-roots-directory): New variable.
  (add-permanent-root, remove-permanent-root): New procedures.
* tests/store.scm ("permanent root"): New test.
2014-04-12 22:32:10 +02:00
Ludovic Courtès 1d6243cf70 ui: Add 'size->number'.
* guix/scripts/gc.scm (size->number): Remove.
* guix/ui.scm (size->number): New procedure.
* tests/ui.scm ("size->number, bytes",
  "size->number, MiB", "size->number, GiB", "size->number, 1.2GiB",
  "size->number, invalid unit"): New tests.
2014-04-08 22:01:44 +02:00
Ludovic Courtès 68ec0450d1 tests: Avoid buffering in 'fcntl-flock' tests.
Partially fixes <http://bugs.gnu.org/17212>.

* tests/utils.scm ("fcntl-flock wait", "fcntl-flock non-blocking"): Open
  files in binary mode, with no buffering.
2014-04-07 18:16:58 +02:00
Ludovic Courtès a53a9aed93 tests: Add 'union-build' test for <http://bugs.gnu.org/17083>.
* tests/union.scm ("union-build with symlink to directory"): New test.
2014-04-02 23:08:44 +02:00
Mark H Weaver 1212999868 union: Rewrite to be faster; handle symlink/directory conflicts.
* guix/build/union.scm: Rewrite; only 'file=?' remains unchanged.  Remove
  'tree-union' and 'delete-duplicate-leaves' exports.  Merge inputs in a
  breadth-first fashion.  Follow symlinks for purposes of making decisions
  about the merge.

* tests/union.scm: Remove tests of 'tree-union' and 'delete-duplicate-leaves'.
2014-04-02 15:31:46 -04:00
Ludovic Courtès d2952326ae guix package: Register non-default profiles as GC roots.
* guix/scripts/package.scm (maybe-register-gc-root): New procedure.
* tests/guix-package.sh (profile): Grep the output of "guix gc
  --list-live" in a couple of places.
2014-04-02 16:07:40 +02:00
Ludovic Courtès e4687a5e68 Use 'signature-case' in (guix nar) and 'substitute-binary'.
* guix/nar.scm (restore-file-set)[assert-valid-signature]: Rewrite in
  terms of 'signature-case'.
* guix/scripts/substitute-binary.scm (narinfo-signature->canonical-sexp):
  Call 'leave' instead of 'raise' when SIGNATURE is invalid.
  (&nar-signature-error, &nar-invalid-hash-error): Remove.
  (assert-valid-signature): Add 'narinfo' parameter; remove 'port'.
  Rewrite in terms of 'signature-case' and 'leave'.  Mention NARINFO's
  URI in error messages.  Adjust caller.
  (narinfo-sha256): New procedure.
  (assert-valid-narinfo): Use it.
  (valid-narinfo?): Rewrite using 'narinfo-sha256' and
  'signature-case'.
* tests/substitute-binary.scm (assert-valid-signature,
  test-error-condition): Remove.
  ("corrupt signature data", "unauthorized public key", "invalid
  signature"): Remove.
2014-03-31 23:47:02 +02:00
Ludovic Courtès 81deef270d pki: Add 'signature-case' macro.
* guix/pki.scm (%signature-status): New procedure.
  (signature-case): New macro.
* tests/pki.scm (%secret-key, %alternate-secret-key): New variables.
  ("signature-case valid-signature", "signature-case invalid-signature",
  "signature-case hash-mismatch", "signature-case unauthorized-key",
  "signature-case corrupt-signature"): New tests.
2014-03-31 23:34:20 +02:00
Ludovic Courtès f84f859093 tests: Test the error output of 'substitute-binary'.
* tests/substitute-binary.scm (test-error*): Rename to...
  (test-quit): ... this.  Add 'error-rx' parameter and honor it.
  ("not a number", "wrong version number", "substitute, no signature",
  "substitute, invalid hash", "substitute, unauthorized key"): Adjust
  accordingly.
2014-03-30 22:32:16 +02:00
Ludovic Courtès e903b7c1a8 tests: Add more signed substitute tests.
* tests/substitute-binary.scm (%narinfo): Set 'URL', 'Compression', and
  'NarHash'.
  (call-with-narinfo): Create 'example.out' and 'example.nar'.
  ("query narinfo without signature", "substitute, no signature",
  "substitute, authorized key"): New tests.
2014-03-30 22:32:16 +02:00
Ludovic Courtès 52f80dfc8a tests: Simplify 'substitute-binary' tests; reduce use of global variables.
* tests/substitute-binary.scm (signature-body): Change 'str' parameter
  to 'bv', and expect it to be a bytevector.
  (%signature-body, %wrong-signature, %acl): Remove.
  (signature): Rename to...
  (signature-field): ... this.  Add 'bv-or-str' parameter.  Change 'str'
  parameter to #:version.  Add #:public-key parameter.  Call
  'signature-body' directly.  Change domain part of the signature to
  'example.gnu.org'.
  ("not a number", "wrong version number", "valid
  narinfo-signature->canonical-sexp"): Use 'signature-field' instead of
  'signature' or %SIGNATURE.
  (test-error-condition): Add 'message-rx' parameter and honor it.
  ("corrupt signature data", "unauthorized public key", "invalid
  signature"): Adjust accordingly.
  (narinfo, %signed-narinfo): Remove.
  ("query narinfo with invalid hash"): Use '%narinfo' and
  'signature-field' instead of 'narinfo' and '%signature'.
  ("query narinfo signed with authorized key", "query narinfo signed
  with unauthorized key", "substitute, invalid hash", "substitute,
  unauthorized key"): Likewise.
2014-03-30 22:32:16 +02:00
Ludovic Courtès 491e6de7d6 tests: Make sure the daemon reports substitute hash mismatches.
* tests/store.scm ("substitute, corrupt output hash"): New test.
2014-03-30 22:32:16 +02:00
Ludovic Courtès cdea30e061 substitute-binary: Defer narinfo authentication and authorization checks.
* guix/scripts/substitute-binary.scm (narinfo-signature->canonical-sexp):
  Catch 'gcry-error' around 'string->canonical-sexp' call, and re-raise
  as a SRFI-35 &message and &nar-signature-error.
  (narinfo-maker): Handle when SIGNATURE is #f or an invalid canonical
  sexp.
  (&nar-signature-error, &nar-invalid-hash-error): New variables.
  (assert-valid-signature): Use them.  Expect 'signature' to be a
  canonical sexp.
  (read-narinfo): Remove authentication and authorization checks.
  (%signature-line-rx): New variable.
  (assert-valid-narinfo, valid-narinfo?): New procedures.
  (guix-substitute-binary): Wrap body in 'with-error-handling'.
  [valid?]: New procedure.
  <--query>: Show only store items of narinfos that match
  'valid-narinfo?'.
  <--substitute>: Call 'assert-valid-narinfo'.
* tests/substitute-binary.scm (test-error*): Use 'test-equal'.
  (%keypair): Remove.
  (%public-key, %private-key): Load from signing-key.{pub,sec}.
  (signature-body): Add #:public-key parameter.
  (call-with-narinfo): New procedure.
  (with-narinfo): New macro.
  ("corrupt signature data", "unauthorized public key", "invalid
  signature"): Make the first argument to 'assert-valid-signature' a
  canonical sexp.
  ("invalid hash", "valid read-narinfo", "valid write-narinfo"):
  Remove.
  ("query narinfo with invalid hash", "query narinfo signed with
  authorized key", "query narinfo signed with unauthorized key",
  "substitute, invalid hash", "substitute, unauthorized key"): New
  tests.
2014-03-30 22:32:11 +02:00
Nikita Karetnikov e9c6c58418 substitute-binary: Support the Signature field of a narinfo file.
* guix/scripts/substitute-binary.scm (<narinfo>): Add the 'signature'
  and 'contents' fields.
  (narinfo-signature->canonical-sexp): New function.
  (narinfo-maker): Add the 'signature' argument and use it.
  (assert-valid-signature): New function.
  (read-narinfo): Support the Signature field.
  (write-narinfo): Use 'narinfo-contents'.
  (%allow-unauthenticated-substitutes?): New variable.
* guix/base64.scm, tests/base64.scm, tests/substitute-binary.scm: New files.
* Makefile.am (SCM_TESTS): Add tests/base64.scm and
  tests/substitute-binary.scm.
  (MODULES): Add guix/base64.scm.
* test-env.in: Set 'GUIX_ALLOW_UNAUTHENTICATED_SUBSTITUTES'.
2014-03-30 12:02:10 +02:00
Ludovic Courtès e4629ef43b tests: Make sure 'guix archive --import' succeeds.
* tests/guix-archive.sh: Check the exit value of 'guix archive
  --import'.
2014-03-29 22:59:46 +01:00
Ludovic Courtès c9e2b0b16e daemon: Add tests for substitutes and --no-substitutes.
* tests/guix-daemon.sh: Add substituter tests.
2014-03-27 23:56:47 +01:00
Ludovic Courtès 4979ee04f0 Merge branch 'core-updates' 2014-03-26 16:31:57 +01:00
Ludovic Courtès 01ac19dca4 utils: Add 'call-with-decompressed-port' and 'call-with-compressed-output-port'.
* guix/utils.scm (call-with-decompressed-port,
  call-with-compressed-output-port): New procedures.
* tests/utils.scm ("compressed-output-port + decompressed-port"):
  Rewrite to use them.
2014-03-24 22:15:29 +01:00
Ludovic Courtès 80dea563a3 utils: Add 'filtered-output-port' and 'compressed-output-port'.
* guix/utils.scm (filtered-output-port, compressed-output-port): New
  procedures.
* tests/utils.scm ("compressed-output-port + decompressed-port"): New
  test.
2014-03-24 21:09:15 +01:00
Ludovic Courtès 1950bf56d0 tests: Make sure substitutes are usable when we need them.
* tests/derivations.scm ("derivation-prerequisites-to-build and
  substitutes"): Add call to 'set-build-options'.
2014-03-22 22:57:10 +01:00
Ludovic Courtès 9b0a2233db authenticate: Support reading the hash or key from stdin.
* guix/scripts/authenticate.scm (guix-authenticate): Add clauses
  for ("rsautl" "-sign" "-inkey" key) and ("rsautl" "-verify" "-inkey" _
  "-pubin").
* tests/guix-authenticate.sh (hash): Add test using -sign and -verify in
  a pipeline.
2014-03-22 22:57:10 +01:00
Ludovic Courtès 7a8024a33a utils: Add 'decompressed-port' and 'compressed-port'.
* guix/utils.scm (decompressed-port, compressed-port): New procedures.
* guix/scripts/substitute-binary.scm (decompressed-port): Remove.
  (guix-substitute-binary): Pass a symbol or #f as the first argument to
  'decompress-port'.
* tests/utils.scm ("compressed-port, decompressed-port, non-file"): New
  test.
2014-03-22 22:57:09 +01:00
Ludovic Courtès 443eb4e950 utils: 'filtered-port' doesn't leave dangling processes behind.
* guix/utils.scm (filtered-port): Make sure the 'execl' child process
  always exits, and does (primitive-_exit 1) upon execution failure.
  Use 'primitive-_exit' in the 'dump-port' child process.
* tests/utils.scm ("filtered-port, does not exist"): New test.
2014-03-22 22:57:09 +01:00
Mark H Weaver 1eefbb2693 Merge branch 'master' into core-updates 2014-03-22 11:19:19 -04:00
Ludovic Courtès 1fda6840a8 pk-crypto: Don't use Ed25519 when libgcrypt is older than 1.6.0.
* guix/pk-crypto.scm (gcrypt-version): New procedure.
* guix/scripts/archive.scm (%key-generation-parameters): New variable.
  (%options) <generate-key>: Use it.
* tests/pk-crypto.scm ("sign + verify, Ed25519"): Skip if using gcrypt < 1.6.0.
2014-03-20 23:06:47 +01:00
Ludovic Courtès 32a1eb8025 pk-crypto: Use RFC6979 when signing with an ECC or DSA key.
* guix/pk-crypto.scm (bytevector->hash-data): Add #:key-type parameter.
  Use the 'pkcs1' flag when KEY-TYPE is 'rsa', and 'rfc6979' when
  KEY-TYPE is 'ecc' or 'dsa'.
  (key-type): New procedure.
* guix/scripts/authenticate.scm (read-hash-data): Add 'key-type'
  parameter.  Pass it to 'bytevector->hash-data'.  Adjust caller
  accordingly.
* tests/pk-crypto.scm (%ecc-key-pair): New variable.
  ("key-type"): New test.
  ("sign + verify"): Pass #:key-type to 'bytevector->hash-data'.
  ("sign + verify, Ed25519"): New test.
2014-03-19 21:40:10 +01:00
Ludovic Courtès e297d8fc56 tests: Test recovery from 'valid-path?' RPCs with an invalid parameter.
* tests/store.scm ("valid-path? live", "valid-path? false", "valid-path?
  error", "valid-path? recovery"): New tests.
2014-03-19 00:00:29 +01:00
Ludovic Courtès aa2480e50d build: Fix test failures due to the nix -> guix directory name change.
Reported by Nikita Karetnikov <nikita@karetnikov.org>
and Pierre-Antoine Rault <par@rigelk.eu>.

* test-env.in: Change 'NIX_LOG_DIR' in accordance with f5768af.
* tests/guix-register.sh: Likewise for 'NIX_LOG_DIR' and 'NIX_DB_DIR'.
2014-03-17 23:30:42 +01:00
Ludovic Courtès 0562dbe5d3 Merge branch 'master' into core-updates 2014-03-17 18:26:46 +01:00
Ludovic Courtès 11e7a6cf46 store: Add 'hash-part->path'.
* guix/store.scm (hash-part->path): New procedure.
* tests/store.scm ("hash-part->path"): New test.
2014-03-14 17:16:10 +01:00
Ludovic Courtès e06f7865e2 Merge branch 'master' into core-updates 2014-03-10 23:54:17 +01:00
Ludovic Courtès 58cbbe4b55 tests: 'topologically-sorted' test handles different references orders.
* tests/store.scm ("topologically-sorted, more difficult"): Arrange to
  handle a different ordering of (references %store y).
2014-03-10 23:43:31 +01:00
Ludovic Courtès 6c20d1d0c3 store: Add #:timeout build option.
* guix/serialization.scm (write-string-pairs): New procedure.
* guix/store.scm (write-arg): Add 'string-pairs' case.
  (set-build-options): Add 'timeout' keyword parameter.  Honor it.
* tests/derivations.scm ("build-expression->derivation and timeout"):
  New test.
2014-03-09 23:01:18 +01:00
Ludovic Courtès c7445833eb utils: Add a non-blocking option for 'fcntl-flock'.
* guix/utils.scm (F_SETLK): New variable.
  (fcntl-flock): Add 'wait?' keyword parameter; honor it.
* tests/utils.scm ("fcntl-flock non-blocking"): New test.
2014-03-08 00:18:22 +01:00
Ludovic Courtès cafb92d853 store: 'export-paths' doesn't export references of the given files.
This fixes a regression introduced in
99fbddf9a6 ("store: Change 'export-paths'
to always export in topological order.")

* guix/store.scm (export-paths): Define 'ordered' variable.  Iterate
  over it.
* tests/store.scm ("export/import paths, ensure topological order"): Add
  'file0'.  Adjust accordingly.
2014-03-07 00:19:03 +01:00
Ludovic Courtès 827d556311 tests: Rewrite 'fcntl-lock' test.
* tests/utils.scm (temp-file): New variable.
  ("fcntl-flock"): Rewrite to actually test whether the child process
  waits for the lock to be released.  The previous test was wrong
  because (1) it expected F_SETLK semantics, not F_SETLKW, and (2) it
  got EBADF because of a mismatch between the open mode and the lock
  style.
2014-03-06 21:42:24 +01:00
Ludovic Courtès b2bfa32d25 Merge branch 'master' into core-updates
Conflicts:
	gnu-system.am
2014-02-22 00:27:57 +01:00
Ludovic Courtès 96c7448f37 nar: Produce archives with files sorted in C collation order.
* guix/nar.scm (write-file) <directory>: Pass 'string<?' as the second
  argument to 'scandir'.
* tests/nar.scm ("write-file puts file in C locale collation order"):
  New test.
2014-02-21 23:49:53 +01:00
Ludovic Courtès 36bbbbd150 derivations: Add support for recursive fixed-output derivations.
* guix/derivations.scm (<derivation-output>): Add 'recursive?' field.
  Adjust 'make-derivation-output' callers.
  (%read-derivation) <fixed-output>: When HASH-ALGO starts with 'r:',
  set the 'recursive?' field and drop 'r:' from the hash algo name.
  (write-derivation)[write-output]: Write the algo as 'r:HASH-ALGO' when
  the RECURSIVE? field is set.
  (derivation-hash) <fixed-output>: Prepend "r:" when RECURSIVE? is set.
  (fixed-output-path): New procedure.
  (derivation): Add #:recursive? parameter.  Use 'fixed-output-path' to
  compute the output file name of a fixed output derivation.
  (build-expression->derivation): Add #:recursive? parameter.  Pass it
  to 'derivation'.
* tests/derivations.scm ("fixed-output derivation, recursive",
  "build-expression->derivation produces recursive fixed-output",
  "build-expression->derivation uses recursive fixed-output"): New
  tests.
* doc/guix.texi (Derivations): Document #:recursive? for 'derivation'.
  Add #:recursive? for 'build-expression->derivation'.
2014-02-21 23:49:52 +01:00
Ludovic Courtès 3140f2df42 guix hash: Add '--recursive'.
* guix/scripts/hash.scm (show-help): Add --recursive.
  (%options): Likewise.
  (guix-hash)[file-hash]: New procedure.  Honor --recursive.
  Use it.
* guix/nar.scm (write-file): Add missing field to the &nar-error
  condition raised upon unsupported file type; change its message to be
  more descriptive.
* tests/guix-hash.sh: Add tests with -r.
* doc/guix.texi (Invoking guix hash): Document --recursive.
2014-02-21 23:49:52 +01:00
Ludovic Courtès a93e91ff48 nar: 'write-file' can write to non-file ports.
* guix/nar.scm (write-contents): Use 'sendfile' only when P is a file
  port.
* tests/nar.scm ("write-file supports non-file output ports"): New test.
2014-02-21 23:49:52 +01:00
Ludovic Courtès 99fbddf9a6 store: Change 'export-paths' to always export in topological order.
* guix/store.scm (export-paths): Pass PATHS through
  'topologically-sorted' before iterating.
* tests/store.scm ("export/import paths, ensure topological order"): New
  test.
2014-02-10 23:36:42 +01:00
Ludovic Courtès 45adbd624f monads: Add 'text-file*'.
* guix/monads.scm (text-file*): New procedure.
* tests/monads.scm ("text-file*"): New test.
* doc/guix.texi (The Store Monad): Change example since the previous one
  would erroneously fail to retain a reference to Coreutils.  Document
  'text-file*'.
2014-02-03 23:20:49 +01:00
Ludovic Courtès ecb1b610d2 tests: Adjust to recent Binutils change.
* tests/guix-package.sh: Refer to 'glibc:debug' instead of
  'binutils:lib' since the latter no longer exists.
2014-01-25 17:23:23 +01:00
Ludovic Courtès 50add47748 store: Add 'topologically-sorted'.
* guix/store.scm (topologically-sorted): New procedure.
* tests/store.scm ("topologically-sorted, one item",
  "topologically-sorted, several items", "topologically-sorted, more
  difficult"): New tests.
2014-01-24 00:01:50 +01:00
Ludovic Courtès cd4027fa47 nar: Add 'restore-file-set', for use by build hooks.
* guix/nar.scm (&nar-invalid-hash-error, &nar-signature-error): New
  condition types.
  (&nar-error): Add 'file' and 'port' fields.
  (&nar-read-error): Remove 'port' and 'file' fields.
  (lock-store-file, unlock-store-file, finalize-store-file,
  temporary-store-directory, restore-file-set): New procedures.
* tests/nar.scm (%seed): New variable.
  (random-text): New procedure.
  ("restore-file-set (signed, valid)", "restore-file-set (missing
  signature)", "restore-file-set (corrupt)"): New tests.
* po/Makevars (XGETTEXT_OPTIONS): Add '--keyword=message'.nar fixes
* po/POTFILES.in: Add guix/nar.scm.
2014-01-24 00:01:50 +01:00
Ludovic Courtès 045111e10c hash: Add 'open-sha256-input-port', for Guile > 2.0.9.
* guix/hash.scm (open-sha256-input-port): New procedure.
* tests/hash.scm (supports-unbuffered-cbip?): New procedure.
  ("open-sha256-input-port, empty", "open-sha256-input-port, hello",
  "open-sha256-input-port, hello, one two",
  "open-sha256-input-port, hello, read from wrapped port"): New tests.
2014-01-24 00:01:49 +01:00
Ludovic Courtès 2cd5c0380e utils: Add 'fcntl-flock'.
* guix/utils.scm (%struct-flock, F_SETLKW, F_xxLCK): New variables.
  (fcntl-flock): New procedure.
* tests/utils.scm ("fcntl-flock"): New test.
2014-01-24 00:01:49 +01:00
Ludovic Courtès 6bfec3edf5 store: Add 'register-path' procedure.
* guix/store.scm (register-path): New procedure.
* tests/store.scm ("register-path"): New test.
* guix/config.scm.in (%guix-register-program): New variable.
* configure.ac: Compute and substitute 'guix_sbindir'.  Compute
  'guix_prefix'.
* pre-inst-env.in: Define 'GUIX_REGISTER'.
2014-01-24 00:01:49 +01:00
Ludovic Courtès 349fd3b11f guix-register: Support registration in the current store, without '--prefix'.
* nix/guix-register/guix-register.cc (register_validity): Leave
  'info.path' unmodified when PREFIX is empty.
  (main): Call 'settings.processEnvironment' early on.
  Leave 'settings.nixStore' unmodified when PREFIX is empty.
2014-01-24 00:01:49 +01:00
Ludovic Courtès 87236aed77 archive: Add '--missing'.
* guix/scripts/archive.scm (show-help, %options): Add '--missing'.
  (guix-archive)[lines]: New procedure.
  Use it to honor '--missing'.
* tests/guix-archive.sh: Add tests.
* doc/guix.texi (Invoking guix archive): Document '--missing'.
2014-01-06 22:25:29 +01:00
Ludovic Courtès 1a43e4dc57 guix package: Gracefully deal with EPIPE on stdout for --list-*.
* guix/scripts/package.scm (leave-on-EPIPE): New macro.
  (guix-package): Use it for 'list-installed', 'list-available', and
  '--list-generations'.
* tests/guix-package.sh: Add test.
2014-01-04 22:45:33 +01:00
Ludovic Courtès f82cc5fdbe archive: Add '--authorize'.
* guix/scripts/archive.scm (authorize-key): New procedure.
  (guix-archive): Call it when OPTS contains 'authorize-key'.
* tests/guix-archive.sh: Add test with invalid public key.
* guix/pki.scm: Export '%acl-file'.
* doc/guix.texi (Invoking guix archive): Make it clear that '--import'
  works only with authorized keys.  Document '--authorize'.
2013-12-30 23:18:52 +01:00
Ludovic Courtès dedb5d947e pk-crypto: Fix 'canonical-sexp->sexp' for atoms.
* guix/pk-crypto.scm (canonical-sexp->sexp): Add hack to extract an
  atom's buffer.
* tests/pk-crypto.scm ("sexp->canonical-sexp->sexp"): Add sample.
2013-12-30 22:29:12 +01:00
Ludovic Courtès 36341854df pk-crypto: Work around Libgcrypt bug <https://bugs.g10code.com/gnupg/issue1594>.
* guix/pk-crypto.scm (canonical-sexp-fold): Call 'nth-data' before
  'nth' to work around <https://bugs.g10code.com/gnupg/issue1594>.
* tests/pk-crypto.scm ("https://bugs.g10code.com/gnupg/issue1594"): New
  test.
2013-12-30 22:19:19 +01:00
Ludovic Courtès 8b420f74e4 Add (guix pki).
* guix/pki.scm, tests/pki.scm: New files.
* Makefile.am (MODULES): Add 'guix/pki.scm'.
  (SCM_TESTS): Add 'tests/pki.scm'.
2013-12-29 15:57:24 +01:00
Ludovic Courtès 9501d7745e pk-crypto: Add canonical-sexp to sexp conversion procedures.
* guix/pk-crypto.scm (canonical-sexp-fold, canonical-sexp->sexp,
  sexp->canonical-sexp): New procedures.
* tests/pk-crypto.scm ("canonical-sexp->sexp",
  "sexp->canonical-sexp->sexp"): New tests.
2013-12-29 15:57:24 +01:00
Ludovic Courtès 363ae1da82 pk-crypto: Add 'canonical-sexp-length' and related procedures.
* guix/pk-crypto.scm (canonical-sexp-length, canonical-sexp-null?,
  canonical-sexp-list?): New procedures.
* tests/pk-crypto.scm ("canonical-sexp-length", "canonical-sexp-list?"):
  New tests.
2013-12-29 15:57:24 +01:00
Ludovic Courtès a2cbbb743d pk-crypto: 'canonical-sexp-nth-data' returns a symbol for "tokens".
* guix/pk-crypto.scm (token-string?): New procedure.
  (canonical-sexp-nth-data): Return a symbol when the element is a
  "token", and a bytevector otherwise.
  (latin1-string->bytevector): Remove.
  (hash-data->bytevector): Adjust accordingly.
* tests/pk-crypto.scm ("canonical-sexp-nth"): Adjust accordingly.  Add
  octet string example.
2013-12-29 15:57:23 +01:00
Ludovic Courtès 6df1fb8991 authenticate: Store the public key as part of the signature.
* guix/scripts/authenticate.scm (signature-sexp): New procedure.
  (guix-authenticate): Use it to produce the signature.  Adjust
  verification code accordingly.
* tests/store.scm ("import corrupt path"): Adjust test accordingly.
2013-12-29 15:57:23 +01:00
Ludovic Courtès b0a33ac157 pk-crypto: Rename 'gcry-sexp' to 'canonical-sexp'.
* guix/pk-crypto.scm: Rename procedures, variables, etc. from
  'gcry-sexp' to 'canonical-sexp'.  Add comment with references.
* guix/scripts/authenticate.scm, tests/pk-crypto.scm: Adjust
  accordingly.
2013-12-29 15:57:23 +01:00
Ludovic Courtès 760c60d684 Add 'guix archive'.
* guix/scripts/archive.scm, tests/guix-archive.sh: New files.
* Makefile.am (MODULES): Add 'archive.scm'.
  (SH_TESTS): Add 'guix-archive.sh'.
* doc/guix.texi (Invoking guix archive): New section.
* guix/scripts/build.scm: Export 'derivation-from-expression'.
* guix/scripts/package.scm: Export 'specification->package+output'.
2013-12-22 01:08:21 +01:00
Ludovic Courtès 0820098d1c authenticate: Add test.
* tests/guix-authenticate.sh: New file.
* Makefile.am (SH_TESTS): Add it.
2013-12-21 21:47:17 +01:00
Ludovic Courtès 0a66781eee build: Adjust pk-crypto tests to Libgcrypt 1.5.3.
Reported by Andreas Enge <andreas@enge.fr>.

* tests/pk-crypto.scm ("string->gcry-sexp->string"): Remove "#C0FFEE#"
  from SEXPS.
  ("gcry-sexp-nth"): Start at index 1.
2013-12-21 00:10:09 +01:00
Ludovic Courtès 526382ff92 daemon: Implement signed archive import/export.
* guix/scripts/authenticate.scm, nix/scripts/guix-authenticate.in,
  tests/signing-key.pub, tests/signing-key.sec: New files.
* po/POTFILES.in: Add 'guix/scripts/authenticate.scm'.
* guix/store.scm (dump-port): New procedure.
  (process-stderr): Add 'user-port' optional parameter.  Handle
  the %STDERR-WRITE and %STDERR-READ cases as expected.
  (import-paths, export-path, export-paths): New procedures.
* tests/store.scm ("export/import several paths", "import corrupt
  path"): New tests.
* Makefile.am (MODULES): Add 'guix/scripts/authenticate.scm'.
  (EXTRA_DIST): Add 'tests/signing-key.{pub,sec}'.
* daemon.am (libstore_a_CPPFLAGS)[-DNIX_CONF_DIR]: Change 'NIX_CONF_DIR'
  to .../guix.  Change 'OPENSSL_PATH' to 'guix-authenticate'.
* config-daemon.ac: Instantiate 'nix/scripts/guix-authenticate'.
* nix/nix-daemon/guix-daemon.cc (main): Augment $PATH to include
  'settings.nixLibexecDir'.
* test-env.in: Export 'NIX_CONF_DIR' and 'NIX_LIBEXEC_DIR'.  Populate
  $NIX_CONF_DIR.
2013-12-20 17:17:42 +01:00
Ludovic Courtès ce507041f7 pk-crypto: Add a few sexp utility procedures.
* guix/pk-crypto.scm (gcry-sexp-car, gcry-sexp-cdr, gcry-sexp-nth,
  gcry-sexp-nth-data, dereference-size_t, latin1-string->bytevector,
  hash-data->bytevector): New procedures.
* tests/pk-crypto.scm ("gcry-sexp-car + cdr", "gcry-sexp-nth",
  "gcry-sexp-nth-data", "bytevector->hash-data->bytevector"): New tests.
2013-12-20 15:22:15 +01:00
Ludovic Courtès 3476ded934 Add (guix pk-crypto).
* guix/pk-crypto.scm, tests/pk-crypto.scm: New files.
* Makefile.am (MODULES, SCM_TESTS): Add them.
2013-12-20 00:36:26 +01:00
Mark H Weaver 6447738c01 guix package: allow multiple arguments after -i, -r, and -u.
* guix/scripts/package.scm (%options): Adapt option processors to accept and
  return a second seed value: 'arg-handler', which handles bare arguments (if
  not false).  The install, remove, and upgrade option processors return an
  arg-handler that repeat the same operation.  All other option processors
  return #f as the arg-handler.  Make the arguments to install and remove
  optional.  The upgrade option processor deletes (upgrade . #f) from the
  alist before adding a new entry.
  (guix-package): Procedures passed to 'args-fold*' accept the new seed value
  'arg-handler'.  The 'operand-proc' uses 'arg-handler' (if not false).

* doc/guix.texi (Invoking guix package): Update docs.

* tests/guix-package.sh: Add test.
2013-12-14 16:25:02 -05:00
Ludovic Courtès b29f947d22 build: Skip one 'package-source-derivation' test when networking is missing.
* tests/packages.scm ("package-source-derivation, snippet"): Skip when
  networking is missing.
2013-12-11 13:55:49 +01:00
Ludovic Courtès c61a5b4a6d store: Add tests for 'store-path-package-name'.
* tests/store.scm ("store-path-package-name", "store-path-package-name
  #f"): New tests.
2013-12-11 00:18:14 +01:00
Ludovic Courtès 593c3fe600 monads: Fix 'anym'.
* guix/monads.scm (anym): Fix successful case.
* tests/monads.scm ("anym"): New test.
2013-12-10 00:24:01 +01:00
Ludovic Courtès dd1a5a152c derivations: Use more keyword parameters for 'build-expression->derivation'.
* guix/derivations.scm (build-expression->derivation): Turn 'system' and
  'inputs' into keyword parameters.
  Adjust callers accordingly.
* gnu/system/linux.scm, gnu/system/vm.scm, guix/build-system/cmake.scm,
  guix/build-system/gnu.scm, guix/build-system/perl.scm,
  guix/build-system/python.scm, guix/build-system/trivial.scm,
  guix/download.scm, guix/packages.scm, guix/profiles.scm,
  guix/scripts/pull.scm, tests/derivations.scm, tests/guix-build.sh,
  tests/monads.scm, tests/store.scm, tests/union.scm: Adjust users of
  'build-expression->derivation' and 'derivation-expression'
  accordingly.
* doc/guix.texi (Derivations): Adjust 'build-expression->derivation'
  documentation accordingly.
  (The Store Monad): Likewise for 'derivation-expression'.
2013-12-04 16:07:53 +01:00
Ludovic Courtès edae5b3d50 Merge branch 'master' into core-updates
Conflicts:
	guix/packages.scm
2013-11-20 23:51:26 +01:00
Ludovic Courtès 0b8749b7bd packages: 'package-field-location' returns a relative file name.
* guix/packages.scm (package-field-location): Set
  %FILE-PORT-NAME-CANONICALIZATION.
* tests/packages.scm ("package-field-location, relative file name"): New
  test.
2013-11-18 23:56:07 +01:00
Ludovic Courtès ac5de156ae guix build: '-e' can be passed a monadic thunk.
* guix/ui.scm (read/eval): New procedure.
  (read/eval-package-expression): Use it.
* guix/scripts/build.scm (derivations-from-package-expressions): Rename to...
  (derivation-from-expression): ... this.  Accept procedures, under the
  assumption that they are monadic thunk.
  (show-help): Adjust accordingly.
  (guix-build): Ditto.
* tests/guix-build.sh: Add test.
* doc/guix.texi (Invoking guix build): Augment description of '-e'.
2013-11-18 23:08:20 +01:00
Ludovic Courtès 127ed6a9dd tests: Adjust to bootstrap tarball updates.
Reported by Mark H. Weaver <mhw@netris.org>.

* tests/packages.scm ("package-source-derivation, snippet"): Change to
  "guile-2.0.9.tar.xz".
* tests/union.scm ("union-build"): Check or include/c++ being a symlink.
2013-11-16 22:10:03 +01:00
Ludovic Courtès a716e36de9 derivations: Allow 'map-derivations' to replace sources.
* guix/derivations.scm (map-derivation)[input->output-paths]: Allow
  non-derivation inputs.
  Allow replacements to be store files.  Replace in SOURCES too.
* tests/derivations.scm ("map-derivation, sources"): New test.
2013-11-13 11:22:07 +01:00
Ludovic Courtès f80594cc41 packages: Suitably cope with indirect store paths as package sources.
* guix/packages.scm (package-source-derivation): Don't let indirect
  store paths pass through.
* tests/packages.scm ("package-source-derivation, indirect store path"):
  New test.
2013-11-13 00:29:05 +01:00
Ludovic Courtès 9336e5b5e7 store: Make 'direct-store-path?' public.
* guix/store.scm (direct-store-path?): New procedure.
* guix/derivations.scm (derivation)[direct-store-path?]: Remove.
* tests/store.scm ("direct-store-path?"): New test.
2013-11-13 00:29:05 +01:00
Ludovic Courtès e387ab7c10 derivations: Add 'map-derivation'.
* guix/derivations.scm (map-derivation): New procedure.
* tests/derivations.scm ("map-derivation"): New test.
2013-11-13 00:29:05 +01:00
Ludovic Courtès 56b943de6e utils: Add 'string-replace-substring'.
* guix/utils.scm (string-replace-substring): New procedure.  Based on
  code by Mark H. Weaver.
* tests/utils.scm ("string-replace-substring"): New test.
2013-11-13 00:29:05 +01:00
Ludovic Courtès bf4211523b guix build: Add '--log-file'.
* guix/scripts/build.scm (show-help): Add '--log-file'.
  (%options): Likewise.
  (guix-build): Set %FILE-PORT-NAME-CANONICALIZATION.  Honor '--log-file'.
* tests/guix-build.sh: Add '--log-file' tests.
* doc/guix.texi (Invoking guix build): Document '--log-file'.
2013-11-12 01:06:45 +01:00
Ludovic Courtès eddd4077a5 store: Add 'log-file' procedure.
* guix/store.scm (log-file): New procedure.
* tests/store.scm ("log-file, derivation", "log-file, output file
  name"): New tests.
2013-11-12 01:06:45 +01:00
Ludovic Courtès 7db9608d52 Merge branch 'master' into core-updates
Conflicts:
	guix/packages.scm
2013-11-08 21:58:09 +01:00
Ludovic Courtès f9cc897105 packages: Add a 'snippet' field to <origin>.
* guix/packages.scm (<origin>): Add 'snippet', 'modules', and
  'imported-modules' fields.
  (patch-and-repack): Make 'inputs' a keyword parameter.  Add 'snippet',
  'modules', and 'imported-modules' parameters.  Accept SOURCE as a raw
  file name.  Insert SNIPPET in BUILDER.  Pass IMPORTED-MODULES to
  'build-expression->derivation'.
  (package-source-derivation): Pass the extra arguments to
  'patch-and-repack'.
* tests/packages.scm ("package-source-derivation, snippet"): New test.
* doc/guix.texi (Defining Packages): Mention the 'patches' and 'snippet'
  fields.
  (Invoking guix build): Tell that --source has patches and snippets
  applied.
  (Software Freedom): Mention packages that contain non-free code.
2013-11-07 22:57:30 +01:00
Ludovic Courtès 01e82af55f tests: Fix max-silent-time test.
* tests/derivations.scm ("build-expression->derivation and
  max-silent-time"): Use STORE instead of %STORE.  Change BUILDER to
  succeed by default.  Return #f when no exception is raised.
2013-11-04 23:41:33 +01:00
Ludovic Courtès bde2d9cf8d tests: Add the builder as an input to raw derivations.
* tests/derivations.scm ("build derivation with 1 source",
  "derivation with local file as input",
  "derivation with a fixed-output input",
  "multiple-output derivation",
  "multiple-output derivation, non-alphabetic order",
  "user of multiple-output derivation"): Add %BASH as an input, needed
  in chroot builds.
2013-11-04 23:06:13 +01:00
Ludovic Courtès a20787706c guix package: Allow removal of a specific package output.
Fixes <http://bugs.gnu.org/15756>.

* guix/profiles.scm (<manifest-pattern>): New record type.
  (remove-manifest-entry): Remove.
  (entry-predicate, manifest-matching-entries): New procedures.
  (manifest-remove): Accept a list of <manifest-pattern>.
  (manifest-installed?): Replace 'name' parameter by 'pattern', a
  <manifest-pattern>.
* guix/scripts/package.scm (options->removable): Return a list of
  <manifest-pattern>.
  (guix-package)[process-action]: Use 'manifest-matching-entries' to
  compute the list of packages to remove.
* tests/profiles.scm: New file.
* Makefile.am (SCM_TESTS): Add it.
2013-11-01 23:21:01 +01:00
Ludovic Courtès 2876b98925 ui: Factorize package specification parsing.
* guix/ui.scm (package-specification->name+version+output): New
  procedure.
* guix/scripts/package.scm (specification->package+output): Use it.
* tests/ui.scm ("package-specification->name+version+output"): New test.
2013-11-01 23:21:00 +01:00
Ludovic Courtès d0dc4907d6 derivations: 'derivation-path->output-path' honors the 'output' parameter.
* guix/derivations.scm (derivation-path->output-path): Pass OUTPUT.
* tests/derivations.scm ("multiple-output derivation,
  derivation-path->output-path"): New test.
2013-10-30 22:09:32 +01:00
Ludovic Courtès 59fbeb8cae records: define-record-type*: Field bindings are bound with 'let*'.
* guix/records.scm (define-record-type*): Wrap field bindings in a
  'let*', not in a 'letrec*', which turned out to be pointlessly
  inconvenient.
* tests/records.scm: Adjust test names accordingly.
2013-10-15 23:31:22 +02:00
Ludovic Courtès aeb7ec5c9a monads: Allow resolution of a monad's bind/return at expansion time.
* guix/monads.scm (<monad>): Turn in a raw SRFI-9 record type.
  (define-monad): New macro.
  (with-monad): Add a case for when MONAD is a macro.
  (identity-return, identity-bind, store-return, store-bind): Inline.
  (%identity-monad, %store-monad): Use 'define-monad'.
* tests/monads.scm ("monad?"): New test.
2013-10-03 23:12:20 +02:00
Ludovic Courtès b860f38244 Add (guix monads).
* guix/monads.scm: New file.
* tests/monads.scm: New file.
* Makefile.am (MODULES): Add guix/monads.scm.
  (SCM_TESTS): Add tests/monads.scm.
* doc/guix.texi (The Store Monad): New node.
  (The Store): Reference it.
2013-10-03 23:12:20 +02:00
Ludovic Courtès d7ddb257c9 guix package: '--delete-generations' deletes generations older than specified.
* guix/scripts/package.scm (matching-generations): Add
  'duration-relation' keyword parameter.
  (guix-package)[process-action](delete-generations): Pass
  #:duration-relation >.
* tests/guix-package.sh: Add test.
* doc/guix.texi (Invoking guix package): Clarify the meaning of
  durations for '--list-durations' and '--delete-durations'.
2013-09-27 01:23:59 +02:00
Ludovic Courtès 03f4ef28b1 tests: Fix typo.
* tests/guix-package.sh: Add missing "-p" option.
2013-09-27 01:07:37 +02:00
Ludovic Courtès 03761a4465 build-system/trivial: Take the 'source' field into account.
* guix/build-system/trivial.scm (trivial-build): When SOURCE is true,
  add it to INPUTS.
  (trivial-cross-build): Likewise.
* tests/packages.scm ("trivial with source"): New test.
2013-09-27 00:46:17 +02:00
Nikita Karetnikov b7884ca3ca guix package: Add '--delete-generations'.
* guix/scripts/package.scm (switch-to-previous-generation): New function.
  (roll-back): Use the new function instead of 'switch-link'.
  (show-help): Add '--delete-generations'.
  (%options): Likewise.
  (guix-package)[process-actions]: Add 'current-generation-number',
  'display-and-delete', and 'delete-generation'.  Add support for
  '--delete-generations', and reindent the code.
* tests/guix-package.sh: Test '--delete-generations'.
* doc/guix.texi (Invoking guix-package): Document '--delete-generations'.
2013-09-26 15:41:43 +00:00
Nikita Karetnikov 9ac9360d6e guix package: Show which generation is the current one.
* guix/scripts/package.scm (guix-package)[process-query]: Show that a
  generation is the current one if the profile points to it.
* tests/guix-package.sh: Test it.
2013-09-25 16:10:40 +00:00
Nikita Karetnikov aad5af9f40 tests: Use 'test -z' to check that a string equals zero. 2013-09-25 16:09:50 +00:00
Nikita Karetnikov 4b2bc804d8 guix package: Do not list the zeroth generation.
* guix/scripts/package.scm (guix-package)[process-query]: Change
  'list-generation' to not list the zeroth generation.
* tests/guix-package.sh: Test it.
* doc/guix.texi (Invoking guix package): Document it, and use the
  right term when talking about generations.
2013-09-25 16:08:39 +00:00
Nikita Karetnikov 0ab212b946 guix package: Exit with 1 when a generation cannot be listed.
* guix/scripts/package.scm (guix-package)[process-query]: Exit with 1
  when a generation does not exist or the profile points to the zeroth
  generation.
* tests/guix-package.sh: Test the former case.
2013-09-25 16:07:50 +00:00
Ludovic Courtès caf96debc2 guix-register: Expect closures to refer to the original store.
* nix/guix-register/guix-register.cc (prefix): New variable.
  (parse_opt): Use it.
  (register_validity): Change 'info.path' to the final store name.
  Hash the final under its real path.
* tests/guix-register.sh: Adjust the contents of $closure accordingly.
  Rename 'NIX_LOCALSTATE_DIR' to 'NIX_STATE_DIR'.  Don't try to call
  'valid-path?'.  Add test using 'sqlite3'.
2013-09-23 23:56:35 +02:00
Ludovic Courtès a7a4e6a4f7 Add 'guix-register'.
* nix/guix-register/guix-register.cc, tests/guix-register.sh: New
  files.
* Makefile.am (SH_TESTS)[BUILD_DAEMON]: Add tests/guix-register.sh.
* daemon.am (sbin_PROGRAMS, guix_register_SOURCES,
  guix_register_CPPFLAGS, guix_register_LDADD): New variables.
* test-env.in: Export 'storedir', 'prefix', 'datarootdir', 'datadir',
  and 'localstatedir'.
2013-09-23 00:33:50 +02:00
Nikita Karetnikov 2cd09108c9 guix package: Add '--list-generations'.
* guix/scripts/package.scm: Import (srfi srfi-19).
  (generation-time, matching-generations): New functions.
  (show-help): Add '--list-generations'.
  (%options): Likewise.
  (guix-package)[process-query]: Add support for '--list-generations'.
* guix/ui.scm: Import (srfi srfi-19) and (ice-9 regex).
  (string->generations, string->duration): New functions.
* tests/guix-package.sh: Test '--list-generations'.
* tests/ui.scm: Import (srfi srfi-19).
  Test 'string->generations' and 'string->duration'.
* doc/guix.texi (Invoking guix-package): Document '--list-generations'.
2013-09-19 11:22:31 +00:00