From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Lepiller Subject: bug#22138: Search paths of dependencies are not honored Date: Thu, 1 Aug 2019 22:12:06 +0200 Message-ID: <20190801221206.17965136@sybil.lepiller.eu> References: <87bn9yk5mf.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/P7b3w4QD0RSr.lNrEvJblE1" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:53311) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htHRk-0001ul-2Y for bug-guix@gnu.org; Thu, 01 Aug 2019 16:13:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htHRi-0002wQ-L4 for bug-guix@gnu.org; Thu, 01 Aug 2019 16:13:08 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46585) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htHRe-0002uu-5r for bug-guix@gnu.org; Thu, 01 Aug 2019 16:13:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1htHRd-0007xs-UO for bug-guix@gnu.org; Thu, 01 Aug 2019 16:13:01 -0400 In-Reply-To: <87bn9yk5mf.fsf@gnu.org> Sender: "Debbugs-submit" Resent-Message-ID: List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: 22138@debbugs.gnu.org --MP_/P7b3w4QD0RSr.lNrEvJblE1 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, I've been looking at our current code and would like to propose the attached patch for that issue. --MP_/P7b3w4QD0RSr.lNrEvJblE1 Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-guix-Recursively-honor-search-paths-of-dependencies.patch >From cfd2c229087166ab4cc0a9e2bdb72c8b393bcdd5 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Thu, 1 Aug 2019 22:09:38 +0200 Subject: [PATCH] guix: Recursively honor search paths of dependencies. * guix/packages.scm (all-transitive-inputs) (package-all-transitive-inputs) (package-all-transitive-native-search-paths): New procedures. * guix/profiles.scm (package->manifest-entry): Use package-all-transitive-native-search-paths to generate manifest search paths. --- guix/packages.scm | 53 +++++++++++++++++++++++++++++++++++++++++++++++ guix/profiles.scm | 2 +- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/guix/packages.scm b/guix/packages.scm index c94a651f27..f9095759f1 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -101,6 +101,7 @@ package-transitive-propagated-inputs package-transitive-native-search-paths package-transitive-supported-systems + package-all-transitive-native-search-paths package-mapping package-input-rewriting package-input-rewriting/spec @@ -686,6 +687,42 @@ preserved, and only duplicate propagated inputs are removed." ((input rest ...) (loop rest (cons input result) propagated first? seen))))) +(define (all-transitive-inputs inputs) + "Return the closure of INPUTS when considering the 'propagated-inputs', +'inputs' and 'native-inputs' edges. Omit duplicate inputs, except for +those already present in INPUTS itself. + +This is implemented as a breadth-first traversal such that INPUTS is +preserved, and only duplicate propagated inputs are removed." + (define (seen? seen item outputs) + ;; FIXME: We're using pointer identity here, which is extremely sensitive + ;; to memoization in package-producing procedures; see + ;; . + (match (vhash-assq item seen) + ((_ . o) (equal? o outputs)) + (_ #f))) + + (let loop ((inputs inputs) + (result '()) + (transitive '()) + (first? #t) + (seen vlist-null)) + (match inputs + (() + (if (null? transitive) + (reverse result) + (loop (reverse (concatenate transitive)) result '() #f seen))) + (((and input (label (? package? package) outputs ...)) rest ...) + (if (and (not first?) (seen? seen package outputs)) + (loop rest result transitive first? seen) + (loop rest + (cons input result) + (cons (package-direct-inputs package) transitive) + first? + (vhash-consq package outputs seen)))) + ((input rest ...) + (loop rest (cons input result) transitive first? seen))))) + (define (package-direct-sources package) "Return all source origins associated with PACKAGE; including origins in PACKAGE's inputs." @@ -720,6 +757,11 @@ with their propagated inputs." with their propagated inputs, recursively." (transitive-inputs (package-direct-inputs package))) +(define (package-all-transitive-inputs package) + "Return the transitive inputs of PACKAGE---i.e., its direct inputs along +with their propagated inputs, recursively." + (all-transitive-inputs (package-direct-inputs package))) + (define (package-transitive-target-inputs package) "Return the transitive target inputs of PACKAGE---i.e., its direct inputs along with their propagated inputs, recursively. This only includes inputs @@ -749,6 +791,17 @@ recursively." '())) (package-transitive-propagated-inputs package)))) +(define (package-all-transitive-native-search-paths package) + "Return the list of search paths for PACKAGE and its propagated inputs, +recursively." + (append (package-native-search-paths package) + (append-map (match-lambda + ((label (? package? p) _ ...) + (package-native-search-paths p)) + (_ + '())) + (package-all-transitive-inputs package)))) + (define (transitive-input-references alist inputs) "Return a list of (assoc-ref ALIST