Commit Graph

140 Commits

Author SHA1 Message Date
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