From patchwork Thu Jan 23 06:28:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: tusharhero--- via Guix-patches via X-Patchwork-Id: 37615 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 564D727BBEB; Thu, 23 Jan 2025 06:27:33 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1EDDB27BBE2 for ; Thu, 23 Jan 2025 06:27:31 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1taqgE-0007HN-5X; Thu, 23 Jan 2025 01:27:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1taqgC-0007Gp-D6 for guix-patches@gnu.org; Thu, 23 Jan 2025 01:27:04 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1taqgB-0002hd-Uy for guix-patches@gnu.org; Thu, 23 Jan 2025 01:27:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=G7erAM1Py70vcrHfbE6aWiu2zVmRxzrQ+W5yk2hhb3A=; b=ShE5nCW0hXT+YBVN4GBaBXPZr50zcYSYR/lPcStMNzKIcff3BlDFqRO8HqBIJUpBFGqoLofTZFI8P0C7FnsbdaH8+tEAkn1qtfW3T8kvW7rXEEf5jFsUM7e/anlPRAyEAyRlAsvTYOuGMWREZmpOF2A4dCmtEnmwHzlLQqeAqlp+1V6qLgVIemNKLcuZgpky92ozvC477S2qf5T9H+d+UmeSijkZvEUI4rzB0oLrLvPTd9YOuWHSjq2hCTPXm5IES1YJzR1U4EN50nMvnWjf4n+uQEOd0CodqgoHjXwVsuuOw2DwX9LITQfLXdI9oJA4dTRQatKAOxJCB5CwCKsbhg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1taqgB-0007WE-AP; Thu, 23 Jan 2025 01:27:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#75688] [PATCH v2 4/4] build: glib-or-gtk-build-system: Replace wrapper scripts with 'search-paths.d'. Resent-From: iyzsong@envs.net Original-Sender: "Debbugs-submit" Resent-CC: liliana.prikler@gmail.com, maxim.cournoyer@gmail.com, vivien@planete-kraus.eu, guix-patches@gnu.org Resent-Date: Thu, 23 Jan 2025 06:27:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75688 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75688@debbugs.gnu.org Cc: =?utf-8?b?5a6L5paH5q2m?= , Liliana Marie Prikler , Maxim Cournoyer , Vivien Kraus X-Debbugs-Original-Xcc: Liliana Marie Prikler , Maxim Cournoyer , Vivien Kraus Received: via spool by 75688-submit@debbugs.gnu.org id=B75688.173761357028789 (code B ref 75688); Thu, 23 Jan 2025 06:27:03 +0000 Received: (at 75688) by debbugs.gnu.org; 23 Jan 2025 06:26:10 +0000 Received: from localhost ([127.0.0.1]:38743 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1taqfJ-0007U9-4m for submit@debbugs.gnu.org; Thu, 23 Jan 2025 01:26:10 -0500 Received: from mail.envs.net ([5.199.136.28]:52166) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1taqfA-0007T8-Qi for 75688@debbugs.gnu.org; Thu, 23 Jan 2025 01:26:02 -0500 Received: from localhost (mail.envs.net [127.0.0.1]) by mail.envs.net (Postfix) with ESMTP id E7F5B38A3E53; Thu, 23 Jan 2025 06:25:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=envs.net; s=modoboa; t=1737613559; bh=G7erAM1Py70vcrHfbE6aWiu2zVmRxzrQ+W5yk2hhb3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FQULegF7dfeM9S21gazYBo5JPZoO+ODJg2IrdyMTQF9LB0sTScuIo3a168XlDe74V SOpmxlgiQ/79nLndmVd4tpZngRtCypCczPHLr8X5Tn0WxYDB+BSkyrKxpW4NiWAA4T IP51cnM2NtupktYdtMvGg7T5jvBqnJrCIXAC5JmIDSFcMMITkpvIADl4sGHjPjvDbK uTfuVabAN0fgWAW/SRbEoHsAKfYO4O1aB0Rh57XazZYp3O2Dsrm6Ub2qS3ic1ls9BI +l0n7di0DtWCHEVV7aX6ZXEo6w5itKQZ3MVniF9mPp4NwmTbUAnV4tYZYfUDoinhYe ut+b9xYIbCSh72JD2bEvw9McfnSRU++VT1ousFtWSPhmV8Q7LPdnDcsctpZ9pwOabM Mc4J+UUKmHATii0bFA/HY7AhVpQInI9/ZyfsQhVFJ+VOTEbE73TcsfNNRLJTyA+p9a 6wgcgOdjJbDtBGoMbAnRsO2QKZuSmItzK3Frz5KbsqFUy+ZaHPy9qXMLETe8d/l9uy dEWPm3umB70L3XNObPZQxUFdKj3xh7f7hIINEDhS/pXpl3Y9CGldqJpVUa5PjR9ixB O0Fm/siqf4WnIM136WMsq4uRJu5DMH0OZtI4CDEsIIhm61sH2wa4wa4X9qlzugTv79 g4tVKjtbr3RPLGDI/iqwHTsA= X-Virus-Scanned: Debian amavisd-new at mail.envs.net Received: from mail.envs.net ([127.0.0.1]) by localhost (mail.envs.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id UESCZvR8rFHt; Thu, 23 Jan 2025 06:25:56 +0000 (UTC) Received: from localhost (unknown [112.44.100.254]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.envs.net (Postfix) with ESMTPSA; Thu, 23 Jan 2025 06:25:55 +0000 (UTC) Received: from localhost.localdomain (localhost.lan [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 55cbef31; Thu, 23 Jan 2025 06:29:11 +0000 (UTC) Date: Thu, 23 Jan 2025 14:28:58 +0800 Message-ID: <96b1c701576df682137650386544821196e2152d.1737613671.git.iyzsong@member.fsf.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <916f2d3087c47d6212682656f47a2899ba795df1.1737613671.git.iyzsong@member.fsf.org> References: <916f2d3087c47d6212682656f47a2899ba795df1.1737613671.git.iyzsong@member.fsf.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: iyzsong@envs.net X-ACL-Warn: , iyzsong--- via Guix-patches X-Patchwork-Original-From: iyzsong--- via Guix-patches via From: tusharhero--- via Guix-patches via Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches From: 宋文武 * guix/build/glib-or-gtk-build-system.scm (write-search-path-file): New procedure. (gtk-module-directories): Add version to arguments. (gsettings-schema-directories): New procedure. (data-directories): Don't check for "/glib-2.0/schemas". (conf-directories): New procedure. (wrap-all-programs): Rewrite in terms of 'write-search-path-file'. Change-Id: I1c9e8d491b96e298d1568a5e29b04c762c26e4d1 --- guix/build/glib-or-gtk-build-system.scm | 165 ++++++++++++++---------- 1 file changed, 94 insertions(+), 71 deletions(-) diff --git a/guix/build/glib-or-gtk-build-system.scm b/guix/build/glib-or-gtk-build-system.scm index 67a52ddad3..a04c1b0616 100644 --- a/guix/build/glib-or-gtk-build-system.scm +++ b/guix/build/glib-or-gtk-build-system.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2018 Mark H Weaver ;;; Copyright © 2021 Maxime Devos ;;; Copyright © 2021 Maxim Cournoyer +;;; Copyright © 2025 宋文武 ;;; ;;; This file is part of GNU Guix. ;;; @@ -39,6 +40,13 @@ (define-module (guix build glib-or-gtk-build-system) ;; ;; Code: +(define* (write-search-path-file output variable value) + "Write VALUE to @file{etc/search-paths.d/VARIABLE} under OUTPUT." + (let ((search-paths.d (string-append output "/etc/search-paths.d"))) + (mkdir-p search-paths.d) + (with-output-to-file (string-append search-paths.d "/" variable) + (lambda () (display variable))))) + (define (subdirectory-exists? parent sub-directory) (directory-exists? (string-append parent sub-directory))) @@ -47,32 +55,12 @@ (define (directory-included? directory directories-list) (fold (lambda (s p) (or (string-ci=? s directory) p)) #f directories-list)) -;; We do not include $HOME/.guix-profile/gtk-v.0 (v=2 or 3) because we do not -;; want to mix gtk+-2 and gtk+-3 modules. See -;; https://developer.gnome.org/gtk3/stable/gtk-running.html -(define (gtk-module-directories inputs) - "Check for the existence of \"libdir/gtk-v.0\" in INPUTS. Return a list +;; We load GTK modules via the GUIX_GTK2_PATH, GUIX_GTK3_PATH and GUIX_GTK4_PATH +;; search paths. +(define (gtk-module-directories inputs version) + "Check for the existence of \"libdir/gtk-VERSION\" in INPUTS. Return a list with all found directories." - (let* ((version - (cond - ((string-match "gtk-4" - (or (assoc-ref inputs "gtk") - (assoc-ref inputs "source") - "")) - "4.0") - ((string-match "gtk\\+-3" - (or (assoc-ref inputs "gtk+") - (assoc-ref inputs "source") - "")) - "3.0") - ((string-match "gtk\\+-2" - (or (assoc-ref inputs "gtk+") - (assoc-ref inputs "source") - "")) - "2.0") - (else - "4.0"))) ; We default to version 4.0. - (gtk-module + (let ((gtk-module (lambda (input prev) (let* ((in (match input ((_ . dir) dir) @@ -85,27 +73,22 @@ (define (gtk-module-directories inputs) prev))))) (fold gtk-module '() inputs))) -;; See +;; XDG data files include themes, sounds, icons, etc. See: ;; http://www.freedesktop.org/wiki/DesktopThemeSpec ;; http://freedesktop.org/wiki/Specifications/sound-theme-spec ;; http://freedesktop.org/wiki/Specifications/icon-theme-spec ;; -;; Currently desktop themes are not well supported and do not honor -;; XDG_DATA_DIRS. One example is evince which only looks for desktop themes -;; in $HOME/.themes (for backward compatibility) and in XDG_DATA_HOME (which -;; defaults to $HOME/.local/share). One way to handle these applications -;; appears to be by making $HOME/.themes a symlink to -;; $HOME/.guix-profile/share/themes. +;; We load them via XDG_DATA_DIRS (from profile, has higher priority) and +;; GUIX_XDG_DATA_DIRS (application specified) search paths. (define (data-directories inputs) - "Check for the existence of \"$datadir/glib-2.0/schemas\" or XDG themes data -in INPUTS. Return a list with all found directories." + "Check for the existence of XDG data files in INPUTS. Return a list with all found +directories." (define (data-directory input previous) (let* ((in (match input ((_ . dir) dir) (_ ""))) (datadir (string-append in "/share"))) - (if (and (or (subdirectory-exists? datadir "/glib-2.0/schemas") - (subdirectory-exists? datadir "/sounds") + (if (and (or (subdirectory-exists? datadir "/sounds") (subdirectory-exists? datadir "/themes") (subdirectory-exists? datadir "/cursors") (subdirectory-exists? datadir "/wallpapers") @@ -117,15 +100,45 @@ (define (data-directories inputs) (fold data-directory '() inputs)) +;;; XDG configuration files are expected to be installed in etc/xdg directory. +;;; We load them via XDG_CONFIG_DIRS (from profile, has higher priority) and +;;; GUIX_XDG_CONFIG_DIRS (application specified) search paths. +(define (conf-directories inputs) + "Check for the existence of XDG configuration files in INPUTS. Return a list with +all found directories." + (define (conf-directory input previous) + (let* ((in (match input + ((_ . dir) dir) + (_ ""))) + (conf-dir (string-append in "etc/xdg"))) + (if (and (directory-exists? conf-dir) + (not (directory-included? conf-dir previous))) + (cons conf-dir previous) + previous))) + + (fold conf-directory '() inputs)) + +;;; GIO GSettings schemas are expected to be installed in $datadir/glib-2.0/schemas +;;; directory. We load them via the GUIX_GSETTINGS_SCHEMA_DIR search path. +(define (gsettings-schema-directories inputs) + "Check for the existence of \"$datadir/glib-2.0/schemas\" in INPUTS. +Return a list with all found directories." + (define (gsettings-schema-directory input previous) + (let* ((in (match input + ((_ . dir) dir) + (_ ""))) + (schema-dir (string-append in "/share/glib-2.0/schemas"))) + (if (and (directory-exists? schema-dir) + (not (directory-included? schema-dir previous))) + (cons schema-dir previous) + previous))) + + (fold gsettings-schema-directory '() inputs)) + ;; All GIO modules are expected to be installed in GLib's $libdir/gio/modules ;; directory. That directory has to include a file called giomodule.cache -;; listing all available modules. GIO can be made aware of modules in other -;; directories with the help of the environment variable GIO_EXTRA_MODULES. -;; The official GIO documentation states that this environment variable should -;; only be used for testing and not in a production environment. However, it -;; appears that there is no other way of specifying multiple modules -;; directories (NIXOS also does use this variable). See -;; https://developer.gnome.org/gio/stable/running-gio-apps.html +;; listing all available modules. We load them via the GUIX_GIO_EXTRA_MODULES +;; search path. (define (gio-module-directories inputs) "Check for the existence of \"$libdir/gio/modules\" in the INPUTS and returns a list with all found directories." @@ -141,50 +154,60 @@ (define (gio-module-directories inputs) (fold gio-module-directory '() inputs)) + (define* (wrap-all-programs #:key inputs outputs (glib-or-gtk-wrap-excluded-outputs '()) #:allow-other-keys) "Implement phase \"glib-or-gtk-wrap\": look for GSettings schemas and -gtk+-v.0 libraries and create wrappers with suitably set environment variables +GTK libraries and create etc/search-paths.d with suitably set of files if found. Wrapping is not applied to outputs whose name is listed in GLIB-OR-GTK-WRAP-EXCLUDED-OUTPUTS. This is useful when an output is known not to contain any GLib or GTK+ binaries, and where wrapping would gratuitously -add a dependency of that output on GLib and GTK+." - ;; Do not require bash to be present in the package inputs - ;; even when there is nothing to wrap. - ;; Also, calculate (sh) only once to prevent some I/O. - (define %sh (delay (search-input-file inputs "bin/bash"))) - (define (sh) (force %sh)) +add a dependency of that output on GLib and GTK." (define handle-output (match-lambda ((output . directory) (unless (member output glib-or-gtk-wrap-excluded-outputs) - (let* ((bindir (string-append directory "/bin")) - (libexecdir (string-append directory "/libexec")) - (bin-list (filter (negate wrapped-program?) - (append (find-files bindir ".*") - (find-files libexecdir ".*")))) - (datadirs (data-directories + (let* ((datadirs (data-directories (alist-cons output directory inputs))) - (gtk-mod-dirs (gtk-module-directories + (confdirs (conf-directories (alist-cons output directory inputs))) - (gio-mod-dirs (gio-module-directories + (schemadirs (gsettings-schema-directories (alist-cons output directory inputs))) - (env-vars `(,@(if (not (null? datadirs)) - (list `("XDG_DATA_DIRS" ":" prefix ,datadirs)) - '()) - ,@(if (not (null? gtk-mod-dirs)) - (list `("GTK_PATH" ":" prefix ,gtk-mod-dirs)) - '()) - ,@(if (not (null? gio-mod-dirs)) - (list `("GIO_EXTRA_MODULES" ":" - prefix ,gio-mod-dirs)) - '())))) - (for-each (lambda (program) - (apply wrap-program program #:sh (sh) env-vars)) - bin-list)))))) + (gtk2-mod-dirs (gtk-module-directories + (alist-cons output directory inputs) + "2.0")) + (gtk3-mod-dirs (gtk-module-directories + (alist-cons output directory inputs) + "3.0")) + (gtk4-mod-dirs (gtk-module-directories + (alist-cons output directory inputs) + "4.0")) + (gio-mod-dirs (gio-module-directories + (alist-cons output directory inputs)))) + (when (not (null? datadirs)) + (write-search-path-file output "GUIX_XDG_DATA_DIRS" + (string-join datadirs ":"))) + (when (not (null? confdirs)) + (write-search-path-file output "GUIX_XDG_CONFIG_DIRS" + (string-join confdirs ":"))) + (when (not (null? schemadirs)) + (write-search-path-file output "GUIX_GSETTINGS_SCHEMA_DIR" + (string-join schemadirs ":"))) + (when (not (null? gtk2-mod-dirs)) + (write-search-path-file output "GUIX_GTK2_PATH" + (string-join gtk2-mod-dirs ":"))) + (when (not (null? gtk3-mod-dirs)) + (write-search-path-file output "GUIX_GTK3_PATH" + (string-join gtk3-mod-dirs ":"))) + (when (not (null? gtk4-mod-dirs)) + (write-search-path-file output "GUIX_GTK4_PATH" + (string-join gtk4-mod-dirs ":"))) + (when (not (null? gio-mod-dirs)) + (write-search-path-file output "GUIX_GIO_EXTRA_MODULES" + (string-join gio-mod-dirs ":")))))))) (for-each handle-output outputs))