From patchwork Tue Apr 5 15:15:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Munksgaard X-Patchwork-Id: 38338 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 7297727BBEA; Tue, 5 Apr 2022 21:00:35 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 C5A1B27BBE9 for ; Tue, 5 Apr 2022 21:00:34 +0100 (BST) Received: from localhost ([::1]:52962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nbpLt-0000R8-RW for patchwork@mira.cbaines.net; Tue, 05 Apr 2022 16:00:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nbkuY-0000rA-Iu for guix-patches@gnu.org; Tue, 05 Apr 2022 11:16:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:33735) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nbkuY-0003ha-3N for guix-patches@gnu.org; Tue, 05 Apr 2022 11:16:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nbkuX-00031F-Ue for guix-patches@gnu.org; Tue, 05 Apr 2022 11:16:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54729] [PATCH] build: haskell-build-system: Support packages w. multiple libraries Resent-From: Philip Munksgaard Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 05 Apr 2022 15:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 54729 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 54729@debbugs.gnu.org Cc: Philip Munksgaard X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.164917175110930 (code B ref -1); Tue, 05 Apr 2022 15:16:01 +0000 Received: (at submit) by debbugs.gnu.org; 5 Apr 2022 15:15:51 +0000 Received: from localhost ([127.0.0.1]:55865 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nbkuM-0002pp-AT for submit@debbugs.gnu.org; Tue, 05 Apr 2022 11:15:51 -0400 Received: from lists.gnu.org ([209.51.188.17]:47680) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nbkuH-0002k1-9F for submit@debbugs.gnu.org; Tue, 05 Apr 2022 11:15:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nbkuF-0000g3-FW for guix-patches@gnu.org; Tue, 05 Apr 2022 11:15:45 -0400 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:36817) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nbku9-0003Yo-DR for guix-patches@gnu.org; Tue, 05 Apr 2022 11:15:39 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 804DA3201F94; Tue, 5 Apr 2022 11:15:33 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 05 Apr 2022 11:15:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=munksgaard.me; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to; s=fm1; bh=TqaJK+0aFPwcav/bZEWojcBBg2eUcA1CH70sE1 Qwu4U=; b=pp0lYF7TtnWG6sSuLjT9R5VHlTe4z+I60ONRnWcwWDmv8vcRdlKGK7 bIBwS6qEPpGoyL3BiMJFh6Sn5RVI9yGkrU0a6io1rZrIJo/lGdMFN4pW2E1bUc0h YyNryJVUOVvDfego6vPL1iJ8L627xlNjWrAvCT3ABvyRA+DZkgPAmz0Mbpdrh2t/ NjXyVUzNzk/fdFZk17ufXrlG9cn7QnqlqEBFj9JqBasFoJyph+neq2P3Mx+vYzaW ELcT2DuB/SjyXhEIMi48/arTFhIG+TiICoWjXUnOpmKqvJBeD+CHdH88aqNGxmgE INvbl5Jozsanv+MagS+09Co/IurdIy8A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :from:from:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=TqaJK+0aFPwcav/bZEWojcBBg2eUc A1CH70sE1Qwu4U=; b=b3u8mXQx4jlabL03lc6/f+pPccsjWLkRsvMhub8R9j0jR fGcMO4+t7TiUevZnwQH4nc4CTXU9QfUv1kv2kypUmMxXVzUQNHVs98rf199n4iR3 Pb9icRqSKcZ/ENbGatiN/RDR4lXi8/Voanc/7pe1ly1tE6LmHb7TtwNpAHO7hUWF qkbqvoketaeVUlHrLsiGJAk+BSKJw9T/AyyFcZXFOpdsnjmqlZz/WLxKIyrCM0m+ uFNiMRDM3vEWEc2mzeIyU9dnoUvbyEFXOb56ITiWv85ZnyczYKBnQlADuFhnQi0K uYz3ve2sFHZeHNewnN4i0ArFavXi418qHpam/uV5Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudejgedgkeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomheprfhhihhlihhpucfouhhnkhhsghgrrghrugcuoehphhhilhhiphes mhhunhhkshhgrggrrhgurdhmvgeqnecuggftrfgrthhtvghrnhepveevkefhuedvtdffhf ekffeljefhueevjeejteeiteetudfhueffjefggeefveelnecuffhomhgrihhnpehgnhhu rdhorhhgpdhhrghskhgvlhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomhepphhhihhlihhpsehmuhhnkhhsghgrrghrugdrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 5 Apr 2022 11:15:31 -0400 (EDT) From: Philip Munksgaard Date: Tue, 5 Apr 2022 17:15:29 +0200 Message-Id: <8a396a9803fc35ee63f01e608f87ffb16863bc6d.1649171729.git.philip@munksgaard.me> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Received-SPF: pass client-ip=64.147.123.20; envelope-from=philip@munksgaard.me; helo=wout4-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Mailman-Approved-At: Tue, 05 Apr 2022 15:58:02 -0400 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches As discussed in #53655 [0], haskell-build-system.scm does not currently support packages which contain multiple libraries, such as attoparsec [1]. Such libraries are often used for internal or convenience libraries, as detailed in the documentation [2]. The current state of affairs means that attoparsec and any other libraries with similar structure cannot be built on guix, nor can any library or executable that depends on such a library. Instead of assuming that `runhaskell Setup.hs --gen-pkg-config=...` always outputs a single file, we detect whether the result was a directory. If so, we need to handle each file independently in lexicographic order by calling the new private function `install-from-config-file`. Because `install-transitive-deps` can now be called multiple times for each call to `register`, it has also been amended to support the files already installed. 0: https://issues.guix.gnu.org/53655 1: https://hackage.haskell.org/package/attoparsec-0.14.4/attoparsec.cabal 2: https://downloads.haskell.org/cabal/Cabal-3.0.0.0/doc/users-guide/installing-packages.html#cmdoption-setup-register-gen-pkg-config --- guix/build/haskell-build-system.scm | 34 ++++++++++++++++++----------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/guix/build/haskell-build-system.scm b/guix/build/haskell-build-system.scm index ef6cb316ee..e827e23aba 100644 --- a/guix/build/haskell-build-system.scm +++ b/guix/build/haskell-build-system.scm @@ -217,11 +217,13 @@ (define* (register #:key name system inputs outputs #:allow-other-keys) (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*) + (when (not (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)))))) (let* ((out (assoc-ref outputs "out")) @@ -234,13 +236,12 @@ (define* (register #:key name system inputs outputs #:allow-other-keys) "/ghc-" version "/" name ".conf.d")) (id-rx (make-regexp "^id:[ \n\t]+([^ \t\n]+)$" regexp/newline)) - (config-file (string-append out "/" name ".conf")) + (config-output (string-append out "/" name ".conf")) (params - (list (string-append "--gen-pkg-config=" config-file)))) + (list (string-append "--gen-pkg-config=" config-output)))) (run-setuphs "register" params) - ;; The conf file is created only when there is a library to register. - (when (file-exists? config-file) - (mkdir-p config-dir) + + (define (install-from-config-file config-file) (let* ((contents (call-with-input-file config-file read-string)) (config-file-name+id (match:substring (first (list-matches id-rx contents)) 1))) @@ -270,10 +271,17 @@ (define* (register #:key name system inputs outputs #:allow-other-keys) (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"))) + config-file-name+id ".conf")))) + + ;; The conf file is created only when there is a library to register. + (when (file-exists? config-output) + (mkdir-p config-dir) + (if (file-is-directory? config-output) + (for-each install-from-config-file (find-files config-output)) + (install-from-config-file config-output)) + (invoke "ghc-pkg" + (string-append "--package-db=" config-dir) + "recache")) #t)) (define* (check #:key tests? test-target #:allow-other-keys)