Archived
1
0
Fork 0

build-system/qt: Wrappers only include relevant directories to XDG_DATA_DIRS.

Fixes <https://bugs.gnu.org/47569>.

Previously the wrapper's XDG_DATA_DIRS would contain any input that had
a /share sub-directory, which is usually all build-time inputs.

* guix/build/qt-build-system.scm (variables-for-wrapping)[collect-sub-dirs]:
Add 'selectors' parameter and honor it.  Change caller to handle
selectors.  Add selectors for /share.
This commit is contained in:
Ludovic Courtès 2021-04-08 22:17:03 +02:00
parent eb6ac483a5
commit c5fd1b0bd3
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014 Federico Beffa <beffa@fbengineering.ch> ;;; Copyright © 2014 Federico Beffa <beffa@fbengineering.ch>
;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2014, 2015, 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2018 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2019, 2020 Hartmut Goebel <h.goebel@crazy-compilers.com> ;;; Copyright © 2019, 2020 Hartmut Goebel <h.goebel@crazy-compilers.com>
;;; ;;;
@ -49,25 +49,45 @@
(define (variables-for-wrapping base-directories) (define (variables-for-wrapping base-directories)
(define (collect-sub-dirs base-directories subdirectory) (define (collect-sub-dirs base-directories subdirectory
(filter-map selectors)
(lambda (dir) ;; Append SUBDIRECTORY and each of BASE-DIRECTORIES, and return the subset
(let ((directory (string-append dir subdirectory))) ;; that exists and has at least one of the SELECTORS sub-directories,
(if (directory-exists? directory) directory #f))) ;; unless SELECTORS is the empty list.
base-directories)) (filter-map (lambda (dir)
(let ((directory (string-append dir subdirectory)))
(and (directory-exists? directory)
(or (null? selectors)
(any (lambda (selector)
(directory-exists?
(string-append directory selector)))
selectors))
directory)))
base-directories))
(filter (filter-map
(lambda (var-to-wrap) (not (null? (last var-to-wrap)))) (match-lambda
(map ((variable directory selectors ...)
(lambda (var-spec) (match (collect-sub-dirs base-directories directory
`(,(first var-spec) = ,(collect-sub-dirs base-directories (last var-spec)))) selectors)
(list (()
;; these shall match the search-path-specification for Qt and KDE #f)
;; libraries (directories
'("XDG_DATA_DIRS" "/share") `(,variable = ,directories)))))
'("XDG_CONFIG_DIRS" "/etc/xdg")
'("QT_PLUGIN_PATH" "/lib/qt5/plugins") ;; These shall match the search-path-specification for Qt and KDE
'("QML2_IMPORT_PATH" "/lib/qt5/qml"))))) ;; libraries.
(list '("XDG_DATA_DIRS" "/share"
;; These are "selectors": consider /share if and only if at least
;; one of these sub-directories exist. This avoids adding
;; irrelevant packages to XDG_DATA_DIRS just because they have a
;; /share sub-directory.
"/glib-2.0/schemas" "/sounds" "/themes"
"/cursors" "/wallpapers" "/icons" "/mime")
'("XDG_CONFIG_DIRS" "/etc/xdg")
'("QT_PLUGIN_PATH" "/lib/qt5/plugins")
'("QML2_IMPORT_PATH" "/lib/qt5/qml"))))
(define* (wrap-all-programs #:key inputs outputs (define* (wrap-all-programs #:key inputs outputs
(qt-wrap-excluded-outputs '()) (qt-wrap-excluded-outputs '())