From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: Re: [PATCH 2/2] profiles: Build GTK+ input module cache. Date: Mon, 26 Sep 2016 07:56:14 +0200 Message-ID: <87mvivw6f5.fsf@elephly.net> References: <20160922202827.22039-1-rekado@elephly.net> <20160922202827.22039-2-rekado@elephly.net> <87lgygusp3.fsf@member.fsf.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boOtv-0002QF-JO for guix-devel@gnu.org; Mon, 26 Sep 2016 01:56:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1boOts-0008Ug-Fc for guix-devel@gnu.org; Mon, 26 Sep 2016 01:56:27 -0400 Received: from sender163-mail.zoho.com ([74.201.84.163]:21405) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boOts-0008UB-7N for guix-devel@gnu.org; Mon, 26 Sep 2016 01:56:24 -0400 In-reply-to: <87lgygusp3.fsf@member.fsf.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: =?utf-8?B?5a6L5paH5q2m?= Cc: guix-devel@gnu.org 宋文武 writes: > Ricardo Wurmus writes: > >> * guix/profiles.scm (gtk-im-modules): New procedure. >> (%default-profile-hooks): Add it. >> --- >> guix/profiles.scm | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 63 insertions(+) >> >> diff --git a/guix/profiles.scm b/guix/profiles.scm >> index 78deeb7..1a522ae 100644 >> --- a/guix/profiles.scm >> +++ b/guix/profiles.scm >> @@ -723,6 +723,68 @@ creates the GTK+ 'icon-theme.cache' file for each theme." >> #:substitutable? #f) >> (return #f)))) >> >> +(define (gtk-im-modules manifest) >> + "Return a derivation that builds the cache files for input method modules >> +for both major versions of GTK+." >> + >> + (mlet %store-monad ((gtk+ (manifest-lookup-package manifest "gtk+" "3")) >> + (gtk+-2 (manifest-lookup-package manifest "gtk+" "2"))) >> + >> + (define (build gtk gtk-version) >> + (let ((major (string-take gtk-version 1))) >> + (with-imported-modules '((guix build utils) >> + (guix build union) >> + (guix build profiles) >> + (guix search-paths) >> + (guix records)) >> + #~(begin >> + (use-modules (guix build utils) >> + (guix build union) >> + (guix build profiles) >> + (ice-9 popen) >> + (srfi srfi-26)) >> + >> + (let* ((prefix (string-append "/lib/gtk-" #$major ".0/" >> + #$gtk-version)) >> + (query (string-append #$gtk "/bin/gtk-query-immodules-" >> + #$major ".0")) >> + (destdir (string-append #$output prefix)) >> + (moddirs (cons (string-append #$gtk prefix "/immodules") >> + (filter file-exists? >> + (map (cut string-append <> prefix "/immodules") >> + '#$(manifest-inputs manifest)))))) >> + >> + ;; Union all the gtk immodules directories. >> + (mkdir-p (string-append #$output "/lib/gtk-" #$major ".0")) >> + (union-build destdir moddirs #:log-port >> (%make-void-port "w")) > > I think there is no need to run `union-build'. Other hooks use it > because they (eg: update-icon-cache, update-mime-databes) require input > and output files in a single directory. You are right. This is a left-over of previous experimentation. I previously tried to do without pipes and rewrite some environment variables instead, but that needed a single directory, hence the union. >> + >> + ;; Generate a new 'immodules.cache' file. >> + (let ((pipe (apply open-pipe* >> + OPEN_READ query >> + (map readlink (find-files >> destdir "\\.so$")))) > and use 'moddirs' here should work. Using “moddirs” directly won’t work because it’s a list of directories. I added another definition of “modules”, which is a flattened list of the result of “find-files” on all the directories. I tested the resulting cache files and they work fine with our patched versions of GTK. (The simple GTK input methods e.g. for switching between Qwerty and Dvorak no longer work, but that appears to be unrelated.) I’ll push the updated version of this patch in a moment. ~~ Ricardo