From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Subject: bug#22138: Search paths of dependencies are not honored Date: Fri, 23 Aug 2019 16:42:08 +0200 Message-ID: <87d0gw54fz.fsf@gnu.org> References: <87bn9yk5mf.fsf@gnu.org> <20190801221206.17965136@sybil.lepiller.eu> <87ftmfa8cp.fsf@netris.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:52522) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1AmO-0002Gw-OU for bug-guix@gnu.org; Fri, 23 Aug 2019 10:43:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i1AmN-0001Pp-Au for bug-guix@gnu.org; Fri, 23 Aug 2019 10:43:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:60387) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i1AmN-0001PD-84 for bug-guix@gnu.org; Fri, 23 Aug 2019 10:43:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i1AmM-00030D-5j for bug-guix@gnu.org; Fri, 23 Aug 2019 10:43:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87ftmfa8cp.fsf@netris.org> (Mark H. Weaver's message of "Mon, 05 Aug 2019 12:23:55 -0400") 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: Mark H Weaver Cc: 22138@debbugs.gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Mark, Mark H Weaver skribis: > Julien Lepiller writes: > >> Hi, I've been looking at our current code and would like to propose the >> attached patch for that issue. >> >> 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. > > As I recall this kind of solution has been proposed in the past and > rejected. It's a reasonable suggestion, but I personally think that it > goes too far, because it would include a great many packages whose code > is nowhere to be found in the resulting profile. I agree. We need to take into account run-time dependencies (references), not build-time dependencies, and that=E2=80=99s what makes things more difficul= t. The attached procedure computes the search paths of a package based on its run-time dependencies. =E2=80=98profile-derivation=E2=80=99 could use = this to compute its =E2=80=98etc/profile=E2=80=99 file and its =E2=80=98manifest=E2= =80=99 file. Here=E2=80=99s what it gives for =E2=80=98w3m=E2=80=99: --8<---------------cut here---------------start------------->8--- (("BASH_LOADABLES_PATH" ("lib/bash") ":" directory #f) ("GUIX_LOCPATH" ("lib/locale") ":" directory #f) ("SSL_CERT_DIR" ("etc/ssl/certs") #f directory #f) ("SSL_CERT_FILE" ("etc/ssl/certs/ca-certificates.crt") #f regular #f) ("TERMINFO_DIRS" ("share/terminfo") ":" directory #f) ("XDG_DATA_DIRS" ("share") ":" directory #f) ("GIO_EXTRA_MODULES" ("lib/gio/modules") ":" directory #f) ("PERL5LIB" ("lib/perl5/site_perl") ":" directory #f)) --8<---------------cut here---------------end--------------->8--- We get GUIX_LOCPATH and SSL_CERT_DIR, which is exactly what we want. However, the other search paths that we get look less desirable: intuitively, it seems that we may not need them, and in the case of XDG_DATA_DIRS, setting it may be detrimental. For =E2=80=98icecat=E2=80=99 this gives additional things like PYTHONPATH, GUILE_LOAD_PATH, XML_CATALOG_FILES, and so on. In practice that=E2=80=99s probably OK though: if you only have =E2=80=98ic= ecat=E2=80=99 and other GUIs in your profile, Guix won=E2=80=99t suggest setting GUILE_LOAD_P= ATH or PYTHONPATH. So I think we can come up with a solution based on the patch below, but we=E2=80=99ll have to test it on Guix System and on foreign distros to see = if the extra search paths that it brings are warranted. Thoughts? Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/guix/packages.scm b/guix/packages.scm index c94a651f27..7d5c8198ac 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -26,6 +26,7 @@ #:use-module (guix store) #:use-module (guix monads) #:use-module (guix gexp) + #:use-module (guix modules) #:use-module (guix base32) #:use-module (guix grafts) #:use-module (guix derivations) @@ -749,6 +750,64 @@ recursively." '())) (package-transitive-propagated-inputs package)))) +(define (package-run-time-search-paths package) + "Return a file that contains a list of search path specifications +corresponding to the run-time references of PACKAGE." + (define search-paths + (map (lambda (package) + (cons (package-full-name package "-") + (map search-path-specification->sexp + (package-native-search-paths package)))) + (package-closure (list package)))) + + (define build + (with-imported-modules (source-module-closure + '((guix build utils) + (guix search-paths) + (guix build store-copy))) + #~(begin + (use-modules (guix build utils) + (guix build store-copy) + (guix search-paths) + (srfi srfi-1) + (ice-9 match) + (ice-9 pretty-print)) + + (define search-paths + ;; Map items like "coreutils-8.20" to their search path specs. + (map (match-lambda + ((item . paths) + (cons item (map sexp->search-path-specification paths)))) + '#$search-paths)) + + (define (store-item-search-paths item) + "Return the search paths that apply to ITEM, a store item." + (or (any (match-lambda + ((entry . paths) + (and (string-suffix? entry item) + paths))) + search-paths) + '())) + + (let* ((references (map store-info-item + (call-with-input-file "graph" + read-reference-graph))) + (paths (delete-duplicates + (append-map store-item-search-paths + references)))) + (call-with-output-file #$output + (lambda (port) + (pretty-print (map search-path-specification->sexp + paths) + port))))))) + + (computed-file (string-append (package-full-name package "-") + "-search-paths") + build + #:options + `(#:references-graphs (("graph" ,package)) + #:properties '((type . search-paths))))) + (define (transitive-input-references alist inputs) "Return a list of (assoc-ref ALIST