From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <guix-patches-bounces+larch=yhetil.org@gnu.org> Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id OOlqHurnTWIBewAAgWs5BA (envelope-from <guix-patches-bounces+larch=yhetil.org@gnu.org>) for <larch@yhetil.org>; Wed, 06 Apr 2022 21:20:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 6LDNG+rnTWKaIQEA9RJhRA (envelope-from <guix-patches-bounces+larch=yhetil.org@gnu.org>) for <larch@yhetil.org>; Wed, 06 Apr 2022 21:20:10 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D30EEFDDB for <larch@yhetil.org>; Wed, 6 Apr 2022 21:20:09 +0200 (CEST) Received: from localhost ([::1]:42320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <guix-patches-bounces+larch=yhetil.org@gnu.org>) id 1ncBCK-0003Xs-FP for larch@yhetil.org; Wed, 06 Apr 2022 15:20:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55126) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1ncBCE-0003Vp-S7 for guix-patches@gnu.org; Wed, 06 Apr 2022 15:20:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:37038) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1ncBCE-00040l-IX for guix-patches@gnu.org; Wed, 06 Apr 2022 15:20:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1ncBCE-0002uX-BK for guix-patches@gnu.org; Wed, 06 Apr 2022 15:20:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54729] [PATCH core-updates v2 2/2] build: haskell-build-system: Support multiple libraries. Resent-From: zimoun <zimon.toutoune@gmail.com> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 06 Apr 2022 19:20:02 +0000 Resent-Message-ID: <handler.54729.B54729.164927277011127@debbugs.gnu.org> Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54729 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 54729@debbugs.gnu.org Cc: Philip Munksgaard <philip@munksgaard.me>, zimoun <zimon.toutoune@gmail.com> Received: via spool by 54729-submit@debbugs.gnu.org id=B54729.164927277011127 (code B ref 54729); Wed, 06 Apr 2022 19:20:02 +0000 Received: (at 54729) by debbugs.gnu.org; 6 Apr 2022 19:19:30 +0000 Received: from localhost ([127.0.0.1]:59167 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1ncBBh-0002tN-Q6 for submit@debbugs.gnu.org; Wed, 06 Apr 2022 15:19:30 -0400 Received: from mail-wr1-f42.google.com ([209.85.221.42]:36380) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <zimon.toutoune@gmail.com>) id 1ncBBe-0002sr-Pg for 54729@debbugs.gnu.org; Wed, 06 Apr 2022 15:19:27 -0400 Received: by mail-wr1-f42.google.com with SMTP id u3so4688556wrg.3 for <54729@debbugs.gnu.org>; Wed, 06 Apr 2022 12:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G/eDU2C54YUH9mTJCSxb2PuIDuSay4sTs+jgDyjAG/w=; b=qNYRVYQmhRTcX6a/NZcH+Si+PtBvkzznYo8psDwc1n2dUty/4AstiGbb+PAl/DVjOU NImh+ywErefI+eIIiT9TQMIk2Rr1dR9Tb8KtsGc9AQNd5ldg1NGBcmp6Lg5wUPqUDasA 6JnRPAkG9XZyg1lGxQ+xJSGs23DHQgK9w2KCGijGMtkHsiO9qA80UXm1l/Ru8Chbd0k/ 82j5nwFGkG7WAAX2PaqB0q+oPCVlVeOqW+kV0AnzQVqOe4pRhL0WEI1+S1llD3kwH9jX yXtypn7wZYX6ooRUymFMUFTqrTveF5RAYQ+9Q95m8o0FPNVpDjw4knC41PKsyFSiZ1eX POPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G/eDU2C54YUH9mTJCSxb2PuIDuSay4sTs+jgDyjAG/w=; b=v/uDudZ6Z/96VjTRXlRg48vl7lF0rZbce0iMs2/DG9Ty+IGMAcq2Hgl+JAIky/dcGs 21Y3WtIW3D1ea8xGhNF+WVqYgzaCPIJzDcvA3MDQA9D2WY2GHB6VRsZCcx8Fjs28gUoh mMlLwBjdxzLkKOTdtqwZLIy0KBqiuBBWj4hfqX7yqF/eRJpm33/G/1cVKHJ9LPv7r2zY zcwZG6fijZEeYegKhPvNAu9bSj5QWSQJUV796m7HRa16QoH6E1yiciRnj2IZ4iSQNNQu 6FpK0SF0SvCqaEj798W/g3taNBvwtc7KyXwpKNBHh59zcdL4XQI4IOPQUepMtnKD7Jq+ LoaA== X-Gm-Message-State: AOAM531Ln8CJFcVp9NHqlRcDagHFNgNrlT2NAhIHpmUqequzj3gzyXma 2/dUU6EmC+b2eERuUCeaDE2uLTzbyys= X-Google-Smtp-Source: ABdhPJzHtkMcl6H+spEDxvLugvbNh8rGwpug+J9P/laBIPnBc98yx/nDuh1ROq6pt2hIZt9GiqEf5w== X-Received: by 2002:a5d:49c9:0:b0:206:1327:5058 with SMTP id t9-20020a5d49c9000000b0020613275058mr7831013wrs.555.1649272761184; Wed, 06 Apr 2022 12:19:21 -0700 (PDT) Received: from localhost.localdomain ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id u12-20020a5d6dac000000b00204119d37d0sm15230647wrs.26.2022.04.06.12.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 12:19:20 -0700 (PDT) From: zimoun <zimon.toutoune@gmail.com> Date: Wed, 6 Apr 2022 21:19:08 +0200 Message-Id: <20220406191908.2393054-2-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20220406191908.2393054-1-zimon.toutoune@gmail.com> References: <20220406191908.2393054-1-zimon.toutoune@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=subscribe> Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" <guix-patches-bounces+larch=yhetil.org@gnu.org> X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1649272810; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=G/eDU2C54YUH9mTJCSxb2PuIDuSay4sTs+jgDyjAG/w=; b=qttp9XFIS7hCuBG7EXzjj7JDNKQkpSvT9cDNldPWmYgihzN4nKY+VznwrOVD7FJVEvNFi1 INE1VhNtjCBwDXZk7iwC2S+ZkQXfpApHH28VvekYHZrVoSvWlFuy19NF/+BHrWRmbdLXxZ fsfZpmCVAs/SxEfOdtFEK5faCIlIS8gNsy9q8DOOsDUo4vz+nWxX2v2rBY8ZqDDoPvKHm1 c4d6LROTbL2dOff4ZdQtEYWtiPdGjcdgSj6wQMNRmfRhQZF4PKeyedloiI0uy6iIku8qVL GMLjNs+QzyHx6Q7RuT0l1WFprsFdJdYY64llugCeTcKnAyRtj9CUhcxSMtxewA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1649272810; a=rsa-sha256; cv=none; b=ISBUPovYebYD9AoCBH6SyR9zGKlXQOOXbC0Ex+hZkbTgywBGYSz5jRAKymTXjYWEh4BhG+ 9Iywz3X8wj3G4GcpbmNh+9dI1J3cvQbFqirL+Fk18clLBMDa4Z/eQyeEFzV/cdj6WochUX YvUFSQlPu+m0aHhiehg9PJaUiUp3qQo0NeM07Kf+Yezx1vQ2XtpKs02gVtWe0lUTmbGImK yL3tIsTvRfYlaff+8lHPfa5gDBO+I0cBiSOa3XpPAIpKpFE5AidhlC/q/aXVMTPFdbhwqI 7KwCuToJQ4aVHtbW4duyjqnT6U4b4b9B8wnxddA6wiREx0FJQpMexWK85VoBXA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=qNYRVYQm; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 4.53 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=qNYRVYQm; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: D30EEFDDB X-Spam-Score: 4.53 X-Migadu-Scanner: scn0.migadu.com X-TUID: /a4mN4DgHGga From: Philip Munksgaard <philip@munksgaard.me> Fixes <https://bugs.gnu.org/53655>. The patch handles correctly the multiple registration of some package using their own internal sub-libraries. It allows to call 'install-transitive-deps' multiple times and deals with packages requiring a multiple registration. * guix/build/haskell-build-system.scm (register)[install-transitive-deps]: Guard also the destination direction. [install-config-file]: New procedure. Co-Authored-by: zimoun <zimon.toutoune@gmail.com>. --- guix/build/haskell-build-system.scm | 87 ++++++++++++++++------------- 1 file changed, 49 insertions(+), 38 deletions(-) diff --git a/guix/build/haskell-build-system.scm b/guix/build/haskell-build-system.scm index e2e5904dce..fb4aba28ea 100644 --- a/guix/build/haskell-build-system.scm +++ b/guix/build/haskell-build-system.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com> ;;; Copyright © 2021 John Kehayias <john.kehayias@protonmail.com> ;;; Copyright © 2022 Simon Tournier <zimon.toutoune@gmail.com> +;;; Copyright © 2022 Philip Munksgaard <philip@munksgaard.me> ;;; ;;; This file is part of GNU Guix. ;;; @@ -215,13 +216,50 @@ (define (install-transitive-deps conf-file src dest) (if (not (vhash-assoc id seen)) (let ((dep-conf (string-append src "/" id ".conf")) (dep-conf* (string-append dest "/" id ".conf"))) - (when (not (file-exists? dep-conf)) + (unless (file-exists? dep-conf*) + (unless (file-exists? dep-conf) (error (format #f "File ~a does not exist. This usually means the dependency ~a is missing. Was checking conf-file ~a." dep-conf id conf-file))) - (copy-file dep-conf dep-conf*) ;XXX: maybe symlink instead? - (loop (vhash-cons id #t seen) - (append lst (conf-depends dep-conf)))) + (copy-file dep-conf dep-conf*) ;XXX: maybe symlink instead? + (loop (vhash-cons id #t seen) + (append lst (conf-depends dep-conf))))) (loop seen tail)))))) + (define (install-config-file conf-file dest output:doc output:lib) + ;; Copy CONF-FILE to DEST removing reference to OUTPUT:DOC from + ;; OUTPUT:LIB and using install-transitive-deps. + (let* ((contents (call-with-input-file conf-file read-string)) + (id-rx (make-regexp "^id:[ \n\t]+([^ \t\n]+)$" regexp/newline)) + (config-file-name+id + (match:substring (first (list-matches id-rx contents)) 1))) + + (when (or + (and + (string? config-file-name+id) + (string-null? config-file-name+id)) + (not config-file-name+id)) + (error (format #f "The package id for ~a is empty. This is a bug." conf-file))) + + ;; Remove reference to "doc" output from "lib" (or "out") by rewriting the + ;; "haddock-interfaces" field and removing the optional "haddock-html" + ;; field in the generated .conf file. + (when output:doc + (substitute* conf-file + (("^haddock-html: .*") "\n") + (((format #f "^haddock-interfaces: ~a" output:doc)) + (string-append "haddock-interfaces: " output:lib))) + ;; Move the referenced file to the "lib" (or "out") output. + (match (find-files output:doc "\\.haddock$") + ((haddock-file . rest) + (let* ((subdir (string-drop haddock-file (string-length output:doc))) + (new (string-append output:lib subdir))) + (mkdir-p (dirname new)) + (rename-file haddock-file new))) + (_ #f))) + (install-transitive-deps conf-file %tmp-db-dir dest) + (rename-file conf-file + (string-append dest "/" + config-file-name+id ".conf")))) + (let* ((out (assoc-ref outputs "out")) (doc (assoc-ref outputs "doc")) (haskell (assoc-ref inputs "haskell")) @@ -231,7 +269,6 @@ (define (install-transitive-deps conf-file src dest) (config-dir (string-append lib "/ghc-" version "/" name ".conf.d")) - (id-rx (make-regexp "^id:[ \n\t]+([^ \t\n]+)$" regexp/newline)) (config-file (string-append out "/" name ".conf")) (params (list (string-append "--gen-pkg-config=" config-file)))) @@ -239,39 +276,13 @@ (define (install-transitive-deps conf-file src dest) ;; The conf file is created only when there is a library to register. (when (file-exists? config-file) (mkdir-p config-dir) - (let* ((contents (call-with-input-file config-file read-string)) - (config-file-name+id (match:substring (first (list-matches id-rx contents)) 1))) - - (when (or - (and - (string? config-file-name+id) - (string-null? config-file-name+id)) - (not config-file-name+id)) - (error (format #f "The package id for ~a is empty. This is a bug." config-file))) - - ;; Remove reference to "doc" output from "lib" (or "out") by rewriting the - ;; "haddock-interfaces" field and removing the optional "haddock-html" - ;; field in the generated .conf file. - (when doc - (substitute* config-file - (("^haddock-html: .*") "\n") - (((format #f "^haddock-interfaces: ~a" doc)) - (string-append "haddock-interfaces: " lib))) - ;; Move the referenced file to the "lib" (or "out") output. - (match (find-files doc "\\.haddock$") - ((haddock-file . rest) - (let* ((subdir (string-drop haddock-file (string-length doc))) - (new (string-append lib subdir))) - (mkdir-p (dirname new)) - (rename-file haddock-file new))) - (_ #f))) - (install-transitive-deps config-file %tmp-db-dir config-dir) - (rename-file config-file - (string-append config-dir "/" - config-file-name+id ".conf")) - (invoke "ghc-pkg" - (string-append "--package-db=" config-dir) - "recache"))))) + (if (file-is-directory? config-file) + (for-each (cut install-config-file <> config-dir doc lib) + (find-files config-file)) + (install-config-file config-file config-dir doc lib)) + (invoke "ghc-pkg" + (string-append "--package-db=" config-dir) + "recache")))) (define* (check #:key tests? test-target #:allow-other-keys) "Run the test suite of a given Haskell package." -- 2.34.0