Commit Graph

94 Commits

Author SHA1 Message Date
Ludovic Courtès 5dbae738f0
utils: 'current-source-directory' is now purely an expansion-time thing.
* guix/utils.scm (extract-directory): Remove.
(current-source-directory): Rewrite as a 'syntax-case' macro.
2016-06-16 23:50:44 +02:00
Ludovic Courtès 07c8a98c3b
gexp: Move 'current-source-directory' to (guix utils).
* guix/gexp.scm (extract-directory, current-source-directory): Move to...
* guix/utils.scm (extract-directory, current-source-directory):
... here.  New procedures.
2016-06-16 09:34:32 +02:00
Ludovic Courtès c25637dfe8
utils: 'with-atomic-file-output' closes the port upon exception.
Previously it could have left the file descriptor open.

* guix/utils.scm (with-atomic-file-output): Call 'close-port' in handler.
2016-06-13 18:05:54 +02:00
Ludovic Courtès 1752a17a1e
utils: 'with-atomic-file-output' calls 'fdatasync'.
Suggested by Danny Milosavljevic <dannym@scratchpost.org>
at <https://lists.gnu.org/archive/html/guix-devel/2016-06/msg00456.html>.

* guix/build/syscalls.scm (fdatasync): New procedure.
* guix/utils.scm (with-atomic-file-output): Use it.  Use 'close-port'
instead of 'close'.
2016-06-13 18:05:54 +02:00
Alex Kost 19e1d5f7f9 guix: utils: Re-export 'memoize'.
Suggested by Ludovic Courtès <ludo@gnu.org>.

* guix/utils.scm: Re-export 'memoize' to avoid a potential breakage of
  emacs interface.  See
  <http://lists.gnu.org/archive/html/guix-devel/2016-05/msg00146.html>
  for details.
2016-05-09 11:41:00 +03:00
Ludovic Courtès 4e0ea3eb28
utils: Move 'fcntl-flock' to (guix build syscalls).
* guix/utils.scm (%struct-flock, F_SETLKW, F_SETLK, F_xxLCK)
(fcntl-flock): Move to...
* guix/build/syscalls.scm: ... here.  New variables.
* guix/nar.scm: Adjust imports accordingly.
* tests/utils.scm ("fcntl-flock wait", "fcntl-flock non-blocking"): Move
to...
* tests/syscalls.scm: ... here.  New tests.
(temp-file): New variable.
2016-05-06 13:25:30 +02:00
Ludovic Courtès 958dd3ce68
utils: Move combinators to (guix combinators).
* guix/utils.scm (compile-time-value, memoize, fold2)
(fold-tree, fold-tree-leaves): Move to...
* guix/combinators: ... here.  New file.
* tests/utils.scm ("fold2, 1 list", "fold2, 2 lists")
(fold-tree tests): Move to...
* tests/combinators.scm: ... here.  New file.
* Makefile.am (MODULES, SCM_TESTS): Add them.
* gnu/packages.scm, gnu/packages/bootstrap.scm,
gnu/services/herd.scm, guix/build-system/gnu.scm,
guix/build-system/python.scm, guix/derivations.scm,
guix/gnu-maintenance.scm, guix/import/elpa.scm,
guix/scripts/archive.scm, guix/scripts/build.scm,
guix/scripts/graph.scm, guix/scripts/lint.scm,
guix/scripts/size.scm, guix/scripts/substitute.scm,
guix/serialization.scm, guix/store.scm, guix/ui.scm: Adjust imports
accordingly.
2016-05-04 23:35:55 +02:00
Ludovic Courtès 4b6fa8b339
utils: Remove 'split'.
This procedure was redundant with SRFI-1's 'break'.

* guix/utils.scm (split): Remove.
* tests/utils.scm ("split, element is in list")
("split, element is not in list"): Remove.
2016-05-04 23:35:55 +02:00
Ludovic Courtès dd1d09f7e4 utils: 'cache-directory' gracefully deals with unset 'HOME'.
Fixes <http://bugs.gnu.org/23165>.

* guix/utils.scm (cache-directory): Use 'getpwuid' when 'HOME' is unset.
2016-04-18 19:26:34 +02:00
宋文武 f7df1e3efb utils: Add 'location->source-properties'.
* guix/utils (location-source->properties): New procedure.
2016-04-13 09:17:01 +08:00
宋文武 50a3d59473 utils: Add 'edit-expression'.
* guix/utils.scm (edit-expression): New procedure.
* tests/utils.scm (edit-expression): New test.
2016-04-13 09:16:54 +08:00
Mathieu Lirzin 1b846da8c3 utils: Use '@' for separating package names and version numbers.
This provides the ability to use numbers in package names.

Fixes <http://bugs.gnu.org/19219>.

* guix/utils.scm (package-name->name+version): New procedure.
* gnu/packages.scm (%find-package): Add a FALLBACK? keyword argument.
Use the previous method when no package is found.
(specification->package+output, specification->package): Adapt
documentation to new syntax.
* doc/guix.texi (Invoking guix package, Invoking guix import): Likewise.
* guix/ui.scm (package-specification->name+version+output): Likewise.
* guix/scripts/import/hackage.scm (show-help): Likewise.
* tests/guix-build.sh: Adapt to new syntax.
* tests/guix-lint.sh: Likewise.
* tests/guix-package.sh: Likewise.
* tests/ui.scm ("package-specification->name+version+output"): Likewise.
* tests/utils.scm ("package-name->name+version"): Likewise.
* NEWS: Mention new syntax.
2016-03-02 21:41:41 +01:00
Ludovic Courtès 6071122b71 utils: Add 'ensure-keyword-arguments'.
* guix/utils.scm (delkw, ensure-keyword-arguments): New procedures.
* tests/utils.scm ("ensure-keyword-arguments"): New test.
2016-01-06 23:08:22 +01:00
Federico Beffa c8be6f0d4a utils: Add 'canonical-newline-port'.
* guix/utils.scm (canonical-newline-port): New procedure.
* tests/utils.scm ("canonical-newline-port"): New test.
2015-11-26 18:17:23 +01:00
Ludovic Courtès 3bb168b099 utils: Add 'switch-symlinks', moved from (guix ui).
* guix/ui.scm (switch-symlinks): Move to...
* guix/utils.scm: ... here.  New procedure.
* guix/scripts/pull.scm: Use it.
2015-10-27 00:01:20 +01:00
Ludovic Courtès d50cb56d9b utils: Add 'readlink*'.
* guix/scripts/package.scm (readlink*): Move to...
* guix/utils.scm (readlink*): ... here.  New procedure.
2015-10-27 00:01:20 +01:00
Ludovic Courtès 739ab68bac http-client: Add 'http-fetch/cached'.
* guix/utils.scm (cache-directory): New procedure.
* guix/http-client.scm (%http-cache-ttl): New variable.
  (http-fetch/cached): New procedure.
2015-10-17 14:42:01 +02:00
David Thompson bbd00d2012 utils: Add split procedure.
* guix/utils.scm (split): New procedure.
* tests/utils.scm: Add tests.
2015-10-09 12:17:01 -04:00
Ludovic Courtès f073e52382 utils: Remove Nixpkgs helpers.
* guix/config.scm.in (%nixpkgs): Remove.
* guix/utils.scm (%nixpkgs-directory, nixpkgs-derivation,
  nixpkgs-derivation*): Remove.
* test-env.in: Export 'NIXPKGS'.
* tests/derivations.scm (%coreutils): Remove use of
  'nixpkgs-derivation'.
* tests/snix.scm (%nixpkgs-directory): New variable.
  Adjust users accordingly.
2015-10-06 23:51:04 +02:00
Ludovic Courtès e1556533d3 Merge branch 'core-updates' 2015-09-26 15:14:53 +02:00
Ludovic Courtès 62d2b57157 utils: Add #:options parameter for compression output ports.
* guix/utils.scm (compressed-output-port,
  call-with-compressed-output-port): Add #:options parameter and honor
  it.
2015-09-25 22:35:35 +02:00
Ludovic Courtès 8c578a6094 utils: Move 'package-name->name+version' to (guix build utils).
* guix/utils.scm (package-name->name+version): Move to...
* guix/build/utils.scm (package-name->name+version): ... here.  New
  procedure.
* guix/build/emacs-build-system.scm (package-name->name+version):
  Remove.
2015-08-30 18:38:08 +02:00
David Thompson db6e5e2b2c utils: Add call-with-temporary-directory.
* guix/utils.scm (call-with-temporary-directory): New procedure.
2015-07-07 18:47:25 -04:00
Ludovic Courtès 6568d2bd6e search-paths: Add 'evaluate-search-paths', from (guix scripts package).
* guix/scripts/package.scm (with-null-error-port,
  evaluate-search-paths): Move to...
* guix/search-paths.scm: ... here.
* guix/utils.scm (string-tokenize*): Move to...
* guix/search-paths.scm: ... here.
* tests/utils.scm ("string-tokenize*"): Adjust accordingly.
2015-05-04 23:30:51 +02:00
Ludovic Courtès cde1e967cf utils: Add 'version>=?'.
* guix/utils.scm (version>?): Clarify docstring.
  (version>=?): New procedure.
2015-02-09 18:18:41 +01:00
Mark H Weaver 3f00ff8b43 gnu: Add toolchain support for 'armhf-linux'.
Based on preliminary work by John Darrington <john@darrington.wattle.id.au>.

* gnu/packages/cross-base.scm (xgcc-armhf): New variable.
* gnu/packages/gcc.scm (gcc-configure-flags-for-triplet): Add armhf case.
  (gcc-4.7)[pre-configure]: Add gcc/config/*/linux-eabi.h to the list
  of files in which to patch GLIBC_DYNAMIC_LINKER.
* gnu/packages/bootstrap.scm (glibc-dynamic-linker): Add armhf case.
* guix/utils.scm (gnu-triplet->nix-system, nix-system->gnu-triplet):
  Add armhf cases.
2015-01-07 16:27:55 -05:00
Mark H Weaver 8eb8048432 Move 'nix-system->gnu-triplet' to (guix utils) and export it.
* gnu/packages/commencement.scm (nix-system->gnu-triplet): Move to...
* guix/utils.scm (nix-system->gnu-triplet): ... here.  Fix docstring typo.
2015-01-07 12:34:10 -05:00
nebuli 16eb115ef4 guix: scripts: Add GUIX_BUILD_OPTIONS environment handling.
* doc/guix.texi (Invoking guix build): Mention 'GUIX_BUILD_OPTIONS'.
* guix/scripts/archive.scm: (append args (environment-build-options)).
* guix/scripts/build.scm: Ditto.
* guix/scripts/environment.scm: Ditto.
* guix/scripts/package.scm: Ditto.
* guix/scripts/system.scm: Ditto.
* guix/ui.scm (environment-build-options): New function.
* guix/utils.scm (arguments-from-environment-variable): New function.
* tests/guix-build.sh: Add tests.
* test-env.in: Unset GUIX_BUILD_OPTIONS.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2014-11-30 18:54:07 +01:00
Ian Denhardt 29a7c98a42 gnu: Add 'version-prefix' and 'version-major+minor'; use them.
The procedure version-prefix truncates a version string to a certain
number of components. version-major+minor is a special case of this,
which extracts the "major.minor" part of the string. Previously this
was handled by an expression common to several packages.

* guix/utils.scm (version-prefix, version-major+minor): New procedures
* gnu/packages/backup.scm (duplicity): Use version-major+minor.
* gnu/packages/cmake.scm (cmake): Likewise.
* gnu/packages/gnome.scm (libbonobo, libbonoboui): Likewise.
* gnu/packages/gnutls.scm (gnutls): Likewise.
* gnu/packages/mail.scm (gmime): Likewise.
* gnu/packages/mpd.scm (mpd): Likewise.
* gnu/packages/mpi.scm (openmpi): Likewise.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2014-10-20 15:32:54 +02:00
Ludovic Courtès 998fb8fa1d utils: Micro-optimize 'bytevector->base16-string'.
This reduces run time of (package-derivation s emacs) by ~1.5%.

* guix/utils.scm (bytevector->base16-string): Traverse BV from the end
  so as to use 'string-concatenate' instead of
  'string-concatenate-reverse'.
2014-10-13 23:34:09 +02:00
Ludovic Courtès 5e1103821a utils: Add 'strip-keyword-arguments'.
* guix/utils.scm (strip-keyword-arguments): New procedure.
* tests/utils.scm ("strip-keyword-arguments"): New test.
2014-10-05 21:57:19 +02:00
Ludovic Courtès 57db49cc3e utils: Create temporary files in $TMPDIR or /tmp.
Reported by Federico Beffa <beffa@ieee.org>.

* guix/utils.scm (call-with-temporary-output-file): Prepend $TMPDIR or
  /tmp to TEMPLATE.
2014-09-17 07:18:46 +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 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 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 af4535c58c utils: Make 'errno' procedure more robust.
Partially fixes <http://bugs.gnu.org/17212>.

* guix/utils.scm (errno): Move definition of 'bv' outside of the
  procedure.  Use 'bytevector-s32-native-ref' or
  'bytevector-s64-native-ref' instead of 'bytevector-sint-ref'.
2014-04-07 18:16:59 +02: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 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
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 9ea3ef2655 utils: 'fcntl-flock' passes an errno when throwing an exception.
* guix/utils.scm (%libc-errno-pointer, errno): New procedures.
  (fcntl-flock): Use it as the exception's argument.
2014-03-06 21:42:24 +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 04d4c8a439 Move 'with-atomic-file-output' to (guix utils).
* guix/scripts/substitute-binary.scm (with-atomic-file-output): Move to...
* guix/utils.scm (with-atomic-file-output): ... here.
2013-12-29 15:57:24 +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 ac10e0e17e packages: Add 'patches' and related fields to <origin>.
See <https://lists.gnu.org/archive/html/guix-devel/2013-09/msg00137.html>
for the rationale.

* guix/packages.scm (<origin>)[patches, patch-flags, patch-inputs,
  patch-guile]: New fields.
  (%standard-patch-inputs, default-guile, patch-and-repack): New
  procedures.
  (package-source-derivation): When 'patches' is non-empty, call
  'patch-and-repack'.
* guix/utils.scm (file-sans-extension): New procedure.
2013-10-09 00:11:34 +02:00
Ludovic Courtès 7db3ff4a29 utils: Add `guile-version>?', and use it.
This fixes Guile version comparisons when (version) has a
vendor-specific suffix.

Reported by Andreas Enge <andreas@enge.fr>.

* guix/utils.scm (guile-version>?): New procedure.
* tests/utils.scm ("guile-version>? 1.8", "guile-version>? 10.5"): New
  tests.
* guix/scripts/substitute-binary.scm (fetch, progress-report-port): Use
  `guile-version>?' instead of `version>?'.
* guix/http-client.scm (when-guile<=2.0.5, http-fetch): Likewise.
2013-08-23 15:51:36 +02:00
Ludovic Courtès 72626a71a9 Move `sha256' to (guix hash).
* guix/utils.scm (sha256): Move to...
* guix/hash.scm: ... here.  New file.
* Makefile.am (MODULES): Add it.
* guix/derivations.scm, guix/scripts/download.scm,
  guix/scripts/hash.scm, guix/scripts/refresh.scm, tests/base32.scm,
  tests/derivations.scm, tests/store.scm: Use (guix hash).
2013-07-01 23:28:21 +02:00
Ludovic Courtès 9c1edabd8b packages: Implement `package-cross-derivation'.
* guix/packages.scm (package-transitive-target-inputs,
  package-transitive-native-inputs): New procedures.
  (package-derivation): Parametrize `%current-target-system'.
  (package-cross-derivation): Implement.
* guix/utils.scm (%current-target-system): New variable.
* tests/packages.scm ("package-cross-derivation"): New test.
* doc/guix.texi (Defining Packages): Document
  `package-cross-derivation'.
2013-05-24 22:30:58 +02:00
Ludovic Courtès 101d9f3fd4 substitute-binary: Pass `filtered-port' an unbuffered port.
This fixes a bug whereby `read-response' would read more than just the
response, with the extra data going into the port's buffer; the
"bzip2 -dc" process spawned by `filtered-port' would not see the those
buffered data, which are definitely lost, and would bail out with
"bzip2: (stdin) is not a bzip2 file."

* guix/utils.scm (filtered-port): Document that INPUT must be
  unbuffered.
* guix/web.scm (http-fetch): Add `buffered?' parameter.  Call
  `open-socket-for-uri' explicitly, and call `setvbuf' when BUFFERED? is
  false.  Pass the port to `http-get'.  Close it upon 301/302.
* guix/scripts/substitute-binary.scm (fetch): Add `buffered?'
  parameter.  Pass it to `http-fetch'; honor it for `file' URIs.
  (guix-substitute-binary): Call `fetch' with #:buffered? #f for port RAW.
* tests/utils.scm ("filtered-port, file"): Open FILE as unbuffered.
2013-05-15 23:40:09 +02:00