From 9fb8a480d5aec9186908e92ad18b31455f4aab6b Mon Sep 17 00:00:00 2001 From: Simon Tournier Date: Sat, 11 Mar 2023 17:51:10 +0100 Subject: [PATCH] packages: Consider 'patches' by 'package-direct-sources'. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/packages.scm (package-direct-sources): Return 'origin' from 'patches'. * tests/packages.scm: Test it. Signed-off-by: Ludovic Courtès --- guix/packages.scm | 10 ++++++++-- tests/packages.scm | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/guix/packages.scm b/guix/packages.scm index 041a872f9d..7b098e21f0 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -9,6 +9,7 @@ ;;; Copyright © 2021 Chris Marusich ;;; Copyright © 2022 Maxime Devos ;;; Copyright © 2022 jgart +;;; Copyright © 2023 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -1239,8 +1240,13 @@ input list." (define (package-direct-sources package) "Return all source origins associated with PACKAGE; including origins in -PACKAGE's inputs." - `(,@(or (and=> (package-source package) list) '()) +PACKAGE's inputs and patches." + (define (expand source) + (cons + source + (filter origin? (origin-patches source)))) + + `(,@(or (and=> (package-source package) expand) '()) ,@(filter-map (match-lambda ((_ (? origin? orig) _ ...) orig) diff --git a/tests/packages.scm b/tests/packages.scm index f58c47817b..27fb918f90 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2021 Maxim Cournoyer ;;; Copyright © 2021 Maxime Devos +;;; Copyright © 2023 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -418,12 +419,15 @@ (let* ((o (dummy-origin)) (u (dummy-origin)) (i (dummy-origin)) + (j (dummy-origin (patches (list o)))) (a (dummy-package "a")) (b (dummy-package "b" (inputs (list a i)))) (c (package (inherit b) (source o))) (d (dummy-package "d" (build-system trivial-build-system) - (source u) (inputs (list c))))) + (source u) (inputs (list c)))) + (e (dummy-package "e" (source j))) + (f (package (inherit e) (inputs (list u))))) (test-assert "package-direct-sources, no source" (null? (package-direct-sources a))) (test-equal "package-direct-sources, #f source" @@ -437,6 +441,17 @@ (and (= (length (pk 's-sources s)) 2) (member o s) (member i s)))) + (test-assert "package-direct-sources, with patches" + (let ((s (package-direct-sources e))) + (and (= (length (pk 's-sources s)) 2) + (member o s) + (member j s)))) + (test-assert "package-direct-sources, with patches and inputs" + (let ((s (package-direct-sources f))) + (and (= (length (pk 's-sources s)) 3) + (member o s) + (member j s) + (member u s)))) (test-assert "package-transitive-sources" (let ((s (package-transitive-sources d))) (and (= (length (pk 'd-sources s)) 3)