summaryrefslogtreecommitdiff
path: root/guix/build/utils.scm
Commit message (Collapse)AuthorAge
* utils: Allow text substitution even in the presence of NUL characters.Mark H Weaver2021-01-08
| | | | | | | | | | | | | | | | | | | | | | Fixes <https://issues.guix.gnu.org/30116>. Before this change, the presence of a NUL character on a line meant that the (glibc) regexp engine used by Guile would either 1. stop scanning the string or 2. crash with the error "string contains #\\nul character", depending on the locale used. This change works around this limitation by first replacing the NUL character by an unused Unicode code point, doing the substitution, then reverting the replacement. * guix/build/utils.scm (unused-private-use-code-point) (replace-char): New procedures. (substitute): Make use of the above procedures to work around the NUL character regexp engine limitation. * tests/build-utils.scm: Add tests. Co-authored-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
* utils: 'copy-recursively' keeps symlink mtime when #:keep-mtime? is true.Ludovic Courtès2020-12-13
| | | | | * guix/build/utils.scm (copy-recursively): In the "leaf" procedure, call 'set-file-time' also on symlinks.
* utils: 'set-file-time' passes AT_SYMLINK_NOFOLLOW.Ludovic Courtès2020-12-13
| | | | | * guix/build/utils.scm (AT_SYMLINK_NOFOLLOW): New variable. (set-file-time): Use it.
* utils: Add #:keep-permissions? parameter to 'copy-recursively'.Ludovic Courtès2020-11-19
| | | | | | * guix/build/utils.scm (copy-recursively): Add #:keep-permissions? and honor it. * doc/guix.texi (Build Utilities): Adjust accordingly.
* utils: Add #:copy-file parameter to 'copy-recursively'.Ludovic Courtès2020-11-19
| | | | | * guix/build/utils.scm (copy-recursively): Add #:copy-file and honor it. * doc/guix.texi (Build Utilities): Adjust accordingly.
* utils: 'copy-recursively' keeps directory mtime when #:keep-mtime? is true.Ludovic Courtès2020-11-19
| | | | | | | Fixes <https://bugs.gnu.org/44741>. * guix/build/utils.scm (copy-recursively): Move 'set-file-time' call from 'down' to 'up'.
* utils: 'wrap-script' doesn't pass a non-literal string to 'format'.Ludovic Courtès2020-11-17
| | | | | | | | Reported by Vagrant Cascadian <vagrant@debian.org> in <https://bugs.gnu.org/44626>. * guix/build/utils.scm (wrap-script): Use 'display' instead of passing a non-literal string to 'format'.
* packages, scripts, utils: Enable multi-threaded xz compression.Maxim Cournoyer2020-10-08
| | | | | | | | | | | | | | | | | 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.
* utils: Do not raise exceptions in delete-file-recursively.Maxim Cournoyer2020-10-08
| | | | | | | | | | | | | This makes it so that delete-file-recursively honors its docstring, which says it should "report but ignore errors". Fixes <https://issues.guix.gnu.org/43366>. * guix/build/utils.scm (warn-on-error): New syntax. (delete-file-recursively): Use it to catch exceptions and print warning messages. Reported-by: Fredrik Salomonsson <plattfot@gmail.com>
* utils: Add 'call-with-temporary-output-file'.Ludovic Courtès2020-09-19
| | | | | | * 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.
* utils: 'dump-port' has an optional 'len' parameter.Ludovic Courtès2020-09-10
| | | | | * guix/build/utils.scm (dump-port): Add optional 'len' parameter and honor it.
* build: substitute*: Fix typo in example.Efraim Flashner2020-05-25
| | | | | * guix/build/utils.scm (substitute*): Fix typo in example in docstring, use consistent variable names.
* utils: Change 'patch-shebang' to not try to patch Rust source files.Danny Milosavljevic2020-02-17
| | | | * guix/build/utils.scm (patch-shebang): Match only absolute paths.
* guix: Fix missing export for make-desktop-entry-file.Pierre Neidhardt2020-01-30
| | | | * guix/build/utils.scm: Export make-desktop-entry-file.
* guix: Add helper for generating desktop entry files.Pierre Neidhardt2019-10-19
| | | | * guix/build/utils.scm (make-desktop-entry-file): New procedure.
* utils: Add 'invoke/quiet'.Ludovic Courtès2019-06-17
| | | | | | | | | | | * gnu/build/bootloader.scm (G_): Remove. (open-pipe-with-stderr, invoke/quiet): Move to... * guix/build/utils.scm: ... here. Use 'let-values' instead of 'define-values' because Guile 2.0 (the bootstrap Guile) doesn't know about 'define-values'. * po/guix/POTFILES.in: Remove gnu/build/bootloader.scm, and add guix/build/utils.scm. * tests/build-utils.scm: Remove import of (gnu build bootloader).
* guix: Add wrap-script.Ricardo Wurmus2019-02-08
| | | | | | | | * guix/build/utils.scm (wrap-script): New procedure. (&wrap-error): New condition. (wrap-error?, wrap-error-program, wrap-error-type): New procedures. * tests/build-utils.scm ("wrap-script, simple case", "wrap-script, with encoding declaration", "wrap-script, raises condition"): New tests.
* build-system/gnu: Report invocation errors in a human-friendly way.Ludovic Courtès2019-01-29
| | | | | | * guix/build/utils.scm (report-invoke-error): New procedure. * guix/build/gnu-build-system.scm (gnu-build): Guard against 'invoke-error?'.
* utils: Switch to the new 'setvbuf' API.Ludovic Courtès2019-01-29
| | | | | | | * guix/build/utils.scm (setvbuf) [(and guile-2 (not guile-2.2))]: New procedure. (remove-store-references): Use the 2.2 'setvbuf' API style. * guix/build/gnu-build-system.scm (gnu-build): Likewise.
* build-system: python: Do not double wrap executables.Arun Isaac2018-11-25
| | | | | | * guix/build/python-build-system.scm (wrap): Only wrap executables that have not already been wrapped. * guix/build/utils.scm (wrapper?): New function.
* utils: Generate valid substitutions in 'wrap-program'.Jelle Licht2018-08-20
| | | | | * guix/build/utils.scm (wrap-program)[export-variable]: Generate valid bash substitutions when using custom separators.
* utils: invoke: Raise exceptions using SRFI-34 and SRFI-35.Mark H Weaver2018-03-16
| | | | | | | | | | * guix/build/utils.scm (&invoke-error): New condition type. (invoke-error?, invoke-error-program, invoke-error-arguments) (invoke-error-exit-status, invoke-error-term-signal) (invoke-error-stop-signal): New exported procedures. (invoke): Raise exceptions using SRFI-34 and SRFI-35. * guix/ui.scm (call-with-error-handling): Add a guard clause for &invoke-error conditions.
* utils: Add 'false-if-file-not-found'.Ludovic Courtès2018-03-11
| | | | * guix/build/utils.scm (false-if-file-not-found): New macro.
* guix: Fix Guile current-processor-count deprecation warnings.Mathieu Othacehe2017-09-05
| | | | | | | | | When current-processor-count is used without (ice-9 threads) being used, Guile complains with the following warning: Import (ice-9 threads) to have access to `current-processor-count'. * guix/build/utils.scm: Use (ice-9 threads).
* utils: Add helper for invoking programs.Danny Milosavljevic2017-06-01
| | | | | | * guix/build/utils.scm (invoke): New variable. Co-authored-by: Ludovic Courtès <ludo@gnu.org>
* utils: Re-export 'delete'.Sergei Trofimovich2017-05-26
| | | | | | * guix/build/utils.scm: Reexport 'delete' binding. Co-authored-by: Ludovic Courtès <ludo@gnu.org>
* utils: Add helper method to make files writable.Marius Bakke2017-01-26
| | | | | | * gnu/build/activation.scm (make-file-writable): Move this to ... * guix/build/utils.scm (make-file-writable): ... here. Export it. * guix/build/gnu-build-system.scm (strip): Use it.
* utils: Add 'gzip-file?' and 'reset-gzip-timestamp'.Ludovic Courtès2017-01-26
| | | | | * guix/build/utils.scm (%gzip-magic-bytes): New variable. (gzip-file?, reset-gzip-timestamp): New procedures.
* search-paths: Allow specs with #f as their separator.Ludovic Courtès2017-01-23
| | | | | | | | | | | | | | | | | | | | | This adds support for single-entry search paths. Fixes <http://bugs.gnu.org/25422>. Reported by Leo Famulari <leo@famulari.name>. * guix/search-paths.scm (<search-path-specification>)[separator]: Document as string or #f. (evaluate-search-paths): Add case for SEPARATOR as #f. (environment-variable-definition): Handle SEPARATOR being #f. * guix/build/utils.scm (list->search-path-as-string): Add case for SEPARATOR as #f. (search-path-as-string->list): Likewise. * guix/build/profiles.scm (abstract-profile): Likewise. * tests/search-paths.scm: New file. * Makefile.am (SCM_TESTS): Add it. * tests/packages.scm ("--search-paths with single-item search path"): New test. * gnu/packages/version-control.scm (git)[native-search-paths](separator): New field.
* utils: 'wrap-program' produces only one wrapper file.Ludovic Courtès2016-09-07
| | | | | | | | | | * guix/build/utils.scm (wrap-program)[wrapper-file-name] [next-wrapper-number, wrapper-target]: Remove. [wrapped-file, already-wrapped?]: New variables. [last-line]: New procedure. Use it to append to PROG when a wrapper already exists. * tests/build-utils.scm ("wrap-program, one input, multiple calls"): Adjust the list of files to delete.
* utils: Fix 'modify-phases' docstring.Taylan Ulrich Bayırlı/Kammer2016-08-10
| | | | * guix/build/utils.scm (modify-phases): Fix the documentation string.
* utils: Have search-path-as-list pattern search for directories.Eric Bavier2015-10-29
| | | | | | * guix/build/utils.scm (search-path-as-list)[pattern]: Check requested file type. Check pattern against directory names. * guix/search-paths.scm (evaluate-search-paths)[pattern]: Remove symlink hack.
* utils: Add 'every*'.Ludovic Courtès2015-10-03
| | | | | * guix/build/gnu-build-system.scm (every*): Move to... * guix/build/utils.scm (every*): ... here. New procedure.
* utils: find-files: Add DIRECTORIES? and FAIL-ON-ERROR? arguments.Mark H Weaver2015-09-06
| | | | | * guix/build/utils.scm (find-files): Add DIRECTORIES? and FAIL-ON-ERROR? keyword arguments.
* utils: Move 'package-name->name+version' to (guix build utils).Ludovic Courtès2015-08-30
| | | | | | | | * 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.
* utils: Add 'strip-store-file-name'.Ludovic Courtès2015-08-30
| | | | | | | | * guix/build/utils.scm (strip-store-file-name): New procedure. * guix/build/emacs-build-system.scm (store-directory->name-version): Remove. Update callers to use 'strip-store-file-name'. * gnu/packages/gcc.scm (make-libstdc++-doc)[arguments]: Use 'strip-store-file-name' instead of 'string-drop'.
* utils: Add 'install-file'.Ludovic Courtès2015-08-29
| | | | * guix/build/utils.scm (install-file): New procedure.
* utils: 'find-files' does not follow symlinks by default.Ludovic Courtès2015-04-06
| | | | | | | | Fixes <http://bugs.gnu.org/20081>. Reported by Tomáš Čech <sleep_walker@suse.cz>. * guix/build/utils.scm (find-files): Add #:stat parameter. Pass it as last argument to 'file-system-fold'.
* gremlin: Ignore non-store file names in RUNPATH and warn about them.Ludovic Courtès2015-04-05
| | | | | | | | | * guix/build/gremlin.scm (validate-needed-in-runpath)[runpath]: Add (filter absolute-file-name? ...). Emit a warning when RUNPATH file names that do not match 'store-file-name?'. Change format of error message to begin with file name. * guix/build/utils.scm (store-file-name?): New procedure.
* utils: Make the second 'find-files' argument optional.Ludovic Courtès2015-04-01
| | | | * guix/build/utils.scm (find-files): Make 'pred' optional.
* utils: 'find-files' takes an arbitrary predicate as its second argument.Ludovic Courtès2015-03-31
| | | | | | | * guix/build/utils.scm (file-name-predicate): New procedure. (find-files): Rename second parameter to 'pred'. When 'pred' is not a procedure, call 'file-name-predicate'. Use PRED instead of 'regexp-exec' in the leaf procedure.
* utils: 'modify-phases' no longer introduces quotes.Ludovic Courtès2015-03-31
| | | | | | | | | | | | | | | | | | | Suggested by Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>. * guix/build/utils.scm (%modify-phases): Remove quotes. * guix/build/cmake-build-system.scm (%standard-phases): Adjust accordingly. * guix/build/glib-or-gtk-build-system.scm (%standard-phases): Likewise. * guix/build/gnu-dist.scm (%dist-phases): Likewise. * guix/build/perl-build-system.scm (%standard-phases): Likewise. * guix/build/python-build-system.scm (%standard-phases): Likewise. * guix/build/ruby-build-system.scm (%standard-phases): Likewise. * guix/build/waf-build-system.scm (%standard-phases): Likewise. * gnu/packages/bash.scm, gnu/packages/code.scm, gnu/packages/gl.scm, gnu/packages/gnome.scm, gnu/packages/graphics.scm, gnu/packages/image.scm, gnu/packages/key-mon.scm, gnu/packages/ocr.scm, gnu/packages/plotutils.scm, gnu/packages/search.scm, gnu/packages/video.scm: Likewise.
* utils: Treat 'configure' and Makefiles with an 8-bit encoding.Ludovic Courtès2015-02-28
| | | | | * guix/build/utils.scm (patch-makefile-SHELL, patch-/usr/bin/file): Wrap 'substitute*' in 'with-fluids'. Fixes <http://hydra.gnu.org/build/262895>.
* utils: Change 'patch-shebangs' to use binary input.Ludovic Courtès2015-02-28
| | | | | | | * guix/build/utils.scm (get-char*): New procedure. (patch-shebang): Use it instead of 'read-char'. (fold-port-matches): Remove local 'get-char' and use 'get-char*' instead.
* utils: Call the progress-report proc when 'dump-port' starts.Ludovic Courtès2015-02-27
| | | | | * guix/build/utils.scm (dump-port): Add call to PROGRESS at the beginning.
* build-system/gnu: Set $LC_ALL (or similar) to the chosen locale.Ludovic Courtès2015-02-27
| | | | | | | Suggested by Mark H Weaver. * guix/build/utils.scm (locale-category->string): New procedure. * guix/build/gnu-build-system.scm (install-locale): Add 'setenv' call.
* utils: Add 'modify-phases'.Ludovic Courtès2015-02-26
| | | | * guix/build/utils.scm (modify-phases): New macro.
* utils: Preserve symbolic links in 'wrap-program'.Andreas Enge2015-02-16
| | | | | | | | | * guix/build/utils.scm (wrap-program): Preserve symbolic links instead of copying the contents of the link. Co-authored-by: Ludovic Courtès <ludo@gnu.org> Closes <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19743>.
* utils: Use $0 instead of absolute path to original program in 'wrap-program'.Andreas Enge2015-02-16
| | | | | | | | | | * guix/build/utils.scm (wrap-program): Create scripts that use $0 (which is usually just the base name) instead of the absolute path to the original program. Alternative implementation of 2ed11b3. Co-authored-by: Ludovic Courtès <ludo@gnu.org> Closes <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19742>.
* utils: Strip duplicates from search path.Eric Bavier2015-02-10
| | | | | * guix/build/utils.scm (search-path-as-list): Delete duplicate input directories before searching.