Commit Graph

110 Commits (4c0c4db0702048488a9712dbba7cad862c667d54)

Author SHA1 Message Date
Ludovic Courtès 4c0c4db070
utils: Move base16 procedures to (guix base16).
* guix/utils.scm (bytevector->base16-string, base16-string->bytevector):
Move to...
* guix/base16.scm: ... here.  New file.
* tests/utils.scm ("bytevector->base16-string->bytevector"): Move to...
* tests/base16.scm: ... here.  New file.
* Makefile.am (MODULES): Add guix/base16.scm.
(SCM_TESTS): Add tests/base16.scm.
* build-aux/download.scm, guix/derivations.scm,
guix/docker.scm, guix/import/snix.scm, guix/pk-crypto.scm,
guix/scripts/authenticate.scm, guix/scripts/download.scm,
guix/scripts/hash.scm, guix/store.scm, tests/hash.scm,
tests/pk-crypto.scm: Adjust imports accordingly.
2017-03-16 22:50:14 +01:00
Ludovic Courtès 3104475148
utils: Use an idiom compatible with both 2.0 and 2.2.
Fixes a regression introduced in 7447aa36e1.
Reported by Ricardo Wurmus.

* guix/utils.scm: Revert 7447aa36e1.  Use
  #:prefix for (ice-9 iconv) to support both 2.0 and 2.2.
2017-03-09 09:48:33 +01:00
Ludovic Courtès 7447aa36e1
utils: Make sure to use the right 'bytevector->string'.
In Guile 2.2, (rnrs io ports) exports 'bytevector->string', which
conflicts with that of (ice-9 iconv).

* guix/utils.scm: Hide 'bytevector->string' from (rnrs io ports).
2017-03-08 23:42:53 +01:00
Ludovic Courtès 55b2d92145
Use 'mlambda' instead of 'memoize'.
* gnu/packages.scm (find-newest-available-packages): Use 'mlambda'
instead of (memoize (lambda ...) ...).
* gnu/packages/bootstrap.scm (package-with-bootstrap-guile): Likewise.
* guix/build-system/gnu.scm (package-with-explicit-inputs)[rewritten-input]:
Likewise.
* guix/build-system/python.scm (package-with-explicit-python)[transform]:
Likewise.
* guix/derivations.scm (derivation->string): Likewise.
* guix/gnu-maintenance.scm (gnu-package?): Likewise.
* guix/modules.scm (module-file-dependencies): Likewise.
* guix/scripts/graph.scm (standard-package-set): Likewise.
* guix/scripts/lint.scm (official-gnu-packages*): Likewise.
* guix/store.scm (store-regexp*): Likewise.
* guix/utils.scm (location): Likewise.
2017-01-28 18:55:20 +01:00
Ludovic Courtès f9704f179a
Add (guix memoization).
* guix/combinators.scm (memoize): Remove.
* guix/memoization.scm: New file.
* Makefile.am (MODULES): Add it.
* gnu/packages.scm, gnu/packages/bootstrap.scm,
guix/build-system/gnu.scm, guix/build-system/python.scm,
guix/derivations.scm, guix/gnu-maintenance.scm,
guix/import/cran.scm, guix/import/elpa.scm,
guix/modules.scm, guix/scripts/build.scm,
guix/scripts/graph.scm, guix/scripts/lint.scm,
guix/store.scm, guix/utils.scm: Adjust imports accordingly.
2017-01-28 18:55:20 +01:00
Ludovic Courtès aa042770da
guix package: Fix version and output for 'guix package -i /gnu/store/…'.
* guix/utils.scm (package-name->name+version): Add optional 'delimiter'
parameter.
* guix/scripts/package.scm (store-item->manifest-entry): Pass #\- as the
delimiter for 'package-name->name+version'.  Use "out" instead of #f for
the 'output' field.
* tests/guix-package.sh: Add test.
2017-01-11 11:58:21 +01:00
Jan Nieuwenhuizen cba36e6482
gnu: cross-base: Add i686-w64-mingw32 target.
* guix/utils.scm (mingw-target?): New function.
* gnu/packages/cross-base.scm (cross-gcc-snippet): New procedure
(cross-gcc): Use it.
(cross-gcc-arguments, cross-gcc-patches, cross-gcc): Support MinGW.
(native-libc, cross-newlib?): New functions.
(cross-libc): Use cross-newlib? to support MinGW.
(%gcc-include-paths, %gcc-cross-include-paths): New variables.
2016-12-07 10:23:16 +01:00
Ludovic Courtès 2535635f18
Use (ice-9 binary-ports) instead of (rnrs io ports).
This reduces the closure of (guix ui) from 123 to 106 modules.

* guix/derivations.scm: Use (ice-9 binary-ports) instead of (rnrs io
ports).
(map-derivation)[substitute-file]: Use 'read-string' instead of
'get-string-all'.
* guix/ftp-client.scm: Likewise.
* guix/hash.scm: Likewise.
* guix/http-client.scm: Likewise.
* guix/pki.scm (ensure-acl, current-acl): Likewise.
* guix/scripts/archive.scm (authorize-key)[read-key]: Likewise.
* guix/scripts/authenticate.scm (read-canonical-sexp)
(read-hash-data): Likewise.
* guix/scripts/download.scm: Likewise.
* guix/scripts/offload.scm (register-gc-root, remove-gc-roots)
(send-files): Likewise.
* guix/scripts/publish.scm (lazy-read-file-sexp): Likewise.
* guix/scripts/refresh.scm: Likewise.
* guix/scripts/substitute.scm (check-acl-initialized): Likewise.
* guix/serialization.scm (read-maybe-utf8-string): Likewise.
* guix/scripts/hash.scm (guix-hash): Use 'force-output' instead of
'flush-output-port'.
* guix/store.scm (process-stderr): Likewise.
* guix/tests.scm: Likewise.
* guix/utils.scm: Use (ice-9 binary-ports) and autoload (rnrs io ports)
for 'make-custom-binary-input-port'.
2016-10-19 15:54:10 +02:00
Eric Bavier b8b129ebd8
utils: Support defaults in substitute-keyword-arguments.
* guix/utils.scm (collect-default-args, expand-default-args): New
syntax.
(substitute-keyword-arguments): Allow default value declarations.
* tests/utils.scm (substitute-keyword-arguments): New test.
2016-10-07 07:42:05 -05:00
Eric Bavier 347df60158
utils: Fix default-keyword-arguments.
* guix/utils.scm (default-keyword-arguments): Properly test for present
keywords.
* tests/utils.scm (default-keyword-arguments): New test.
2016-10-07 07:41:57 -05:00
Ludovic Courtès 089b167812
publish: Do not compress already-compressed files.
* guix/scripts/publish.scm (narinfo-string): Force %NO-COMPRESSION when
STORE-PATH matches 'compressed-file?'.
* guix/utils.scm (compressed-file?): New procedure.
* tests/publish.scm ("/*.narinfo for a compressed file"): New test.
2016-08-01 17:58:56 +02:00
Ludovic Courtès 934c5d5b28
utils: 'cache-directory' always appends "/guix".
Fixes <http://bugs.gnu.org/23836>.
Fixes a regression introduced in f10dcbf1a9.
Reported by myglc2 <myglc2@gmail.com>.

* guix/utils.scm (cache-directory): Always append "/guix".
2016-06-25 01:13:23 +02:00
Ludovic Courtès 3583b27b2c
utils: 'cache-directory' honors 'XDG_CACHE_HOME'.
* guix/utils.scm (cache-directory): Honor 'XDG_CACHE_HOME', not
'XDG_CONFIG_HOME'.
2016-06-22 23:39:57 +02:00
Ludovic Courtès a68d0f6fd5
utils: 'current-source-directory' gracefully handles lack of source info.
* guix/utils.scm (current-source-directory): Add case for when FILE-NAME
is #f.
2016-06-20 00:52:53 +02:00
Ludovic Courtès cbbbb7be0f
utils: 'current-source-directory' resolves relative file names at run time.
* guix/utils.scm (absolute-dirname): New procedure.
(current-source-directory): Emit code to use it instead of calling
'search-path'.
2016-06-20 00:52:53 +02:00
Ludovic Courtès d4dd37fc46
utils: 'current-source-directory' returns the absolute directory name.
* guix/utils.scm (current-source-directory): When FILE-NAME is relative,
use 'search-path' to determine the absolute file name.
2016-06-16 23:50:44 +02:00
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