aboutsummaryrefslogtreecommitdiff
path: root/guix/build/utils.scm
Commit message (Collapse)AuthorAge
* guix: build: Avoid using magic literals in the code for hash length.Attila Lendvai2022-09-02
| | | | | | | | | * guix/build/utils.scm (%store-hash-string-length): New constant. (store-path-prefix-length): Factor out the calculation of the total store prefix length. * guix/build/graft.scm (hash-length): Use it. Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
* guix: build: Promote local define-inline to a define-constant util.Attila Lendvai2022-09-02
| | | | | | | * guix/build/utils.scm: Moved/renamed define-inline from grafts.scm to an exported define-constant util. Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
* utils: Make switch-symlinks robust against interruption.Arun Isaac2022-06-25
| | | | | | | * guix/build/utils.scm (switch-symlinks): Delete pivot link if it already exists. Co-authored-by: Maxime Devos <maximedevos@telenet.be>
* utils: Move switch-symlinks to (guix build utils).Arun Isaac2022-06-25
| | | | | | | | | * guix/utils.scm (switch-symlinks): Move to ... * guix/build/utils.scm (switch-symlinks): ... here. * guix/profiles.scm, guix/scripts/home.scm, guix/scripts/package.scm: Import switch-symlinks from (guix build utils). * guix/scripts/system/reconfigure.scm (switch-system-program): Import (guix build utils) in G-expression.
* Merge branch 'staging' into core-updates.Maxim Cournoyer2022-01-25
|\ | | | | | | | | | | | | | | | | | | With "conflicts" resolved in (mostly in favor of master/staging): gnu/packages/admin.scm gnu/packages/gnuzilla.scm gnu/packages/gtk.scm gnu/packages/kerberos.scm gnu/packages/linux.scm guix/lint.scm
| * utils: Fix wrap-script argument handling.Brendan Tildesley2022-01-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * guix/build/utils.scm (wrap-script): Don't add (car cl) one too many times, cl its self contains it's car. Split the aguments string with string-tokenize to avoid leaving an empty string argument when there should be none. These two bugs seemed to be partially cancelling each other out so that scripts still worked when ran with no arguments. * tests/build-utils.scm: Adjust wrap-script to above changes. Add two tests to ensure the command line arguments appear identical to a script and its wrapped version. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
* | build/minetest-build-system: Move png-file? to (guix build utils).Maxime Devos2021-10-02
|/ | | | | | | | | | | It's not really Minetest-specific. It was only placed in (guix build minetest-build-system) to avoid a world rebuild. * guix/build/minetest-build-system.scm (%png-magic-bytes,png-file?): Move to ... * guix/build/utils.scm (%png-magic-bytes,png-file?): ... here. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
* build: utils: Trim leading slash from search-input-file input.Mathieu Othacehe2021-07-25
| | | | | | | | | | | Make sure that both: (search-input-file inputs "/bin/sh") and (search-input-file inputs "bin/sh") are supported. * guix/build/utils (search-input-file): Trim leading slash character from FILE.
* utils: Add 'search-input-directory'.Ludovic Courtès2021-07-08
| | | | | | * guix/build/utils.scm (search-input-directory): New procedure. * doc/guix.texi (Build Utilities): Document it next to 'search-input-file'. Tweak wording.
* utils: Define ‘search-input-file’ procedure.Maxime Devos2021-06-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The procedure ‘which’ from (guix build utils) is used for two different purposes: 1. for finding the absolute file name of a binary that needs to run during the build process 2. for finding the absolute file name of a binary, for the target system (as in --target=TARGET), e.g. for substituting sh->/gnu/store/.../bin/sh, python->/gnu/store/.../bin/python. When compiling natively (target=#f in Guix parlance), this is perfectly fine. However, when cross-compiling, there is a problem. "which" looks in $PATH for binaries. That's good for purpose (1), but incorrect for (2), as the $PATH contains binaries from native-inputs instead of inputs. This commit defines a ‘search-input-file’ procedure. It functions like 'which', but instead of searching in $PATH, it searches in the 'inputs' of the build phase, which must be passed to ‘search-input-file’ as an argument. Also, the file name must include "bin/" or "sbin/" as appropriate. * guix/build/utils.scm (search-input-file): New procedure. * tests/build-utils.scm ("search-input-file: exception if not found") ("search-input-file: can find if existent"): Test it. * doc/guix.texi (File Search): Document it. Partially-Fixes: <https://issues.guix.gnu.org/47869> Co-Authored-By: Ludovic Courtès <ludo@gnu.org> Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* utils: Allow overriding the shell interpreter in ‘wrap-program’.Maxime Devos2021-06-04
| | | | | | | | | | | | | | | | Previously, when creating new wrappers, 'wrap-program' would search for an interpreter to use in PATH. However, this is incorrect when cross-compiling. Allow overriding the shell interpreter to use, via an optional keyword argument #:sh. In time, when all users of 'wrap-program' have been corrected, this keyword argument can be made mandatory. * guix/build/utils.scm (wrap-program): Introduce a #:sh keyword argument, defaulting to (which "sh"). Use this keyword argument. Partially-Fixes: <https://issues.guix.gnu.org/47869> Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* utils: wrap-program: Refuse to wrap .X-real files.Brendan Tildesley2021-04-22
| | | | | | | | | * guix/build/utils.scm (wrap-program): Error if wrap-program was mistakenly passed a .X-real file. This prevents and forces us to fix cases where a double wrapped ..X-real-real file is created, such as can be seen with: "find /gnu/ -iname '.*-real-real'". Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* utils: Rename 'wrapper?' to 'wrapped-program?'.Brendan Tildesley2021-04-22
| | | | | | | | | | * guix/build/utils.scm (wrap-program): The wrapper? procedure is incorrectly named as it actually checks to see if prog is the original program that was moved, not the wrapper. * guix/build/python-build-system: (wrap): Use renamed wrapped-program?. * gnu/packages/ebook.scm (calibre)[arguments]: Likewise. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* build-systems/gnu: Allow unpacking/repacking more kind of files.Maxim Cournoyer2021-01-26
| | | | | | | | | | | | | | | | | | | | | | | Before this change, only plain directories, tar or zip archives were supported as the source of a package for the GNU build system; anything else would cause the unpack phase to fail. Origins relying on snippets would suffer from the same problem. This change adds the support to use files of the following extensions: .gz, .Z, .bz2, .lz, and .xz, even when they are not tarballs. Files of unknown extensions are treated as uncompressed files and supported as well. * guix/packages.scm (patch-and-repack): Only add the compressor utility to the PATH when the file is compressed. Bind more inputs in the mlet, and use them for decompressing single files. Adjust the decompression and compression routines. [decompression-type]: Remove nested variable. * guix/build/utils.scm (compressor, tarball?): New procedures. Move %xz-parallel-args to the new 'compression helpers' section. * tests/packages.scm: Add tests. Add missing copyright year for Jan. * guix/build/gnu-build-system.scm (first-subdirectory): Return #f when no sub-directory was found. (unpack): Support more file types, including uncompressed plain files.
* utils: Add NIX_STORE_DIR as a candidate for the value of the store directory.Maxim Cournoyer2021-01-26
| | | | | | | | | | | | | On the daemon side, nixStore gets set to the environment variable NIX_STORE_DIR, else the environment variable NIX_STORE else the compile time macro NIX_STORE_DIR (see the Settings::processEnvironment method in nix/libstore/globals.cc). When creating a build environment, it sets NIX_STORE with the value computed as described above. Hence, it's safer to look for both NIX_STORE_DIR and NIX_STORE in (guix build utils), so that it works in any context (build context or external context). * guix/build/utils.scm (%store-directory): Consider both NIX_STORE_DIR and NIX_STORE as environment variables.
* 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.