Commit Graph

201 Commits

Author SHA1 Message Date
Ludovic Courtès 579506e272
utils: Add 'version-unique-prefix'.
* guix/utils.scm (version-unique-prefix): New procedure.
* tests/utils.scm ("version-unique-prefix"): New test.
2021-02-01 17:32:34 +01:00
Maxim Cournoyer 01f0707207
Merge branch 'staging' into 'core-updates'.
Conflicts:

	gnu/local.mk
	gnu/packages/cmake.scm
	gnu/packages/curl.scm
	gnu/packages/gl.scm
	gnu/packages/glib.scm
	gnu/packages/guile.scm
	gnu/packages/node.scm
	gnu/packages/openldap.scm
	gnu/packages/package-management.scm
	gnu/packages/python-xyz.scm
	gnu/packages/python.scm
	gnu/packages/tls.scm
	gnu/packages/vpn.scm
	gnu/packages/xorg.scm
2021-01-13 23:45:53 -05:00
Ludovic Courtès db0cecdf6b
utils: Support zstd compression via Guile-zstd.
* guix/utils.scm (lzip-port): Return a single value.
(zstd-port): New procedure.
(decompressed-port, compressed-output-port): Add 'zstd' case.
* tests/utils.scm (test-compression/decompression): Test 'zstd' when
the (zstd) module is available.
2021-01-13 22:24:19 +01:00
Ludovic Courtès 0d04658710
utils: Remove 'compressed-output-port'.
This procedure was unused except in one test.

* guix/utils.scm (compressed-port): Remove.
* tests/utils.scm (test-compression/decompression): Rewrite to use
'compressed-output-port' instead.
2021-01-13 22:24:19 +01:00
Efraim Flashner 3d395e3d83
utils: Add pkg-config-for-target.
* guix/utils.scm (pkg-config-for-target): New procedure.
2020-12-28 19:04:34 +02:00
Christopher Baines ff01206345
Merge remote-tracking branch 'origin/master' into core-updates 2020-11-29 17:34:18 +00:00
Danny Milosavljevic b720cf90e7
utils: Add 'cxx-for-target'.
* guix/utils.scm (cxx-for-target): New procedure.
2020-11-16 10:26:46 +01:00
Maxim Cournoyer 5a0997ef7f
packages, scripts, utils: Enable multi-threaded xz compression.
xz compression is slow; using the multi-thread mode of xz can make it more
than 6 times faster, for example when compressing the large linux-libre
source.

* guix/build/utils.scm (%xz-parallel-args): New procedure.
* guix/packages.scm (patch-and-repack): Specify the required above xz
arguments by setting the XZ_DEFAULTS environment variable.
* guix/scripts/pack.scm (%compressors, bootstrap-xz): Modify the commands
Gexps so they do not need to be quoted.  This allows lazily evaluating the
arguments on the builder's side.  Specify the required xz arguments.
(self-contained-tarball): Do not quote the compressor command value.
(docker-image): Likewise.
* guix/utils.scm (decompressed-port, compressed-port)
(compressed-output-port): Specify the required above xz arguments.
2020-10-08 12:27:02 -04:00
Ludovic Courtès d845e3af7c
utils: Add 'call-with-temporary-output-file'.
* guix/utils.scm: Re-export 'call-with-temporary-output-file'.
(call-with-temporary-output-file): Move to...
* guix/build/utils.scm (call-with-temporary-output-file): ... here.
2020-09-19 17:28:47 +02:00
Mathieu Othacehe 4c0c65acfa
Use "guile-zlib" and "guile-lzlib" instead of (guix config).
* Makefile.am (MODULES): Remove guix/zlib.scm and guix/lzlib.scm,
(SCM_TESTS): remove tests/zlib.scm, tests/lzlib.scm.
* build-aux/build-self.scm (make-config.scm): Remove unused %libz variable.
* configure.ac: Remove LIBZ and LIBLZ variables and check instead for
Guile-zlib and Guile-lzlib.
* doc/guix.texi ("Requirements"): Remove zlib requirement and add Guile-zlib
and Guile-lzlib instead.
* gnu/packages/package-management.scm (guix)[native-inputs]: Add "guile-zlib"
and "guile-lzlib",
[inputs]: remove "zlib" and "lzlib",
[propagated-inputs]: ditto,
[arguments]: add "guile-zlib" and "guile-lzlib" to Guile load path.
* guix/config.scm.in (%libz, %liblz): Remove them.
* guix/lzlib.scm: Remove it.
* guix/man-db.scm: Use (zlib) instead of (guix zlib).
* guix/profiles.scm (manual-database): Do not stub (guix config) in imported
modules list, instead add "guile-zlib" to the extension list.
* guix/scripts/publish.scm: Use (zlib) instead of (guix zlib) and (lzlib)
instead of (guix lzlib),
(string->compression-type, effective-compression): do not check for zlib and
lzlib availability.
* guix/scripts/substitute.scm (%compression-methods): Do not check for lzlib
availability.
* guix/self.scm (specification->package): Add "guile-zlib" and "guile-lzlib"
and remove "zlib" and "lzlib",
(compiled-guix): remove "zlib" and "lzlib" arguments and add guile-zlib and
guile-lzlib to the dependencies, also do not pass "zlib" and "lzlib" to
"make-config.scm" procedure,
(make-config.scm): remove "zlib" and "lzlib" arguments as well as %libz and
%liblz variables.
* guix/utils.scm (lzip-port): Use (lzlib) instead of (guix lzlib) and do not
check for lzlib availability.
* guix/zlib.scm: Remove it.
* m4/guix.m4 (GUIX_LIBZ_LIBDIR, GUIX_LIBLZ_FILE_NAME): Remove them.
* tests/lzlib.scm: Use (zlib) instead of (guix zlib) and (lzlib)
instead of (guix lzlib), and do not check for zlib and lzlib availability.
* tests/publish.scm: Ditto.
* tests/substitute.scm: Do not check for lzlib availability.
* tests/utils.scm: Ditto.
* tests/zlib.scm: Remove it.
2020-08-24 13:35:24 +02:00
Efraim Flashner 46886728a7
utils: Add version-major+minor+point.
* guix/utils.scm (version-major+minor+point): New procedure.
2020-08-17 07:57:23 +03:00
Ludovic Courtès f9a8dd053c
utils: Move '&fix-hint' to (guix diagnostics).
* guix/utils.scm (&fix-hint): Move to...
* guix/diagnostics.scm (&fix-hint): ... here.
* gnu.scm: Adjust imports accordingly.
* gnu/system/mapped-devices.scm: Likewise.
* guix/channels.scm: Likewise.
* guix/profiles.scm: Likewise.
* guix/scripts/system/reconfigure.scm: Likewise.
* guix/ssh.scm: Likewise.
2020-07-25 19:11:36 +02:00
Ludovic Courtès 6a79eed920
utils: Remove compatibility re-export of 'memoize'.
The 'memoize' binding was re-exported in 2016, commit
19e1d5f7f9, as a backwards-compatibility
measure that makes little sense now.

* guix/utils.scm: Don't re-export 'memoize'.
* guix/import/pypi.scm: Adjust imports.
* tests/pypi.scm: Remove duplicate (guix memoization) import.
2020-07-25 19:11:36 +02:00
Ludovic Courtès a5e2fc7376
utils: Move <location> and '&error-location' to (guix diagnostics).
* guix/utils.scm (<location>, source-properties->location)
(location->source-properties, &error-location): Move to...
* guix/diagnostics.scm: ... here.
* gnu.scm: Adjust imports accordingly.
* gnu/machine.scm: Likewise.
* gnu/system.scm: Likewise.
* gnu/tests.scm: Likewise.
* guix/inferior.scm: Likewise.
* tests/channels.scm: Likewise.
* tests/packages.scm: Likewise.
2020-07-25 19:11:36 +02:00
Ludovic Courtès d67a881966
utils: Add 'with-environment-variables'.
* guix/tests/gnupg.scm (call-with-environment-variables)
(with-environment-variables): Move to...
* guix/utils.scm: ... here.
* guix/tests/git.scm: Adjust accordingly.
2020-06-06 23:28:49 +02:00
Marius Bakke fb9a57a8e6
utils: Add 'cc-for-target'.
* guix/utils.scm (cc-for-target): New procedure.
2020-05-29 15:41:30 +02:00
Ludovic Courtès 300a54bb98
utils: 'target-arm32?' & co. take an optional parameter.
* guix/utils.scm (target-arm32?, target-aarch64?)
(target-arm?, target-64bit?): Make 'target' an optional parameter.
2020-05-16 00:34:41 +02:00
Ludovic Courtès 6a7c4636d4
Adjust module autoloads.
In Guile < 2.9.7, autoloading a module would give you access to all its
bindings.  In future versions, autoloading a module gives access only to
the listed bindings, as per #:select (see <https://bugs.gnu.org/38895>).

This commit adjusts autoloads to the new semantics, allowing Guix to be
built with Guile 2.9.7/2.9.8.

* guix/build/download.scm <top level>: Remove call to 'module-autoload!'.
(load-gnutls): New procedure.
(tls-wrap): Call it.
* guix/git.scm <top level>: Remove call to 'module-autoload!'.
(load-git-submodules): New procedure.
(update-submodules): Call it instead of 'resolve-interface'.
* gnu/bootloader/grub.scm: Replace #:autoload with #:use-module.
* gnu/packages.scm: Likewise.
* gnu/packages/ssh.scm: Likewise.
* gnu/packages/tex.scm: Likewise.
* gnu/services/cuirass.scm: Likewise.
* gnu/services/mcron.scm: Likewise.
* guix/lint.scm: Augment list of bindings in #:autoload.
* guix/scripts/build.scm: Likewise.
* guix/scripts/gc.scm: Likewise.
* guix/scripts/pack.scm: Likewise.
* guix/scripts/publish.scm: Likewise.
* guix/scripts/pull.scm: Likewise.
* guix/utils.scm: Remove unnecessary #:autoload clauses; replace one
of them with #:use-module.
2020-01-06 16:31:54 +01:00
Mathieu Othacehe 74f1718081
utils: Use target-aarch64? and target-arm? helpers.
* guix/utils.scm (target-aarch64?, target-arm?): New exported procedures.
2019-11-22 16:33:42 +01:00
Alex Sassmannshausen b997d43214
utils: Handle #f file-name.
* guix/utils.scm (current-source-directory): Change dispatch to handle #f
file-name.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2019-11-18 13:18:41 +09:00
Hartmut Goebel da1027a705
guix: Rename and move sans-extension to tarball-sans-extension.
* guix/gnu-maintenance.scm (sans-extension): Move and rename to ...
* guix/utils.scm (tarball-sans-extension): ... here.
2019-09-10 19:04:05 +02:00
Robert Vollmert 3149c00264
utils: canonical-newline-port: Fix handling of carriage return at buffer end.
Prior to this change the added test fails for me locally at byte
1024. It might depend on some default buffer sizes.

Fixes <https://bugs.gnu.org/35863>.

* tests/utils.scm ("canonical-newline-port-1024"): Add test.
* guix/utils.scm (canonical-newline-port): Correct comments on CR/LF.
Remove CR even when they're at the end of the buffer.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2019-06-20 14:07:01 +02:00
Ludovic Courtès 4e48923e75
utils: Support compression and decompression with lzip.
* guix/utils.scm (lzip-port): New procedure.
(decompressed-port, compressed-port, compressed-output-port): Add 'lzip
case.
* tests/utils.scm <top level>: Call 'test-compression/decompression' for
'lzip as well.
2019-05-27 22:47:24 +02:00
Ludovic Courtès 87b711d200
utils: Memoize 'absolute-dirname'.
* guix/utils.scm (absolute-dirname): Wrap in 'mlambda'.
2018-12-19 23:52:25 +01:00
Marius Bakke e9be2c5409
Revert "guix: Compress and decompress xz archives in parallel."
Threaded compression makes archives non-deterministic: the result depends on
the number of threads used for compressing.  See <https://bugs.gnu.org/31015>.

This reverts commit 63102406f2.
2018-07-22 18:01:35 +02:00
Leo Famulari 27f7cbc91d
utils: Really clean up temporary directories.
Fixes <https://bugs.gnu.org/32126>.

* guix/utils.scm (call-with-temporary-directory): Use DELETE-FILE-RECURSIVELY
instead of RMDIR.
2018-07-13 17:33:45 -04:00
Ludovic Courtès 223fa5b327
utils: Micro-optimize 'source-properties->location'.
* guix/utils.scm (source-properties->location): Destructure LOC with
'match', adding a fast path without 'assq-ref' calls.
2018-07-02 15:28:35 +02:00
Ludovic Courtès 3059a35afe
utils: Disable memoization for 'location'.
This was getting 25% hits, which did not quite justify the overhead.

* guix/utils.scm (location): Remove 'mlambda'.
2018-07-02 15:28:35 +02:00
Marius Bakke 259341cf93
gnu: ldb: Fix build on 32-bit systems.
* guix/utils.scm (target-64bit?): New procedure.
* gnu/packages/samba.scm (ldb)[inputs]: Only add LMDB on 64-bit systems.
[arguments]: Make #:tests? conditional on LMDB availability.
2018-06-16 21:35:25 +02:00
Ludovic Courtès 437f62f02a
utils: Add 'version-prefix?'.
* guix/utils.scm (version-prefix?): New procedure.
* tests/utils.scm ("version-prefix?"): New test.
2018-05-13 13:29:27 +02:00
nee 47dc9a0dae
guix: utils: Add version-major.
* guix/utils.scm (version-major): New procedure.
2017-12-11 19:12:23 +00:00
Mathieu Othacehe e45b573c2d
utils: Add target-arm32? procedure.
* guix/utils.scm (target-arm32?): New exported procedure.
2017-12-01 13:55:45 +01:00
Ludovic Courtès 23735137eb
ui: Define and honor '&error-location' and '&fix-hint' conditions.
* guix/utils.scm (&error-location, &fix-hint): New condition types.
* guix/ui.scm (report-load-error): Handle them.
(call-with-error-handling): Honor '&error-location'.
2017-11-08 22:31:58 +01:00
Ludovic Courtès 8c3488259e
Add (guix progress).
Among other things, this removes (guix utils), (guix ui), (guix config),
etc. from the closure of (guix build download), as was the case since
798648515b.

* guix/utils.scm (<progress-reporter>, call-with-progress-reporter):
Move to...
* guix/progress.scm: ... here.  New file.
* Makefile.am (MODULES): Add it.
* guix/build/download.scm (current-terminal-columns)
(nearest-exact-integer, duration->seconds, seconds->string)
(byte-count->string, progress-bar, string-pad-middle)
(rate-limited, progress-reporter/file, dump-port*)
(time-monotonic): Move to progress.scm.
* guix/scripts/download.scm: Adjust accordingly.
* guix/scripts/substitute.scm: Likewise.
2017-10-19 23:21:49 +02:00
宋文武 5efa0e4d4f
guix: substitute: Report the last progress in the child process.
Fixes <https://bugs.gnu.org/28756>.

* guix/utils.scm (filtered-port): Close the 'input' port for the current
process, and close it upon exit in the child process.
* guix/scripts/substitute.scm (progress-substitution): Display "\n\n" after
the reporter has finished.
2017-10-17 19:00:35 +08:00
宋文武 798648515b
download: Don't report the progress too fast.
* guix/utils.scm (<progress-reporter>): New record type.
(call-with-progress-reporter): New procedure.
* guix/build/download.scm (dump-port*, rate-limited, progress-reporter/file):
New procedures.
(ftp-fetch, http-fetch): Use 'dump-port*'.
(progress-proc): Remove procedure.
* guix/scripts/substitute.scm (progress-report-port): Rewrite in terms of
<progress-reporter>.
(process-substitution): Adjust accordingly.
2017-09-20 19:49:31 +08:00
Ludovic Courtès 82781d871f
utils: 'current-source-directory' gracefully deals with lack of location info.
* guix/utils.scm (current-source-directory): Adjust for when
'syntax-source' returns #f.
2017-09-19 12:19:15 +02:00
Ludovic Courtès f0e492f0a5
utils: Factorize XDG directory handling.
* guix/ui.scm (config-directory): Remove.
* guix/utils.scm (xdg-directory, config-directory): New procedures.
(cache-directory): Rewrite in terms of 'xdg-directory'.
* guix/scripts/substitute.scm (%narinfo-cache-directory): Pass #:ensure?
 #f to 'cache-directory'.
2017-07-28 18:09:43 +02:00
Ludovic Courtès f411124321
utils: 'compressed-file?' matches ".lzma" files.
* guix/utils.scm (compressed-file?): Add "lzma" to the list.
2017-05-15 23:55:10 +02:00
Leo Famulari 6c17422eac
utils: Fix handling of shell arguments for xz compression.
Fixes test failures related to xz compression in tests/utils.scm.

This is a followup to commit 63102406f2.

* guix/utils.scm (decompressed-port, compressed-port, compressed-output-port):
Split each shell argument into its own list element.
2017-04-03 23:23:39 -04:00
Efraim Flashner 63102406f2
guix: Compress and decompress xz archives in parallel.
* guix/scripts/pack.scm (%compressors): Add flag '-T0' when calling "xz".
* guix/utils.scm (decompressed-port, compressed-port,
compressed-output-port): Same.
2017-04-02 14:42:20 +03:00
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
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