mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2026-04-06 21:20:33 +02:00
derivations: Let ‘map-derivation’ correctly handle directories.
The 'map-derivation' procedure was trying to process directories as files.
When a derivation had a 'module import' directory as input, it threw an
exception since it tried to open it as a file.
* guix/derivations.scm (map-derivation): In ‘sources’, add
‘file-is-directory?’ case.
* tests/derivations.scm ("map-derivation, modules"): New test.
Fixes: https://issues.guix.gnu.org/71941
Change-Id: I9b766f9aaa03ea9307f73e8abb36bc347af4b5e6
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
committed by
Ludovic Courtès
parent
2d5ba988d5
commit
cf2a11b966
@@ -1,6 +1,7 @@
|
||||
;;; GNU Guix --- Functional package management for GNU
|
||||
;;; Copyright © 2012-2021, 2023-2024 Ludovic Courtès <ludo@gnu.org>
|
||||
;;; Copyright © 2016, 2017 Mathieu Lirzin <mthl@gnu.org>
|
||||
;;; Copyright © 2025 Sergio Pastor Pérez <sergio.pastorperez@gmail.com>
|
||||
;;;
|
||||
;;; This file is part of GNU Guix.
|
||||
;;;
|
||||
@@ -1074,8 +1075,10 @@ recursively."
|
||||
((_ . replacement)
|
||||
replacement)
|
||||
(#f
|
||||
(substitute-file source
|
||||
initial replacements))))
|
||||
(if (file-is-directory? source)
|
||||
source
|
||||
(substitute-file source
|
||||
initial replacements)))))
|
||||
(derivation-sources drv)))
|
||||
|
||||
;; Now augment the lists of initials and replacements.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
;;; GNU Guix --- Functional package management for GNU
|
||||
;;; Copyright © 2012-2026 Ludovic Courtès <ludo@gnu.org>
|
||||
;;; Copyright © 2025 Sergio Pastor Pérez <sergio.pastorperez@gmail.com>
|
||||
;;;
|
||||
;;; This file is part of GNU Guix.
|
||||
;;;
|
||||
@@ -20,6 +21,7 @@
|
||||
|
||||
(define-module (test-derivations)
|
||||
#:use-module (guix derivations)
|
||||
#:use-module (guix gexp)
|
||||
#:use-module (guix store)
|
||||
#:use-module (guix utils)
|
||||
#:use-module ((gcrypt hash) #:prefix gcrypt:)
|
||||
@@ -1606,6 +1608,29 @@
|
||||
(and (build-derivations %store (list (pk 'remapped* drv2)))
|
||||
(call-with-input-file out get-string-all))))
|
||||
|
||||
(test-assert "map-derivation, modules"
|
||||
(let* ((bash-drv (package-derivation %store (@ (gnu packages bash) bash)))
|
||||
(bash-input (car (derivation-inputs bash-drv)))
|
||||
(bash-input-drv (derivation-input-derivation bash-input))
|
||||
(drv-with-modules (run-with-store %store
|
||||
(gexp->derivation "derivation-with-modules"
|
||||
(with-imported-modules '((guix build utils))
|
||||
#~(begin
|
||||
(use-modules (guix build utils))
|
||||
(mkdir-p (string-append #$output
|
||||
"/bin")))))))
|
||||
(bash-mapped-1 (map-derivation %store bash-drv
|
||||
`((,bash-input-drv . ,drv-with-modules))))
|
||||
(bash-mapped-2 (map-derivation %store bash-mapped-1
|
||||
`((,drv-with-modules . ,bash-input-drv))))
|
||||
(is-input? (lambda (in drv)
|
||||
(not (null? (filter (lambda (input)
|
||||
(eq? in (derivation-input-derivation input)))
|
||||
(derivation-inputs drv)))))))
|
||||
(and
|
||||
(not (is-input? bash-input-drv bash-mapped-1))
|
||||
(is-input? bash-input-drv bash-mapped-2))))
|
||||
|
||||
(test-end)
|
||||
|
||||
;; Local Variables:
|
||||
|
||||
Reference in New Issue
Block a user